2 ACPI Sdt Protocol Driver
4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. <BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
13 // Privacy data structure
17 // ACPI Notify Linked List Signature.
19 #define EFI_ACPI_NOTIFY_LIST_SIGNATURE SIGNATURE_32 ('E', 'A', 'N', 'L')
22 // ACPI Notify List Entry definition.
24 // Signature must be set to EFI_ACPI_NOTIFY_LIST_SIGNATURE
25 // Link is the linked list data.
26 // Notification is the callback function.
31 EFI_ACPI_NOTIFICATION_FN Notification
;
32 } EFI_ACPI_NOTIFY_LIST
;
35 // Containment record for ACPI Notify linked list.
37 #define EFI_ACPI_NOTIFY_LIST_FROM_LINK(_link) CR (_link, EFI_ACPI_NOTIFY_LIST, Link, EFI_ACPI_NOTIFY_LIST_SIGNATURE)
39 typedef struct _AML_BYTE_ENCODING AML_BYTE_ENCODING
;
40 typedef struct _EFI_AML_NODE_LIST EFI_AML_NODE_LIST
;
43 // AML Node Linked List Signature.
45 #define EFI_AML_NODE_LIST_SIGNATURE SIGNATURE_32 ('E', 'A', 'M', 'L')
48 // AML Node Linked List Entry definition.
50 // Signature must be set to EFI_AML_NODE_LIST_SIGNATURE
51 // Link is the linked list data.
52 // Name is the ACPI node name.
53 // This is listed for PATH finding.
54 // Buffer is the ACPI node buffer pointer, the first/second bytes are opcode.
55 // This buffer should not be freed.
56 // Size is the total size of this ACPI node buffer.
57 // Children is the children linked list of this node.
59 #define AML_NAME_SEG_SIZE 4
61 struct _EFI_AML_NODE_LIST
{
63 UINT8 Name
[AML_NAME_SEG_SIZE
];
68 EFI_AML_NODE_LIST
*Parent
;
69 AML_BYTE_ENCODING
*AmlByteEncoding
;
73 // Containment record for AML Node linked list.
75 #define EFI_AML_NODE_LIST_FROM_LINK(_link) CR (_link, EFI_AML_NODE_LIST, Link, EFI_AML_NODE_LIST_SIGNATURE)
78 // AML Handle Signature.
80 #define EFI_AML_HANDLE_SIGNATURE SIGNATURE_32 ('E', 'A', 'H', 'S')
81 #define EFI_AML_ROOT_HANDLE_SIGNATURE SIGNATURE_32 ('E', 'A', 'R', 'H')
84 // AML Handle Entry definition.
86 // Signature must be set to EFI_AML_HANDLE_SIGNATURE or EFI_AML_ROOT_HANDLE_SIGNATURE
87 // Buffer is the ACPI node buffer pointer, the first/second bytes are opcode.
88 // This buffer should not be freed.
89 // Size is the total size of this ACPI node buffer.
95 AML_BYTE_ENCODING
*AmlByteEncoding
;
99 typedef UINT32 AML_OP_PARSE_INDEX
;
101 #define AML_OP_PARSE_INDEX_GET_OPCODE 0
102 #define AML_OP_PARSE_INDEX_GET_TERM1 1
103 #define AML_OP_PARSE_INDEX_GET_TERM2 2
104 #define AML_OP_PARSE_INDEX_GET_TERM3 3
105 #define AML_OP_PARSE_INDEX_GET_TERM4 4
106 #define AML_OP_PARSE_INDEX_GET_TERM5 5
107 #define AML_OP_PARSE_INDEX_GET_TERM6 6
108 #define AML_OP_PARSE_INDEX_GET_SIZE (AML_OP_PARSE_INDEX)-1
110 typedef UINT32 AML_OP_PARSE_FORMAT
;
121 typedef UINT32 AML_OP_ATTRIBUTE
;
122 #define AML_HAS_PKG_LENGTH 0x1 // It is ACPI attribute - if OpCode has PkgLength
123 #define AML_IS_NAME_CHAR 0x2 // It is ACPI attribute - if this is NameChar
124 #define AML_HAS_CHILD_OBJ 0x4 // it is ACPI attribute - if OpCode has Child Object.
125 #define AML_IN_NAMESPACE 0x10000 // It is UEFI SDT attribute - if OpCode will be in NameSpace
126 // NOTE; Not all OBJECT will be in NameSpace
127 // For example, BankField | CreateBitField | CreateByteField | CreateDWordField |
128 // CreateField | CreateQWordField | CreateWordField | Field | IndexField.
130 struct _AML_BYTE_ENCODING
{
133 AML_OP_PARSE_INDEX MaxIndex
;
134 AML_OP_PARSE_FORMAT Format
[6];
135 AML_OP_ATTRIBUTE Attribute
;
139 // AcpiSdt protocol declaration
143 Returns a requested ACPI table.
145 The GetAcpiTable() function returns a pointer to a buffer containing the ACPI table associated
146 with the Index that was input. The following structures are not considered elements in the list of
148 - Root System Description Pointer (RSD_PTR)
149 - Root System Description Table (RSDT)
150 - Extended System Description Table (XSDT)
151 Version is updated with a bit map containing all the versions of ACPI of which the table is a
152 member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,
153 the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.
155 @param[in] Index The zero-based index of the table to retrieve.
156 @param[out] Table Pointer for returning the table buffer.
157 @param[out] Version On return, updated with the ACPI versions to which this table belongs. Type
158 EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
159 EFI_ACPI_SDT_PROTOCOL.
160 @param[out] TableKey On return, points to the table key for the specified ACPI system definition table.
161 This is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
162 The TableKey can be passed to EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
163 to uninstall the table.
165 @retval EFI_SUCCESS The function completed successfully.
166 @retval EFI_NOT_FOUND The requested index is too large and a table was not found.
172 OUT EFI_ACPI_SDT_HEADER
**Table
,
173 OUT EFI_ACPI_TABLE_VERSION
*Version
,
178 Register or unregister a callback when an ACPI table is installed.
180 This function registers or unregisters a function which will be called whenever a new ACPI table is
183 @param[in] Register If TRUE, then the specified function will be registered. If FALSE, then the specified
184 function will be unregistered.
185 @param[in] Notification Points to the callback function to be registered or unregistered.
187 @retval EFI_SUCCESS Callback successfully registered or unregistered.
188 @retval EFI_INVALID_PARAMETER Notification is NULL
189 @retval EFI_INVALID_PARAMETER Register is FALSE and Notification does not match a known registration function.
195 IN EFI_ACPI_NOTIFICATION_FN Notification
199 Create a handle for the first ACPI opcode in an ACPI system description table.
201 @param[in] TableKey The table key for the ACPI table, as returned by GetTable().
202 @param[out] Handle On return, points to the newly created ACPI handle.
204 @retval EFI_SUCCESS Handle created successfully.
205 @retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
211 OUT EFI_ACPI_HANDLE
*Handle
215 Create a handle from an ACPI opcode
217 @param[in] Buffer Points to the ACPI opcode.
218 @param[out] Handle Upon return, holds the handle.
220 @retval EFI_SUCCESS Success
221 @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
229 OUT EFI_ACPI_HANDLE
*Handle
233 Close an ACPI handle.
235 @param[in] Handle Returns the handle.
237 @retval EFI_SUCCESS Success
238 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
243 IN EFI_ACPI_HANDLE Handle
247 Retrieve information about an ACPI object.
249 @param[in] Handle ACPI object handle.
250 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
251 in the ACPI encoding, with index 0 always being the ACPI opcode.
252 @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
253 for the specified index.
254 @param[out] Data Upon return, points to the pointer to the data.
255 @param[out] DataSize Upon return, points to the size of Data.
257 @retval EFI_SUCCESS Success.
258 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
263 IN EFI_ACPI_HANDLE Handle
,
265 OUT EFI_ACPI_DATA_TYPE
*DataType
,
266 OUT CONST VOID
**Data
,
271 Change information about an ACPI object.
273 @param[in] Handle ACPI object handle.
274 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
275 in the ACPI encoding, with index 0 always being the ACPI opcode.
276 @param[in] Data Points to the data.
277 @param[in] DataSize The size of the Data.
279 @retval EFI_SUCCESS Success
280 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
281 @retval EFI_BAD_BUFFER_SIZE Data cannot be accommodated in the space occupied by
288 IN EFI_ACPI_HANDLE Handle
,
295 Return the child ACPI objects.
297 @param[in] ParentHandle Parent handle.
298 @param[in, out] Handle On entry, points to the previously returned handle or NULL to start with the first
299 handle. On return, points to the next returned ACPI handle or NULL if there are no
302 @retval EFI_SUCCESS Success
303 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
308 IN EFI_ACPI_HANDLE ParentHandle
,
309 IN OUT EFI_ACPI_HANDLE
*Handle
313 Returns the handle of the ACPI object representing the specified ACPI path
315 @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
316 @param[in] AcpiPath Points to the ACPI path, which conforms to the ACPI encoded path format.
317 @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
320 @retval EFI_SUCCESS Success
321 @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
326 IN EFI_ACPI_HANDLE HandleIn
,
328 OUT EFI_ACPI_HANDLE
*HandleOut
336 Create a handle from an ACPI opcode
338 @param[in] Buffer Points to the ACPI opcode.
339 @param[in] BufferSize Max buffer size.
340 @param[out] Handle Upon return, holds the handle.
342 @retval EFI_SUCCESS Success
343 @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
351 OUT EFI_ACPI_HANDLE
*Handle
355 // AML support function
359 Get AML NameString size.
361 @param[in] Buffer AML NameString.
362 @param[out] BufferSize AML NameString size
364 @retval EFI_SUCCESS Success.
365 @retval EFI_INVALID_PARAMETER Buffer does not refer to a valid AML NameString.
368 AmlGetNameStringSize (
370 OUT UINTN
*BufferSize
374 This function retuns package length from the buffer.
376 @param[in] Buffer AML buffer
377 @param[out] PkgLength The total length of package.
379 @return The byte data count to present the package length.
388 This function returns AcpiDataType according to AmlType.
390 @param[in] AmlType AML Type.
396 IN AML_OP_PARSE_FORMAT AmlType
400 This function returns AmlByteEncoding according to OpCode Byte.
402 @param[in] OpByteBuffer OpCode byte buffer.
404 @return AmlByteEncoding
408 IN UINT8
*OpByteBuffer
414 @param[in] AmlByteEncoding AML Byte Encoding.
415 @param[in] Buffer AML object buffer.
416 @param[in] MaxBufferSize AML object buffer MAX size. The parser can not parse any data exceed this region.
418 @return Size of the object.
422 IN AML_BYTE_ENCODING
*AmlByteEncoding
,
424 IN UINTN MaxBufferSize
430 @param[in] AmlHandle AML handle.
432 @return Name of the object.
436 IN EFI_AML_HANDLE
*AmlHandle
440 Retrieve information according to AmlHandle
442 @param[in] AmlHandle AML handle.
443 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
444 in the ACPI encoding, with index 0 always being the ACPI opcode.
445 @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
446 for the specified index.
447 @param[out] Data Upon return, points to the pointer to the data.
448 @param[out] DataSize Upon return, points to the size of Data.
450 @retval EFI_SUCCESS Success.
451 @retval EFI_INVALID_PARAMETER AmlHandle does not refer to a valid ACPI object.
454 AmlParseOptionHandleCommon (
455 IN EFI_AML_HANDLE
*AmlHandle
,
456 IN AML_OP_PARSE_INDEX Index
,
457 OUT EFI_ACPI_DATA_TYPE
*DataType
,
463 Return offset of last option.
465 @param[in] AmlHandle AML Handle.
466 @param[out] Buffer Upon return, points to the offset after last option.
468 @retval EFI_SUCCESS Success.
469 @retval EFI_INVALID_PARAMETER AmlHandle does not refer to a valid ACPI object.
472 AmlGetOffsetAfterLastOption (
473 IN EFI_AML_HANDLE
*AmlHandle
,
478 Return the child ACPI objects from Root Handle.
480 @param[in] AmlParentHandle Parent handle. It is Root Handle.
481 @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
482 @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
485 @retval EFI_SUCCESS Success
486 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
489 AmlGetChildFromRoot (
490 IN EFI_AML_HANDLE
*AmlParentHandle
,
491 IN EFI_AML_HANDLE
*AmlHandle
,
496 Return the child ACPI objects from Non-Root Handle.
498 @param[in] AmlParentHandle Parent handle. It is Non-Root Handle.
499 @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
500 @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
503 @retval EFI_SUCCESS Success
504 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
507 AmlGetChildFromNonRoot (
508 IN EFI_AML_HANDLE
*AmlParentHandle
,
509 IN EFI_AML_HANDLE
*AmlHandle
,
514 Return AML name according to ASL name.
515 The caller need free the AmlName returned.
517 @param[in] AslPath ASL name.
527 Returns the handle of the ACPI object representing the specified ACPI AML path
529 @param[in] AmlHandle Points to the handle of the object representing the starting point for the path search.
530 @param[in] AmlPath Points to the ACPI AML path.
531 @param[out] Buffer On return, points to the ACPI object which represents AcpiPath, relative to
533 @param[in] FromRoot TRUE means to find AML path from \ (Root) Node.
534 FALSE means to find AML path from this Node (The HandleIn).
536 @retval EFI_SUCCESS Success
537 @retval EFI_INVALID_PARAMETER HandleIn does not refer to a valid ACPI object.
541 IN EFI_AML_HANDLE
*AmlHandle
,
548 Print AML NameString.
550 @param[in] Buffer AML NameString.
560 @param[in] Buffer AML NameSeg.
568 Check if it is AML Root name
570 @param[in] Buffer AML path.
572 @retval TRUE AML path is root.
573 @retval FALSE AML path is not root.