2 ACPI Sdt Protocol Driver
4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 // Privacy data structure
23 // ACPI Notify Linked List Signature.
25 #define EFI_ACPI_NOTIFY_LIST_SIGNATURE SIGNATURE_32 ('E', 'A', 'N', 'L')
28 // ACPI Notify List Entry definition.
30 // Signature must be set to EFI_ACPI_NOTIFY_LIST_SIGNATURE
31 // Link is the linked list data.
32 // Notification is the callback function.
37 EFI_ACPI_NOTIFICATION_FN Notification
;
38 } EFI_ACPI_NOTIFY_LIST
;
41 // Containment record for ACPI Notify linked list.
43 #define EFI_ACPI_NOTIFY_LIST_FROM_LINK(_link) CR (_link, EFI_ACPI_NOTIFY_LIST, Link, EFI_ACPI_NOTIFY_LIST_SIGNATURE)
45 typedef struct _AML_BYTE_ENCODING AML_BYTE_ENCODING
;
46 typedef struct _EFI_AML_NODE_LIST EFI_AML_NODE_LIST
;
49 // AML Node Linked List Signature.
51 #define EFI_AML_NODE_LIST_SIGNATURE SIGNATURE_32 ('E', 'A', 'M', 'L')
54 // AML Node Linked List Entry definition.
56 // Signature must be set to EFI_AML_NODE_LIST_SIGNATURE
57 // Link is the linked list data.
58 // Name is the ACPI node name.
59 // This is listed for PATH finding.
60 // Buffer is the ACPI node buffer pointer, the first/second bytes are opcode.
61 // This buffer should not be freed.
62 // Size is the total size of this ACPI node buffer.
63 // Children is the children linked list of this node.
65 #define AML_NAME_SEG_SIZE 4
67 struct _EFI_AML_NODE_LIST
{
69 UINT8 Name
[AML_NAME_SEG_SIZE
];
74 EFI_AML_NODE_LIST
*Parent
;
75 AML_BYTE_ENCODING
*AmlByteEncoding
;
79 // Containment record for AML Node linked list.
81 #define EFI_AML_NODE_LIST_FROM_LINK(_link) CR (_link, EFI_AML_NODE_LIST, Link, EFI_AML_NODE_LIST_SIGNATURE)
84 // AML Handle Signature.
86 #define EFI_AML_HANDLE_SIGNATURE SIGNATURE_32 ('E', 'A', 'H', 'S')
87 #define EFI_AML_ROOT_HANDLE_SIGNATURE SIGNATURE_32 ('E', 'A', 'R', 'H')
90 // AML Handle Entry definition.
92 // Signature must be set to EFI_AML_HANDLE_SIGNATURE or EFI_AML_ROOT_HANDLE_SIGNATURE
93 // Buffer is the ACPI node buffer pointer, the first/second bytes are opcode.
94 // This buffer should not be freed.
95 // Size is the total size of this ACPI node buffer.
101 AML_BYTE_ENCODING
*AmlByteEncoding
;
105 typedef UINT32 AML_OP_PARSE_INDEX
;
107 #define AML_OP_PARSE_INDEX_GET_OPCODE 0
108 #define AML_OP_PARSE_INDEX_GET_TERM1 1
109 #define AML_OP_PARSE_INDEX_GET_TERM2 2
110 #define AML_OP_PARSE_INDEX_GET_TERM3 3
111 #define AML_OP_PARSE_INDEX_GET_TERM4 4
112 #define AML_OP_PARSE_INDEX_GET_TERM5 5
113 #define AML_OP_PARSE_INDEX_GET_TERM6 6
114 #define AML_OP_PARSE_INDEX_GET_SIZE (AML_OP_PARSE_INDEX)-1
116 typedef UINT32 AML_OP_PARSE_FORMAT
;
127 typedef UINT32 AML_OP_ATTRIBUTE
;
128 #define AML_HAS_PKG_LENGTH 0x1 // It is ACPI attribute - if OpCode has PkgLength
129 #define AML_IS_NAME_CHAR 0x2 // It is ACPI attribute - if this is NameChar
130 #define AML_HAS_CHILD_OBJ 0x4 // it is ACPI attribute - if OpCode has Child Object.
131 #define AML_IN_NAMESPACE 0x10000 // It is UEFI SDT attribute - if OpCode will be in NameSpace
132 // NOTE; Not all OBJECT will be in NameSpace
133 // For example, BankField | CreateBitField | CreateByteField | CreateDWordField |
134 // CreateField | CreateQWordField | CreateWordField | Field | IndexField.
136 struct _AML_BYTE_ENCODING
{
139 AML_OP_PARSE_INDEX MaxIndex
;
140 AML_OP_PARSE_FORMAT Format
[6];
141 AML_OP_ATTRIBUTE Attribute
;
145 // AcpiSdt protocol declaration
149 Returns a requested ACPI table.
151 The GetAcpiTable() function returns a pointer to a buffer containing the ACPI table associated
152 with the Index that was input. The following structures are not considered elements in the list of
154 - Root System Description Pointer (RSD_PTR)
155 - Root System Description Table (RSDT)
156 - Extended System Description Table (XSDT)
157 Version is updated with a bit map containing all the versions of ACPI of which the table is a
158 member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,
159 the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.
161 @param[in] Index The zero-based index of the table to retrieve.
162 @param[out] Table Pointer for returning the table buffer.
163 @param[out] Version On return, updated with the ACPI versions to which this table belongs. Type
164 EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
165 EFI_ACPI_SDT_PROTOCOL.
166 @param[out] TableKey On return, points to the table key for the specified ACPI system definition table.
167 This is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
168 The TableKey can be passed to EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
169 to uninstall the table.
171 @retval EFI_SUCCESS The function completed successfully.
172 @retval EFI_NOT_FOUND The requested index is too large and a table was not found.
178 OUT EFI_ACPI_SDT_HEADER
**Table
,
179 OUT EFI_ACPI_TABLE_VERSION
*Version
,
184 Register or unregister a callback when an ACPI table is installed.
186 This function registers or unregisters a function which will be called whenever a new ACPI table is
189 @param[in] Register If TRUE, then the specified function will be registered. If FALSE, then the specified
190 function will be unregistered.
191 @param[in] Notification Points to the callback function to be registered or unregistered.
193 @retval EFI_SUCCESS Callback successfully registered or unregistered.
194 @retval EFI_INVALID_PARAMETER Notification is NULL
195 @retval EFI_INVALID_PARAMETER Register is FALSE and Notification does not match a known registration function.
201 IN EFI_ACPI_NOTIFICATION_FN Notification
205 Create a handle for the first ACPI opcode in an ACPI system description table.
207 @param[in] TableKey The table key for the ACPI table, as returned by GetTable().
208 @param[out] Handle On return, points to the newly created ACPI handle.
210 @retval EFI_SUCCESS Handle created successfully.
211 @retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
217 OUT EFI_ACPI_HANDLE
*Handle
221 Create a handle from an ACPI opcode
223 @param[in] Buffer Points to the ACPI opcode.
224 @param[out] Handle Upon return, holds the handle.
226 @retval EFI_SUCCESS Success
227 @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
235 OUT EFI_ACPI_HANDLE
*Handle
239 Close an ACPI handle.
241 @param[in] Handle Returns the handle.
243 @retval EFI_SUCCESS Success
244 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
249 IN EFI_ACPI_HANDLE Handle
253 Retrieve information about an ACPI object.
255 @param[in] Handle ACPI object handle.
256 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
257 in the ACPI encoding, with index 0 always being the ACPI opcode.
258 @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
259 for the specified index.
260 @param[out] Data Upon return, points to the pointer to the data.
261 @param[out] DataSize Upon return, points to the size of Data.
263 @retval EFI_SUCCESS Success.
264 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
269 IN EFI_ACPI_HANDLE Handle
,
271 OUT EFI_ACPI_DATA_TYPE
*DataType
,
272 OUT CONST VOID
**Data
,
277 Change information about an ACPI object.
279 @param[in] Handle ACPI object handle.
280 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
281 in the ACPI encoding, with index 0 always being the ACPI opcode.
282 @param[in] Data Points to the data.
283 @param[in] DataSize The size of the Data.
285 @retval EFI_SUCCESS Success
286 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
287 @retval EFI_BAD_BUFFER_SIZE Data cannot be accommodated in the space occupied by
294 IN EFI_ACPI_HANDLE Handle
,
301 Return the child ACPI objects.
303 @param[in] ParentHandle Parent handle.
304 @param[in, out] Handle On entry, points to the previously returned handle or NULL to start with the first
305 handle. On return, points to the next returned ACPI handle or NULL if there are no
308 @retval EFI_SUCCESS Success
309 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
314 IN EFI_ACPI_HANDLE ParentHandle
,
315 IN OUT EFI_ACPI_HANDLE
*Handle
319 Returns the handle of the ACPI object representing the specified ACPI path
321 @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
322 @param[in] AcpiPath Points to the ACPI path, which conforms to the ACPI encoded path format.
323 @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
326 @retval EFI_SUCCESS Success
327 @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
332 IN EFI_ACPI_HANDLE HandleIn
,
334 OUT EFI_ACPI_HANDLE
*HandleOut
342 Create a handle from an ACPI opcode
344 @param[in] Buffer Points to the ACPI opcode.
345 @param[in] BufferSize Max buffer size.
346 @param[out] Handle Upon return, holds the handle.
348 @retval EFI_SUCCESS Success
349 @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
357 OUT EFI_ACPI_HANDLE
*Handle
361 // AML support function
365 Get AML NameString size.
367 @param[in] Buffer AML NameString.
368 @param[out] BufferSize AML NameString size
370 @retval EFI_SUCCESS Success.
371 @retval EFI_INVALID_PARAMETER Buffer does not refer to a valid AML NameString.
374 AmlGetNameStringSize (
376 OUT UINTN
*BufferSize
380 This function retuns package length from the buffer.
382 @param[in] Buffer AML buffer
383 @param[out] PkgLength The total length of package.
385 @return The byte data count to present the package length.
394 This function returns AcpiDataType according to AmlType.
396 @param[in] AmlType AML Type.
402 IN AML_OP_PARSE_FORMAT AmlType
406 This function returns AmlByteEncoding according to OpCode Byte.
408 @param[in] OpByteBuffer OpCode byte buffer.
410 @return AmlByteEncoding
414 IN UINT8
*OpByteBuffer
420 @param[in] AmlByteEncoding AML Byte Encoding.
421 @param[in] Buffer AML object buffer.
422 @param[in] MaxBufferSize AML object buffer MAX size. The parser can not parse any data exceed this region.
424 @return Size of the object.
428 IN AML_BYTE_ENCODING
*AmlByteEncoding
,
430 IN UINTN MaxBufferSize
436 @param[in] AmlHandle AML handle.
438 @return Name of the object.
442 IN EFI_AML_HANDLE
*AmlHandle
446 Retrieve information according to AmlHandle
448 @param[in] AmlHandle AML handle.
449 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
450 in the ACPI encoding, with index 0 always being the ACPI opcode.
451 @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
452 for the specified index.
453 @param[out] Data Upon return, points to the pointer to the data.
454 @param[out] DataSize Upon return, points to the size of Data.
456 @retval EFI_SUCCESS Success.
457 @retval EFI_INVALID_PARAMETER AmlHandle does not refer to a valid ACPI object.
460 AmlParseOptionHandleCommon (
461 IN EFI_AML_HANDLE
*AmlHandle
,
462 IN AML_OP_PARSE_INDEX Index
,
463 OUT EFI_ACPI_DATA_TYPE
*DataType
,
469 Return offset of last option.
471 @param[in] AmlHandle AML Handle.
472 @param[out] Buffer Upon return, points to the offset after last option.
474 @retval EFI_SUCCESS Success.
475 @retval EFI_INVALID_PARAMETER AmlHandle does not refer to a valid ACPI object.
478 AmlGetOffsetAfterLastOption (
479 IN EFI_AML_HANDLE
*AmlHandle
,
484 Return the child ACPI objects from Root Handle.
486 @param[in] AmlParentHandle Parent handle. It is Root Handle.
487 @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
488 @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
491 @retval EFI_SUCCESS Success
492 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
495 AmlGetChildFromRoot (
496 IN EFI_AML_HANDLE
*AmlParentHandle
,
497 IN EFI_AML_HANDLE
*AmlHandle
,
502 Return the child ACPI objects from Non-Root Handle.
504 @param[in] AmlParentHandle Parent handle. It is Non-Root Handle.
505 @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
506 @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
509 @retval EFI_SUCCESS Success
510 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
513 AmlGetChildFromNonRoot (
514 IN EFI_AML_HANDLE
*AmlParentHandle
,
515 IN EFI_AML_HANDLE
*AmlHandle
,
520 Return AML name according to ASL name.
521 The caller need free the AmlName returned.
523 @param[in] AslPath ASL name.
533 Returns the handle of the ACPI object representing the specified ACPI AML path
535 @param[in] AmlHandle Points to the handle of the object representing the starting point for the path search.
536 @param[in] AmlPath Points to the ACPI AML path.
537 @param[out] Buffer On return, points to the ACPI object which represents AcpiPath, relative to
539 @param[in] FromRoot TRUE means to find AML path from \ (Root) Node.
540 FALSE means to find AML path from this Node (The HandleIn).
542 @retval EFI_SUCCESS Success
543 @retval EFI_INVALID_PARAMETER HandleIn does not refer to a valid ACPI object.
547 IN EFI_AML_HANDLE
*AmlHandle
,
554 Print AML NameString.
556 @param[in] Buffer AML NameString.
566 @param[in] Buffer AML NameSeg.
574 Check if it is AML Root name
576 @param[in] Buffer AML path.
578 @retval TRUE AML path is root.
579 @retval FALSE AML path is not root.