2 ACPI Sdt Protocol Driver
4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. <BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include "AcpiTable.h"
14 GLOBAL_REMOVE_IF_UNREFERENCED
15 EFI_ACPI_SDT_PROTOCOL mAcpiSdtProtocolTemplate
= {
16 EFI_ACPI_TABLE_VERSION_NONE
,
29 This function returns ACPI Table instance.
31 @return AcpiTableInstance
33 EFI_ACPI_TABLE_INSTANCE
*
34 SdtGetAcpiTableInstance (
42 This function finds the table specified by the buffer.
44 @param[in] Buffer Table buffer to find.
46 @return ACPI table list.
53 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
54 LIST_ENTRY
*CurrentLink
;
55 EFI_ACPI_TABLE_LIST
*CurrentTableList
;
56 LIST_ENTRY
*StartLink
;
59 // Get the instance of the ACPI Table
61 AcpiTableInstance
= SdtGetAcpiTableInstance ();
66 StartLink
= &AcpiTableInstance
->TableList
;
67 CurrentLink
= StartLink
->ForwardLink
;
69 while (CurrentLink
!= StartLink
) {
70 CurrentTableList
= EFI_ACPI_TABLE_LIST_FROM_LINK (CurrentLink
);
71 if (((UINTN
)CurrentTableList
->PageAddress
<= (UINTN
)Buffer
) &&
72 ((UINTN
)CurrentTableList
->PageAddress
+ EFI_PAGES_TO_SIZE(CurrentTableList
->NumberOfPages
) > (UINTN
)Buffer
)) {
76 return CurrentTableList
;
79 CurrentLink
= CurrentLink
->ForwardLink
;
86 This function updates AML table checksum.
87 It will search the ACPI table installed by ACPI_TABLE protocol.
89 @param[in] Buffer A piece of AML code buffer pointer.
91 @retval EFI_SUCCESS The table holds the AML buffer is found, and checksum is updated.
92 @retval EFI_NOT_FOUND The table holds the AML buffer is not found.
95 SdtUpdateAmlChecksum (
99 EFI_ACPI_TABLE_LIST
*CurrentTableList
;
101 CurrentTableList
= FindTableByBuffer (Buffer
);
102 if (CurrentTableList
== NULL
) {
103 return EFI_NOT_FOUND
;
106 AcpiPlatformChecksum (
107 (VOID
*)CurrentTableList
->Table
,
108 CurrentTableList
->Table
->Length
,
109 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
, Checksum
)
115 This function finds MAX AML buffer size.
116 It will search the ACPI table installed by ACPI_TABLE protocol.
118 @param[in] Buffer A piece of AML code buffer pointer.
119 @param[out] MaxSize On return it holds the MAX size of buffer.
121 @retval EFI_SUCCESS The table holds the AML buffer is found, and MAX size if returned.
122 @retval EFI_NOT_FOUND The table holds the AML buffer is not found.
125 SdtGetMaxAmlBufferSize (
130 EFI_ACPI_TABLE_LIST
*CurrentTableList
;
132 CurrentTableList
= FindTableByBuffer (Buffer
);
133 if (CurrentTableList
== NULL
) {
134 return EFI_NOT_FOUND
;
137 *MaxSize
= (UINTN
)CurrentTableList
->Table
+ CurrentTableList
->Table
->Length
- (UINTN
)Buffer
;
142 This function invokes ACPI notification.
144 @param[in] AcpiTableInstance Instance to AcpiTable
145 @param[in] Version Version(s) to set.
146 @param[in] Handle Handle of the table.
150 IN EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
,
151 IN EFI_ACPI_TABLE_VERSION Version
,
155 EFI_ACPI_NOTIFY_LIST
*CurrentNotifyList
;
156 LIST_ENTRY
*CurrentLink
;
157 LIST_ENTRY
*StartLink
;
158 EFI_ACPI_TABLE_LIST
*Table
;
162 // We should not use Table buffer, because it is user input buffer.
164 Status
= FindTableByHandle (
166 &AcpiTableInstance
->TableList
,
169 ASSERT_EFI_ERROR (Status
);
174 StartLink
= &AcpiTableInstance
->NotifyList
;
175 CurrentLink
= StartLink
->ForwardLink
;
177 while (CurrentLink
!= StartLink
) {
178 CurrentNotifyList
= EFI_ACPI_NOTIFY_LIST_FROM_LINK (CurrentLink
);
181 // Inovke notification
183 CurrentNotifyList
->Notification ((EFI_ACPI_SDT_HEADER
*)Table
->Table
, Version
, Handle
);
185 CurrentLink
= CurrentLink
->ForwardLink
;
192 Returns a requested ACPI table.
194 The GetAcpiTable() function returns a pointer to a buffer containing the ACPI table associated
195 with the Index that was input. The following structures are not considered elements in the list of
197 - Root System Description Pointer (RSD_PTR)
198 - Root System Description Table (RSDT)
199 - Extended System Description Table (XSDT)
200 Version is updated with a bit map containing all the versions of ACPI of which the table is a
201 member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,
202 the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.
204 @param[in] Index The zero-based index of the table to retrieve.
205 @param[out] Table Pointer for returning the table buffer.
206 @param[out] Version On return, updated with the ACPI versions to which this table belongs. Type
207 EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
208 EFI_ACPI_SDT_PROTOCOL.
209 @param[out] TableKey On return, points to the table key for the specified ACPI system definition table.
210 This is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
211 The TableKey can be passed to EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
212 to uninstall the table.
213 @retval EFI_SUCCESS The function completed successfully.
214 @retval EFI_NOT_FOUND The requested index is too large and a table was not found.
220 OUT EFI_ACPI_SDT_HEADER
**Table
,
221 OUT EFI_ACPI_TABLE_VERSION
*Version
,
225 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
227 LIST_ENTRY
*CurrentLink
;
228 LIST_ENTRY
*StartLink
;
229 EFI_ACPI_TABLE_LIST
*CurrentTable
;
231 ASSERT (Table
!= NULL
);
232 ASSERT (Version
!= NULL
);
233 ASSERT (TableKey
!= NULL
);
236 // Get the instance of the ACPI Table
238 AcpiTableInstance
= SdtGetAcpiTableInstance ();
243 StartLink
= &AcpiTableInstance
->TableList
;
244 CurrentLink
= StartLink
->ForwardLink
;
247 while (CurrentLink
!= StartLink
) {
248 if (TableIndex
== Index
) {
254 CurrentLink
= CurrentLink
->ForwardLink
;
258 if ((TableIndex
!= Index
) || (CurrentLink
== StartLink
)) {
259 return EFI_NOT_FOUND
;
263 // Get handle and version
265 CurrentTable
= EFI_ACPI_TABLE_LIST_FROM_LINK (CurrentLink
);
266 *TableKey
= CurrentTable
->Handle
;
267 *Version
= CurrentTable
->Version
;
268 *Table
= (EFI_ACPI_SDT_HEADER
*)CurrentTable
->Table
;
274 Register a callback when an ACPI table is installed.
276 This function registers a function which will be called whenever a new ACPI table is installed.
278 @param[in] Notification Points to the callback function to be registered
282 IN EFI_ACPI_NOTIFICATION_FN Notification
285 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
286 EFI_ACPI_NOTIFY_LIST
*CurrentNotifyList
;
289 // Get the instance of the ACPI Table
291 AcpiTableInstance
= SdtGetAcpiTableInstance ();
294 // Create a new list entry
296 CurrentNotifyList
= AllocatePool (sizeof (EFI_ACPI_NOTIFY_LIST
));
297 ASSERT (CurrentNotifyList
!= NULL
);
300 // Initialize the table contents
302 CurrentNotifyList
->Signature
= EFI_ACPI_NOTIFY_LIST_SIGNATURE
;
303 CurrentNotifyList
->Notification
= Notification
;
306 // Add the table to the current list of tables
308 InsertTailList (&AcpiTableInstance
->NotifyList
, &CurrentNotifyList
->Link
);
314 Unregister a callback when an ACPI table is installed.
316 This function unregisters a function which will be called whenever a new ACPI table is installed.
318 @param[in] Notification Points to the callback function to be unregistered.
320 @retval EFI_SUCCESS Callback successfully unregistered.
321 @retval EFI_INVALID_PARAMETER Notification does not match a known registration function.
324 SdtUnregisterNotify (
325 IN EFI_ACPI_NOTIFICATION_FN Notification
328 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
329 EFI_ACPI_NOTIFY_LIST
*CurrentNotifyList
;
330 LIST_ENTRY
*CurrentLink
;
331 LIST_ENTRY
*StartLink
;
334 // Get the instance of the ACPI Table
336 AcpiTableInstance
= SdtGetAcpiTableInstance ();
341 StartLink
= &AcpiTableInstance
->NotifyList
;
342 CurrentLink
= StartLink
->ForwardLink
;
344 while (CurrentLink
!= StartLink
) {
345 CurrentNotifyList
= EFI_ACPI_NOTIFY_LIST_FROM_LINK (CurrentLink
);
346 if (CurrentNotifyList
->Notification
== Notification
) {
348 // Good! Found notification.
350 // Remove it from list and free the node.
352 RemoveEntryList (&(CurrentNotifyList
->Link
));
353 FreePool (CurrentNotifyList
);
357 CurrentLink
= CurrentLink
->ForwardLink
;
363 return EFI_INVALID_PARAMETER
;
367 Register or unregister a callback when an ACPI table is installed.
369 This function registers or unregisters a function which will be called whenever a new ACPI table is
372 @param[in] Register If TRUE, then the specified function will be registered. If FALSE, then the specified
373 function will be unregistered.
374 @param[in] Notification Points to the callback function to be registered or unregistered.
376 @retval EFI_SUCCESS Callback successfully registered or unregistered.
377 @retval EFI_INVALID_PARAMETER Notification is NULL
378 @retval EFI_INVALID_PARAMETER Register is FALSE and Notification does not match a known registration function.
384 IN EFI_ACPI_NOTIFICATION_FN Notification
388 // Check for invalid input parameters
390 if (Notification
== NULL
) {
391 return EFI_INVALID_PARAMETER
;
396 // Register a new notify
398 SdtRegisterNotify (Notification
);
402 // Unregister an old notify
404 return SdtUnregisterNotify (Notification
);
409 Create a handle for the first ACPI opcode in an ACPI system description table.
411 @param[in] TableKey The table key for the ACPI table, as returned by GetTable().
412 @param[out] Handle On return, points to the newly created ACPI handle.
414 @retval EFI_SUCCESS Handle created successfully.
415 @retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
420 OUT EFI_ACPI_HANDLE
*Handle
423 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
425 EFI_ACPI_TABLE_LIST
*Table
;
426 EFI_AML_HANDLE
*AmlHandle
;
429 // Get the instance of the ACPI Table
431 AcpiTableInstance
= SdtGetAcpiTableInstance ();
436 Status
= FindTableByHandle (
438 &AcpiTableInstance
->TableList
,
441 if (EFI_ERROR (Status
)) {
442 return EFI_NOT_FOUND
;
445 AmlHandle
= AllocatePool (sizeof(*AmlHandle
));
446 ASSERT (AmlHandle
!= NULL
);
447 AmlHandle
->Signature
= EFI_AML_ROOT_HANDLE_SIGNATURE
;
448 AmlHandle
->Buffer
= (VOID
*)((UINTN
)Table
->Table
+ sizeof(EFI_ACPI_SDT_HEADER
));
449 AmlHandle
->Size
= Table
->Table
->Length
- sizeof(EFI_ACPI_SDT_HEADER
);
450 AmlHandle
->AmlByteEncoding
= NULL
;
451 AmlHandle
->Modified
= FALSE
;
454 // return the ACPI handle
456 *Handle
= (EFI_ACPI_HANDLE
)AmlHandle
;
462 Create a handle for the first ACPI opcode in an ACPI system description table.
464 @param[in] TableKey The table key for the ACPI table, as returned by GetTable().
465 @param[out] Handle On return, points to the newly created ACPI handle.
467 @retval EFI_SUCCESS Handle created successfully.
468 @retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
474 OUT EFI_ACPI_HANDLE
*Handle
477 if (Handle
== NULL
) {
478 return EFI_INVALID_PARAMETER
;
481 return SdtOpenSdtTable (TableKey
, Handle
);
485 Create a handle from an ACPI opcode
487 @param[in] Buffer Points to the ACPI opcode.
488 @param[in] BufferSize Max buffer size.
489 @param[out] Handle Upon return, holds the handle.
491 @retval EFI_SUCCESS Success
492 @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
500 OUT EFI_ACPI_HANDLE
*Handle
503 AML_BYTE_ENCODING
*AmlByteEncoding
;
504 EFI_AML_HANDLE
*AmlHandle
;
506 AmlByteEncoding
= AmlSearchByOpByte (Buffer
);
507 if (AmlByteEncoding
== NULL
) {
508 return EFI_INVALID_PARAMETER
;
512 // Do not open NameString as handle
514 if ((AmlByteEncoding
->Attribute
& AML_IS_NAME_CHAR
) != 0) {
515 return EFI_INVALID_PARAMETER
;
521 AmlHandle
= AllocatePool (sizeof(*AmlHandle
));
522 ASSERT (AmlHandle
!= NULL
);
524 AmlHandle
->Signature
= EFI_AML_HANDLE_SIGNATURE
;
525 AmlHandle
->Buffer
= Buffer
;
526 AmlHandle
->AmlByteEncoding
= AmlByteEncoding
;
527 AmlHandle
->Modified
= FALSE
;
529 AmlHandle
->Size
= AmlGetObjectSize (AmlByteEncoding
, Buffer
, BufferSize
);
530 if (AmlHandle
->Size
== 0) {
531 FreePool (AmlHandle
);
532 return EFI_INVALID_PARAMETER
;
535 *Handle
= (EFI_ACPI_HANDLE
)AmlHandle
;
541 Create a handle from an ACPI opcode
543 @param[in] Buffer Points to the ACPI opcode.
544 @param[out] Handle Upon return, holds the handle.
546 @retval EFI_SUCCESS Success
547 @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
555 OUT EFI_ACPI_HANDLE
*Handle
564 // Check for invalid input parameters
566 if (Buffer
== NULL
|| Handle
== NULL
) {
567 return EFI_INVALID_PARAMETER
;
570 Status
= SdtGetMaxAmlBufferSize (Buffer
, &MaxSize
);
571 if (EFI_ERROR (Status
)) {
572 return EFI_INVALID_PARAMETER
;
575 return SdtOpenEx (Buffer
, MaxSize
, Handle
);
579 Close an ACPI handle.
581 @param[in] Handle Returns the handle.
583 @retval EFI_SUCCESS Success
584 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
589 IN EFI_ACPI_HANDLE Handle
592 EFI_AML_HANDLE
*AmlHandle
;
596 // Check for invalid input parameters
598 if (Handle
== NULL
) {
599 return EFI_INVALID_PARAMETER
;
602 AmlHandle
= (EFI_AML_HANDLE
*)Handle
;
603 if ((AmlHandle
->Signature
!= EFI_AML_ROOT_HANDLE_SIGNATURE
) &&
604 (AmlHandle
->Signature
!= EFI_AML_HANDLE_SIGNATURE
)) {
605 return EFI_INVALID_PARAMETER
;
609 // Update Checksum only if modified
611 if (AmlHandle
->Modified
) {
612 Status
= SdtUpdateAmlChecksum (AmlHandle
->Buffer
);
613 if (EFI_ERROR (Status
)) {
614 return EFI_INVALID_PARAMETER
;
618 FreePool (AmlHandle
);
624 Retrieve information about an ACPI object.
626 @param[in] Handle ACPI object handle.
627 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
628 in the ACPI encoding, with index 0 always being the ACPI opcode.
629 @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
630 for the specified index.
631 @param[out] Data Upon return, points to the pointer to the data.
632 @param[out] DataSize Upon return, points to the size of Data.
634 @retval EFI_SUCCESS Success.
635 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
640 IN EFI_ACPI_HANDLE Handle
,
642 OUT EFI_ACPI_DATA_TYPE
*DataType
,
643 OUT CONST VOID
**Data
,
647 EFI_AML_HANDLE
*AmlHandle
;
648 AML_BYTE_ENCODING
*AmlByteEncoding
;
651 ASSERT (DataType
!= NULL
);
652 ASSERT (Data
!= NULL
);
653 ASSERT (DataSize
!= NULL
);
656 // Check for invalid input parameters
658 if (Handle
== NULL
) {
659 return EFI_INVALID_PARAMETER
;
662 AmlHandle
= (EFI_AML_HANDLE
*)Handle
;
664 // Do not check EFI_AML_ROOT_HANDLE_SIGNATURE because there is no option for Root handle
666 if (AmlHandle
->Signature
!= EFI_AML_HANDLE_SIGNATURE
) {
667 return EFI_INVALID_PARAMETER
;
670 AmlByteEncoding
= AmlHandle
->AmlByteEncoding
;
671 if (Index
> AmlByteEncoding
->MaxIndex
) {
672 *DataType
= EFI_ACPI_DATA_TYPE_NONE
;
679 Status
= AmlParseOptionHandleCommon (AmlHandle
, (AML_OP_PARSE_INDEX
)Index
, DataType
, (VOID
**)Data
, DataSize
);
680 if (EFI_ERROR (Status
)) {
681 return EFI_INVALID_PARAMETER
;
688 Change information about an ACPI object.
690 @param[in] Handle ACPI object handle.
691 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
692 in the ACPI encoding, with index 0 always being the ACPI opcode.
693 @param[in] Data Points to the data.
694 @param[in] DataSize The size of the Data.
696 @retval EFI_SUCCESS Success
697 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
698 @retval EFI_BAD_BUFFER_SIZE Data cannot be accommodated in the space occupied by
705 IN EFI_ACPI_HANDLE Handle
,
711 EFI_AML_HANDLE
*AmlHandle
;
712 AML_BYTE_ENCODING
*AmlByteEncoding
;
714 EFI_ACPI_DATA_TYPE DataType
;
718 ASSERT (Data
!= NULL
);
721 // Check for invalid input parameters
723 if (Handle
== NULL
) {
724 return EFI_INVALID_PARAMETER
;
727 AmlHandle
= (EFI_AML_HANDLE
*)Handle
;
729 // Do not check EFI_AML_ROOT_HANDLE_SIGNATURE because there is no option for Root handle
731 if (AmlHandle
->Signature
!= EFI_AML_HANDLE_SIGNATURE
) {
732 return EFI_INVALID_PARAMETER
;
734 AmlByteEncoding
= AmlHandle
->AmlByteEncoding
;
736 if (Index
> AmlByteEncoding
->MaxIndex
) {
737 return EFI_INVALID_PARAMETER
;
743 Status
= AmlParseOptionHandleCommon (AmlHandle
, (AML_OP_PARSE_INDEX
)Index
, &DataType
, &OrgData
, &OrgDataSize
);
744 if (EFI_ERROR (Status
)) {
745 return EFI_INVALID_PARAMETER
;
747 if (DataType
== EFI_ACPI_DATA_TYPE_NONE
) {
748 return EFI_INVALID_PARAMETER
;
751 if (DataSize
> OrgDataSize
) {
752 return EFI_BAD_BUFFER_SIZE
;
758 CopyMem (OrgData
, Data
, DataSize
);
759 AmlHandle
->Modified
= TRUE
;
765 Return the child ACPI objects.
767 @param[in] ParentHandle Parent handle.
768 @param[in, out] Handle On entry, points to the previously returned handle or NULL to start with the first
769 handle. On return, points to the next returned ACPI handle or NULL if there are no
772 @retval EFI_SUCCESS Success
773 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
778 IN EFI_ACPI_HANDLE ParentHandle
,
779 IN OUT EFI_ACPI_HANDLE
*Handle
782 EFI_AML_HANDLE
*AmlParentHandle
;
783 EFI_AML_HANDLE
*AmlHandle
;
787 ASSERT (Handle
!= NULL
);
790 // Check for invalid input parameters
792 if (ParentHandle
== NULL
) {
793 return EFI_INVALID_PARAMETER
;
797 if ((AmlHandle
!= NULL
) && (AmlHandle
->Signature
!= EFI_AML_HANDLE_SIGNATURE
)) {
798 return EFI_INVALID_PARAMETER
;
801 AmlParentHandle
= (EFI_AML_HANDLE
*)ParentHandle
;
802 if (AmlParentHandle
->Signature
== EFI_AML_ROOT_HANDLE_SIGNATURE
) {
806 Status
= AmlGetChildFromRoot (AmlParentHandle
, AmlHandle
, &Buffer
);
807 } else if (AmlParentHandle
->Signature
== EFI_AML_HANDLE_SIGNATURE
) {
811 Status
= AmlGetChildFromNonRoot (AmlParentHandle
, AmlHandle
, &Buffer
);
816 return EFI_INVALID_PARAMETER
;
819 if (EFI_ERROR (Status
)) {
820 return EFI_INVALID_PARAMETER
;
822 if (Buffer
== NULL
) {
826 return SdtOpenEx (Buffer
, (UINTN
)AmlParentHandle
->Buffer
+ AmlParentHandle
->Size
- (UINTN
)Buffer
, Handle
);
830 Returns the handle of the ACPI object representing the specified ACPI path
832 @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
833 @param[in] AmlPath Points to the AML path.
834 @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
837 @retval EFI_SUCCESS Success
838 @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
841 SdtFindPathFromNonRoot (
842 IN EFI_ACPI_HANDLE HandleIn
,
844 OUT EFI_ACPI_HANDLE
*HandleOut
847 EFI_AML_HANDLE
*AmlHandle
;
852 AmlHandle
= (EFI_AML_HANDLE
*)HandleIn
;
855 // For non-root handle, we need search from THIS node instead of ROOT.
857 Status
= AmlFindPath (AmlHandle
, AmlPath
, &Buffer
, FALSE
);
858 if (EFI_ERROR (Status
)) {
859 return EFI_INVALID_PARAMETER
;
861 if (Buffer
== NULL
) {
865 return SdtOpenEx (Buffer
, (UINTN
)AmlHandle
->Buffer
+ AmlHandle
->Size
- (UINTN
)Buffer
, HandleOut
);
869 Duplicate AML handle.
871 @param[in] AmlHandle Handle to be duplicated.
873 @return Duplicated AML handle.
877 IN EFI_AML_HANDLE
*AmlHandle
880 EFI_AML_HANDLE
*DstAmlHandle
;
882 DstAmlHandle
= AllocatePool (sizeof(*DstAmlHandle
));
883 ASSERT (DstAmlHandle
!= NULL
);
884 CopyMem (DstAmlHandle
, (VOID
*)AmlHandle
, sizeof(*DstAmlHandle
));
890 Returns the handle of the ACPI object representing the specified ACPI path
892 @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
893 @param[in] AmlPath Points to the AML path.
894 @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
897 @retval EFI_SUCCESS Success
898 @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
901 SdtFindPathFromRoot (
902 IN EFI_ACPI_HANDLE HandleIn
,
904 OUT EFI_ACPI_HANDLE
*HandleOut
907 EFI_ACPI_HANDLE ChildHandle
;
908 EFI_AML_HANDLE
*AmlHandle
;
913 AmlHandle
= (EFI_AML_HANDLE
*)HandleIn
;
916 // Handle case that AcpiPath is Root
918 if (AmlIsRootPath (AmlPath
)) {
920 // Duplicate RootHandle
922 *HandleOut
= (EFI_ACPI_HANDLE
)SdtDuplicateHandle (AmlHandle
);
927 // Let children find it.
931 Status
= GetChild (HandleIn
, &ChildHandle
);
932 if (EFI_ERROR (Status
)) {
933 return EFI_INVALID_PARAMETER
;
936 if (ChildHandle
== NULL
) {
947 AmlHandle
= (EFI_AML_HANDLE
*)ChildHandle
;
948 Status
= AmlFindPath (AmlHandle
, AmlPath
, &Buffer
, TRUE
);
949 if (EFI_ERROR (Status
)) {
950 return EFI_INVALID_PARAMETER
;
953 if (Buffer
!= NULL
) {
955 // Great! Find it, open
957 Status
= SdtOpenEx (Buffer
, (UINTN
)AmlHandle
->Buffer
+ AmlHandle
->Size
- (UINTN
)Buffer
, HandleOut
);
958 if (!EFI_ERROR (Status
)) {
962 // Not success, try next one
968 // Should not run here
973 Returns the handle of the ACPI object representing the specified ACPI path
975 @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
976 @param[in] AcpiPath Points to the ACPI path, which conforms to the ACPI encoded path format.
977 @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
980 @retval EFI_SUCCESS Success
981 @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
986 IN EFI_ACPI_HANDLE HandleIn
,
988 OUT EFI_ACPI_HANDLE
*HandleOut
991 EFI_AML_HANDLE
*AmlHandle
;
996 // Check for invalid input parameters
998 if (HandleIn
== NULL
) {
999 return EFI_INVALID_PARAMETER
;
1002 AmlHandle
= (EFI_AML_HANDLE
*)HandleIn
;
1005 // Convert ASL path to AML path
1007 AmlPath
= AmlNameFromAslName (AcpiPath
);
1008 if (AmlPath
== NULL
) {
1009 return EFI_INVALID_PARAMETER
;
1012 DEBUG_CODE_BEGIN ();
1013 DEBUG ((EFI_D_ERROR
, "AcpiSdt: FindPath - "));
1014 AmlPrintNameString (AmlPath
);
1015 DEBUG ((EFI_D_ERROR
, "\n"));
1018 if (AmlHandle
->Signature
== EFI_AML_ROOT_HANDLE_SIGNATURE
) {
1022 Status
= SdtFindPathFromRoot (HandleIn
, AmlPath
, HandleOut
);
1023 } else if (AmlHandle
->Signature
== EFI_AML_HANDLE_SIGNATURE
) {
1027 Status
= SdtFindPathFromNonRoot (HandleIn
, AmlPath
, HandleOut
);
1029 Status
= EFI_INVALID_PARAMETER
;
1038 This function initializes AcpiSdt protocol in ACPI table instance.
1040 @param[in] AcpiTableInstance Instance to construct
1043 SdtAcpiTableAcpiSdtConstructor (
1044 IN EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
1048 InitializeListHead (&AcpiTableInstance
->NotifyList
);
1049 CopyMem (&AcpiTableInstance
->AcpiSdtProtocol
, &mAcpiSdtProtocolTemplate
, sizeof(mAcpiSdtProtocolTemplate
));
1050 AcpiTableInstance
->AcpiSdtProtocol
.AcpiVersion
= (EFI_ACPI_TABLE_VERSION
)PcdGet32 (PcdAcpiExposedTableVersions
);