Skip to content

Commit

Permalink
OcAcpiLib: Provide Base lookup for ACPI patches (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 authored Mar 15, 2021
1 parent b7ba490 commit 5880ec2
Show file tree
Hide file tree
Showing 47 changed files with 2,821 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ xcuserdata
project.xcworkspace
*.dSYM
Utilities/AppleEfiSignTool/AppleEfiSignTool
Utilities/ACPIe/ACPIe
Utilities/acdtinfo/acdtinfo
Utilities/disklabel/disklabel
Utilities/EfiResTool/EfiResTool
Expand Down
24 changes: 24 additions & 0 deletions Docs/Configuration.tex
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,27 @@ \subsection{Patch Properties}\label{acpipropspatch}

\begin{enumerate}

\item
\texttt{Base}\\
\textbf{Type}: \texttt{plist\ string}\\
\textbf{Failsafe}: Empty (Ignored)\\
\textbf{Description}: Selects ACPI path base for patch lookup (or immediate
replacement) by obtaining the offset to the provided path.

Only fully-qualified absolute paths are supported (e.g. \texttt{\textbackslash \_SB\_.PCI0.GFX0}).
Currently supported object types are: \texttt{Device}, \texttt{Field}, \texttt{Method}.

\emph{Note}: Use with care, not all OEM tables can be parsed. Use \texttt{ACPIe}
utility to debug. \texttt{ACPIe} compiled with \texttt{DEBUG=1 make} command
produces helpful ACPI lookup tracing.

\item
\texttt{BaseSkip}\\
\textbf{Type}: \texttt{plist\ integer}\\
\textbf{Failsafe}: \texttt{0} (Do not skip any occurrences)\\
\textbf{Description}: Number of found \texttt{Base} occurrences to skip before
finds and replacements are applied.

\item
\texttt{Comment}\\
\textbf{Type}: \texttt{plist\ string}\\
Expand All @@ -992,6 +1013,9 @@ \subsection{Patch Properties}\label{acpipropspatch}
\textbf{Failsafe}: Empty\\
\textbf{Description}: Data to find. Must be equal to \texttt{Replace} in size if set.

\emph{Note}: Can be empty, when \texttt{Base} is specified, immediate replacement
after \texttt{Base} lookup happens in this case.

\item
\texttt{Limit}\\
\textbf{Type}: \texttt{plist\ integer}\\
Expand Down
4 changes: 4 additions & 0 deletions Docs/Sample.plist
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@
<key>Patch</key>
<array>
<dict>
<key>Base</key>
<string>\_SB_.PCI0.GFX0</string>
<key>BaseSkip</key>
<integer>0</integer>
<key>Comment</key>
<string>Replace one byte sequence with another</string>
<key>Count</key>
Expand Down
4 changes: 4 additions & 0 deletions Docs/SampleCustom.plist
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@
<key>Patch</key>
<array>
<dict>
<key>Base</key>
<string>\_SB_.PCI0.GFX0</string>
<key>BaseSkip</key>
<integer>0</integer>
<key>Comment</key>
<string>Replace one byte sequence with another</string>
<key>Count</key>
Expand Down
32 changes: 32 additions & 0 deletions Include/Acidanthera/Library/OcAcpiLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ typedef struct {
//
CONST UINT8 *ReplaceMask;
//
// Fully qualified name with ACPI path (e.g. \_SB_.PCI0.GFX0).
//
CONST CHAR8 *Base;
//
// Number of Base entries to skip before using.
//
UINT32 BaseSkip;
//
// Patch size.
//
UINT32 Size;
Expand Down Expand Up @@ -304,4 +312,28 @@ AcpiDumpTables (
IN EFI_FILE_PROTOCOL *Root
);

/**
Finds offset of required entry in ACPI table in case it exists.
@param[in] Table Pointer to start of ACPI table.
@param[in] PathString Path to entry which must be found.
@param[in] Entry Number of entry which must be found.
@param[out] Offset Offset of the entry if it was found.
@param[out] TableLength Length of ACPI table.
@retval EFI_SUCCESS Required entry was found.
@retval EFI_NOT_FOUND Required entry was not found.
@retval EFI_DEVICE_ERROR Error occured during parsing ACPI table.
@retval EFI_OUT_OF_RESOURCES Nesting limit has been reached.
@retval EFI_INVALID_PARAMETER Got wrong path to the entry.
**/
EFI_STATUS
AcpiFindEntryInMemory (
IN UINT8 *Table,
IN CONST CHAR8 *PathString,
IN UINT8 Entry,
OUT UINT32 *Offset,
IN UINT32 TableLength OPTIONAL
);

#endif // OC_ACPI_LIB_H
2 changes: 2 additions & 0 deletions Include/Acidanthera/Library/OcConfigurationLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
_(BOOLEAN , Enabled , , FALSE , () ) \
_(OC_STRING , Comment , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \
_(OC_DATA , Find , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \
_(OC_STRING , Base , , OC_STRING_CONSTR ("", _, __), OC_DESTR (OC_STRING) ) \
_(UINT32 , BaseSkip , , 0 , () ) \
_(UINT32 , Limit , , 0 , () ) \
_(OC_DATA , Mask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \
_(OC_DATA , Replace , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \
Expand Down
Loading

2 comments on commit 5880ec2

@1alessandro1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember from this issue acidanthera/bugtracker#453 (comment) that TgtBridge was a requested feature, is this functionality implemented since 5880ec2 ?

@vit9696
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ours is better though of course (:

Please sign in to comment.