2 ACPI Sdt Protocol Driver
4 Copyright (c) 2010 - 2016, 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.
18 #include "AcpiTable.h"
20 GLOBAL_REMOVE_IF_UNREFERENCED
21 EFI_ACPI_SDT_PROTOCOL mAcpiSdtProtocolTemplate
= {
22 EFI_ACPI_TABLE_VERSION_NONE
,
35 This function returns ACPI Table instance.
37 @return AcpiTableInstance
39 EFI_ACPI_TABLE_INSTANCE
*
40 SdtGetAcpiTableInstance (
48 This function finds the table specified by the buffer.
50 @param[in] Buffer Table buffer to find.
52 @return ACPI table list.
59 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
60 LIST_ENTRY
*CurrentLink
;
61 EFI_ACPI_TABLE_LIST
*CurrentTableList
;
62 LIST_ENTRY
*StartLink
;
65 // Get the instance of the ACPI Table
67 AcpiTableInstance
= SdtGetAcpiTableInstance ();
72 StartLink
= &AcpiTableInstance
->TableList
;
73 CurrentLink
= StartLink
->ForwardLink
;
75 while (CurrentLink
!= StartLink
) {
76 CurrentTableList
= EFI_ACPI_TABLE_LIST_FROM_LINK (CurrentLink
);
77 if (((UINTN
)CurrentTableList
->PageAddress
<= (UINTN
)Buffer
) &&
78 ((UINTN
)CurrentTableList
->PageAddress
+ EFI_PAGES_TO_SIZE(CurrentTableList
->NumberOfPages
) > (UINTN
)Buffer
)) {
82 return CurrentTableList
;
85 CurrentLink
= CurrentLink
->ForwardLink
;
92 This function updates AML table checksum.
93 It will search the ACPI table installed by ACPI_TABLE protocol.
95 @param[in] Buffer A piece of AML code buffer pointer.
97 @retval EFI_SUCCESS The table holds the AML buffer is found, and checksum is updated.
98 @retval EFI_NOT_FOUND The table holds the AML buffer is not found.
101 SdtUpdateAmlChecksum (
105 EFI_ACPI_TABLE_LIST
*CurrentTableList
;
107 CurrentTableList
= FindTableByBuffer (Buffer
);
108 if (CurrentTableList
== NULL
) {
109 return EFI_NOT_FOUND
;
112 AcpiPlatformChecksum (
113 (VOID
*)CurrentTableList
->Table
,
114 CurrentTableList
->Table
->Length
,
115 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
, Checksum
)
121 This function finds MAX AML buffer size.
122 It will search the ACPI table installed by ACPI_TABLE protocol.
124 @param[in] Buffer A piece of AML code buffer pointer.
125 @param[out] MaxSize On return it holds the MAX size of buffer.
127 @retval EFI_SUCCESS The table holds the AML buffer is found, and MAX size if returned.
128 @retval EFI_NOT_FOUND The table holds the AML buffer is not found.
131 SdtGetMaxAmlBufferSize (
136 EFI_ACPI_TABLE_LIST
*CurrentTableList
;
138 CurrentTableList
= FindTableByBuffer (Buffer
);
139 if (CurrentTableList
== NULL
) {
140 return EFI_NOT_FOUND
;
143 *MaxSize
= (UINTN
)CurrentTableList
->Table
+ CurrentTableList
->Table
->Length
- (UINTN
)Buffer
;
148 This function invokes ACPI notification.
150 @param[in] AcpiTableInstance Instance to AcpiTable
151 @param[in] Version Version(s) to set.
152 @param[in] Handle Handle of the table.
156 IN EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
,
157 IN EFI_ACPI_TABLE_VERSION Version
,
161 EFI_ACPI_NOTIFY_LIST
*CurrentNotifyList
;
162 LIST_ENTRY
*CurrentLink
;
163 LIST_ENTRY
*StartLink
;
164 EFI_ACPI_TABLE_LIST
*Table
;
168 // We should not use Table buffer, because it is user input buffer.
170 Status
= FindTableByHandle (
172 &AcpiTableInstance
->TableList
,
175 ASSERT_EFI_ERROR (Status
);
180 StartLink
= &AcpiTableInstance
->NotifyList
;
181 CurrentLink
= StartLink
->ForwardLink
;
183 while (CurrentLink
!= StartLink
) {
184 CurrentNotifyList
= EFI_ACPI_NOTIFY_LIST_FROM_LINK (CurrentLink
);
187 // Inovke notification
189 CurrentNotifyList
->Notification ((EFI_ACPI_SDT_HEADER
*)Table
->Table
, Version
, Handle
);
191 CurrentLink
= CurrentLink
->ForwardLink
;
198 Returns a requested ACPI table.
200 The GetAcpiTable() function returns a pointer to a buffer containing the ACPI table associated
201 with the Index that was input. The following structures are not considered elements in the list of
203 - Root System Description Pointer (RSD_PTR)
204 - Root System Description Table (RSDT)
205 - Extended System Description Table (XSDT)
206 Version is updated with a bit map containing all the versions of ACPI of which the table is a
207 member. For tables installed via the EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable() interface,
208 the function returns the value of EFI_ACPI_STD_PROTOCOL.AcpiVersion.
210 @param[in] Index The zero-based index of the table to retrieve.
211 @param[out] Table Pointer for returning the table buffer.
212 @param[out] Version On return, updated with the ACPI versions to which this table belongs. Type
213 EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
214 EFI_ACPI_SDT_PROTOCOL.
215 @param[out] TableKey On return, points to the table key for the specified ACPI system definition table.
216 This is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
217 The TableKey can be passed to EFI_ACPI_TABLE_PROTOCOL.UninstallAcpiTable()
218 to uninstall the table.
219 @retval EFI_SUCCESS The function completed successfully.
220 @retval EFI_NOT_FOUND The requested index is too large and a table was not found.
226 OUT EFI_ACPI_SDT_HEADER
**Table
,
227 OUT EFI_ACPI_TABLE_VERSION
*Version
,
231 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
233 LIST_ENTRY
*CurrentLink
;
234 LIST_ENTRY
*StartLink
;
235 EFI_ACPI_TABLE_LIST
*CurrentTable
;
237 ASSERT (Table
!= NULL
);
238 ASSERT (Version
!= NULL
);
239 ASSERT (TableKey
!= NULL
);
242 // Get the instance of the ACPI Table
244 AcpiTableInstance
= SdtGetAcpiTableInstance ();
249 StartLink
= &AcpiTableInstance
->TableList
;
250 CurrentLink
= StartLink
->ForwardLink
;
253 while (CurrentLink
!= StartLink
) {
254 if (TableIndex
== Index
) {
260 CurrentLink
= CurrentLink
->ForwardLink
;
264 if ((TableIndex
!= Index
) || (CurrentLink
== StartLink
)) {
265 return EFI_NOT_FOUND
;
269 // Get handle and version
271 CurrentTable
= EFI_ACPI_TABLE_LIST_FROM_LINK (CurrentLink
);
272 *TableKey
= CurrentTable
->Handle
;
273 *Version
= CurrentTable
->Version
;
274 *Table
= (EFI_ACPI_SDT_HEADER
*)CurrentTable
->Table
;
280 Register a callback when an ACPI table is installed.
282 This function registers a function which will be called whenever a new ACPI table is installed.
284 @param[in] Notification Points to the callback function to be registered
288 IN EFI_ACPI_NOTIFICATION_FN Notification
291 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
292 EFI_ACPI_NOTIFY_LIST
*CurrentNotifyList
;
295 // Get the instance of the ACPI Table
297 AcpiTableInstance
= SdtGetAcpiTableInstance ();
300 // Create a new list entry
302 CurrentNotifyList
= AllocatePool (sizeof (EFI_ACPI_NOTIFY_LIST
));
303 ASSERT (CurrentNotifyList
!= NULL
);
306 // Initialize the table contents
308 CurrentNotifyList
->Signature
= EFI_ACPI_NOTIFY_LIST_SIGNATURE
;
309 CurrentNotifyList
->Notification
= Notification
;
312 // Add the table to the current list of tables
314 InsertTailList (&AcpiTableInstance
->NotifyList
, &CurrentNotifyList
->Link
);
320 Unregister a callback when an ACPI table is installed.
322 This function unregisters a function which will be called whenever a new ACPI table is installed.
324 @param[in] Notification Points to the callback function to be unregistered.
326 @retval EFI_SUCCESS Callback successfully unregistered.
327 @retval EFI_INVALID_PARAMETER Notification does not match a known registration function.
330 SdtUnregisterNotify (
331 IN EFI_ACPI_NOTIFICATION_FN Notification
334 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
335 EFI_ACPI_NOTIFY_LIST
*CurrentNotifyList
;
336 LIST_ENTRY
*CurrentLink
;
337 LIST_ENTRY
*StartLink
;
340 // Get the instance of the ACPI Table
342 AcpiTableInstance
= SdtGetAcpiTableInstance ();
347 StartLink
= &AcpiTableInstance
->NotifyList
;
348 CurrentLink
= StartLink
->ForwardLink
;
350 while (CurrentLink
!= StartLink
) {
351 CurrentNotifyList
= EFI_ACPI_NOTIFY_LIST_FROM_LINK (CurrentLink
);
352 if (CurrentNotifyList
->Notification
== Notification
) {
354 // Good! Found notification.
356 // Remove it from list and free the node.
358 RemoveEntryList (&(CurrentNotifyList
->Link
));
359 FreePool (CurrentNotifyList
);
363 CurrentLink
= CurrentLink
->ForwardLink
;
369 return EFI_INVALID_PARAMETER
;
373 Register or unregister a callback when an ACPI table is installed.
375 This function registers or unregisters a function which will be called whenever a new ACPI table is
378 @param[in] Register If TRUE, then the specified function will be registered. If FALSE, then the specified
379 function will be unregistered.
380 @param[in] Notification Points to the callback function to be registered or unregistered.
382 @retval EFI_SUCCESS Callback successfully registered or unregistered.
383 @retval EFI_INVALID_PARAMETER Notification is NULL
384 @retval EFI_INVALID_PARAMETER Register is FALSE and Notification does not match a known registration function.
390 IN EFI_ACPI_NOTIFICATION_FN Notification
394 // Check for invalid input parameters
396 if (Notification
== NULL
) {
397 return EFI_INVALID_PARAMETER
;
402 // Register a new notify
404 SdtRegisterNotify (Notification
);
408 // Unregister an old notify
410 return SdtUnregisterNotify (Notification
);
415 Create a handle for the first ACPI opcode in an ACPI system description table.
417 @param[in] TableKey The table key for the ACPI table, as returned by GetTable().
418 @param[out] Handle On return, points to the newly created ACPI handle.
420 @retval EFI_SUCCESS Handle created successfully.
421 @retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
426 OUT EFI_ACPI_HANDLE
*Handle
429 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
431 EFI_ACPI_TABLE_LIST
*Table
;
432 EFI_AML_HANDLE
*AmlHandle
;
435 // Get the instance of the ACPI Table
437 AcpiTableInstance
= SdtGetAcpiTableInstance ();
442 Status
= FindTableByHandle (
444 &AcpiTableInstance
->TableList
,
447 if (EFI_ERROR (Status
)) {
448 return EFI_NOT_FOUND
;
451 AmlHandle
= AllocatePool (sizeof(*AmlHandle
));
452 ASSERT (AmlHandle
!= NULL
);
453 AmlHandle
->Signature
= EFI_AML_ROOT_HANDLE_SIGNATURE
;
454 AmlHandle
->Buffer
= (VOID
*)((UINTN
)Table
->Table
+ sizeof(EFI_ACPI_SDT_HEADER
));
455 AmlHandle
->Size
= Table
->Table
->Length
- sizeof(EFI_ACPI_SDT_HEADER
);
456 AmlHandle
->AmlByteEncoding
= NULL
;
457 AmlHandle
->Modified
= FALSE
;
460 // return the ACPI handle
462 *Handle
= (EFI_ACPI_HANDLE
)AmlHandle
;
468 Create a handle for the first ACPI opcode in an ACPI system description table.
470 @param[in] TableKey The table key for the ACPI table, as returned by GetTable().
471 @param[out] Handle On return, points to the newly created ACPI handle.
473 @retval EFI_SUCCESS Handle created successfully.
474 @retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
480 OUT EFI_ACPI_HANDLE
*Handle
483 if (Handle
== NULL
) {
484 return EFI_INVALID_PARAMETER
;
487 return SdtOpenSdtTable (TableKey
, Handle
);
491 Create a handle from an ACPI opcode
493 @param[in] Buffer Points to the ACPI opcode.
494 @param[in] BufferSize Max buffer size.
495 @param[out] Handle Upon return, holds the handle.
497 @retval EFI_SUCCESS Success
498 @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
506 OUT EFI_ACPI_HANDLE
*Handle
509 AML_BYTE_ENCODING
*AmlByteEncoding
;
510 EFI_AML_HANDLE
*AmlHandle
;
512 AmlByteEncoding
= AmlSearchByOpByte (Buffer
);
513 if (AmlByteEncoding
== NULL
) {
514 return EFI_INVALID_PARAMETER
;
518 // Do not open NameString as handle
520 if ((AmlByteEncoding
->Attribute
& AML_IS_NAME_CHAR
) != 0) {
521 return EFI_INVALID_PARAMETER
;
527 AmlHandle
= AllocatePool (sizeof(*AmlHandle
));
528 ASSERT (AmlHandle
!= NULL
);
530 AmlHandle
->Signature
= EFI_AML_HANDLE_SIGNATURE
;
531 AmlHandle
->Buffer
= Buffer
;
532 AmlHandle
->AmlByteEncoding
= AmlByteEncoding
;
533 AmlHandle
->Modified
= FALSE
;
535 AmlHandle
->Size
= AmlGetObjectSize (AmlByteEncoding
, Buffer
, BufferSize
);
536 if (AmlHandle
->Size
== 0) {
537 FreePool (AmlHandle
);
538 return EFI_INVALID_PARAMETER
;
541 *Handle
= (EFI_ACPI_HANDLE
)AmlHandle
;
547 Create a handle from an ACPI opcode
549 @param[in] Buffer Points to the ACPI opcode.
550 @param[out] Handle Upon return, holds the handle.
552 @retval EFI_SUCCESS Success
553 @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
561 OUT EFI_ACPI_HANDLE
*Handle
570 // Check for invalid input parameters
572 if (Buffer
== NULL
|| Handle
== NULL
) {
573 return EFI_INVALID_PARAMETER
;
576 Status
= SdtGetMaxAmlBufferSize (Buffer
, &MaxSize
);
577 if (EFI_ERROR (Status
)) {
578 return EFI_INVALID_PARAMETER
;
581 return SdtOpenEx (Buffer
, MaxSize
, Handle
);
585 Close an ACPI handle.
587 @param[in] Handle Returns the handle.
589 @retval EFI_SUCCESS Success
590 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
595 IN EFI_ACPI_HANDLE Handle
598 EFI_AML_HANDLE
*AmlHandle
;
602 // Check for invalid input parameters
604 if (Handle
== NULL
) {
605 return EFI_INVALID_PARAMETER
;
608 AmlHandle
= (EFI_AML_HANDLE
*)Handle
;
609 if ((AmlHandle
->Signature
!= EFI_AML_ROOT_HANDLE_SIGNATURE
) &&
610 (AmlHandle
->Signature
!= EFI_AML_HANDLE_SIGNATURE
)) {
611 return EFI_INVALID_PARAMETER
;
615 // Update Checksum only if modified
617 if (AmlHandle
->Modified
) {
618 Status
= SdtUpdateAmlChecksum (AmlHandle
->Buffer
);
619 if (EFI_ERROR (Status
)) {
620 return EFI_INVALID_PARAMETER
;
624 FreePool (AmlHandle
);
630 Retrieve information about an ACPI object.
632 @param[in] Handle ACPI object handle.
633 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
634 in the ACPI encoding, with index 0 always being the ACPI opcode.
635 @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
636 for the specified index.
637 @param[out] Data Upon return, points to the pointer to the data.
638 @param[out] DataSize Upon return, points to the size of Data.
640 @retval EFI_SUCCESS Success.
641 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
646 IN EFI_ACPI_HANDLE Handle
,
648 OUT EFI_ACPI_DATA_TYPE
*DataType
,
649 OUT CONST VOID
**Data
,
653 EFI_AML_HANDLE
*AmlHandle
;
654 AML_BYTE_ENCODING
*AmlByteEncoding
;
657 ASSERT (DataType
!= NULL
);
658 ASSERT (Data
!= NULL
);
659 ASSERT (DataSize
!= NULL
);
662 // Check for invalid input parameters
664 if (Handle
== NULL
) {
665 return EFI_INVALID_PARAMETER
;
668 AmlHandle
= (EFI_AML_HANDLE
*)Handle
;
670 // Do not check EFI_AML_ROOT_HANDLE_SIGNATURE because there is no option for Root handle
672 if (AmlHandle
->Signature
!= EFI_AML_HANDLE_SIGNATURE
) {
673 return EFI_INVALID_PARAMETER
;
676 AmlByteEncoding
= AmlHandle
->AmlByteEncoding
;
677 if (Index
> AmlByteEncoding
->MaxIndex
) {
678 *DataType
= EFI_ACPI_DATA_TYPE_NONE
;
685 Status
= AmlParseOptionHandleCommon (AmlHandle
, (AML_OP_PARSE_INDEX
)Index
, DataType
, (VOID
**)Data
, DataSize
);
686 if (EFI_ERROR (Status
)) {
687 return EFI_INVALID_PARAMETER
;
694 Change information about an ACPI object.
696 @param[in] Handle ACPI object handle.
697 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
698 in the ACPI encoding, with index 0 always being the ACPI opcode.
699 @param[in] Data Points to the data.
700 @param[in] DataSize The size of the Data.
702 @retval EFI_SUCCESS Success
703 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
704 @retval EFI_BAD_BUFFER_SIZE Data cannot be accommodated in the space occupied by
711 IN EFI_ACPI_HANDLE Handle
,
717 EFI_AML_HANDLE
*AmlHandle
;
718 AML_BYTE_ENCODING
*AmlByteEncoding
;
720 EFI_ACPI_DATA_TYPE DataType
;
724 ASSERT (Data
!= NULL
);
727 // Check for invalid input parameters
729 if (Handle
== NULL
) {
730 return EFI_INVALID_PARAMETER
;
733 AmlHandle
= (EFI_AML_HANDLE
*)Handle
;
735 // Do not check EFI_AML_ROOT_HANDLE_SIGNATURE because there is no option for Root handle
737 if (AmlHandle
->Signature
!= EFI_AML_HANDLE_SIGNATURE
) {
738 return EFI_INVALID_PARAMETER
;
740 AmlByteEncoding
= AmlHandle
->AmlByteEncoding
;
742 if (Index
> AmlByteEncoding
->MaxIndex
) {
743 return EFI_INVALID_PARAMETER
;
749 Status
= AmlParseOptionHandleCommon (AmlHandle
, (AML_OP_PARSE_INDEX
)Index
, &DataType
, &OrgData
, &OrgDataSize
);
750 if (EFI_ERROR (Status
)) {
751 return EFI_INVALID_PARAMETER
;
753 if (DataType
== EFI_ACPI_DATA_TYPE_NONE
) {
754 return EFI_INVALID_PARAMETER
;
757 if (DataSize
> OrgDataSize
) {
758 return EFI_BAD_BUFFER_SIZE
;
764 CopyMem (OrgData
, Data
, DataSize
);
765 AmlHandle
->Modified
= TRUE
;
771 Return the child ACPI objects.
773 @param[in] ParentHandle Parent handle.
774 @param[in, out] Handle On entry, points to the previously returned handle or NULL to start with the first
775 handle. On return, points to the next returned ACPI handle or NULL if there are no
778 @retval EFI_SUCCESS Success
779 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
784 IN EFI_ACPI_HANDLE ParentHandle
,
785 IN OUT EFI_ACPI_HANDLE
*Handle
788 EFI_AML_HANDLE
*AmlParentHandle
;
789 EFI_AML_HANDLE
*AmlHandle
;
793 ASSERT (Handle
!= NULL
);
796 // Check for invalid input parameters
798 if (ParentHandle
== NULL
) {
799 return EFI_INVALID_PARAMETER
;
803 if ((AmlHandle
!= NULL
) && (AmlHandle
->Signature
!= EFI_AML_HANDLE_SIGNATURE
)) {
804 return EFI_INVALID_PARAMETER
;
807 AmlParentHandle
= (EFI_AML_HANDLE
*)ParentHandle
;
808 if (AmlParentHandle
->Signature
== EFI_AML_ROOT_HANDLE_SIGNATURE
) {
812 Status
= AmlGetChildFromRoot (AmlParentHandle
, AmlHandle
, &Buffer
);
813 } else if (AmlParentHandle
->Signature
== EFI_AML_HANDLE_SIGNATURE
) {
817 Status
= AmlGetChildFromNonRoot (AmlParentHandle
, AmlHandle
, &Buffer
);
822 return EFI_INVALID_PARAMETER
;
825 if (EFI_ERROR (Status
)) {
826 return EFI_INVALID_PARAMETER
;
828 if (Buffer
== NULL
) {
832 return SdtOpenEx (Buffer
, (UINTN
)AmlParentHandle
->Buffer
+ AmlParentHandle
->Size
- (UINTN
)Buffer
, Handle
);
836 Returns the handle of the ACPI object representing the specified ACPI path
838 @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
839 @param[in] AmlPath Points to the AML path.
840 @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
843 @retval EFI_SUCCESS Success
844 @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
847 SdtFindPathFromNonRoot (
848 IN EFI_ACPI_HANDLE HandleIn
,
850 OUT EFI_ACPI_HANDLE
*HandleOut
853 EFI_AML_HANDLE
*AmlHandle
;
858 AmlHandle
= (EFI_AML_HANDLE
*)HandleIn
;
861 // For non-root handle, we need search from THIS node instead of ROOT.
863 Status
= AmlFindPath (AmlHandle
, AmlPath
, &Buffer
, FALSE
);
864 if (EFI_ERROR (Status
)) {
865 return EFI_INVALID_PARAMETER
;
867 if (Buffer
== NULL
) {
871 return SdtOpenEx (Buffer
, (UINTN
)AmlHandle
->Buffer
+ AmlHandle
->Size
- (UINTN
)Buffer
, HandleOut
);
875 Duplicate AML handle.
877 @param[in] AmlHandle Handle to be duplicated.
879 @return Duplicated AML handle.
883 IN EFI_AML_HANDLE
*AmlHandle
886 EFI_AML_HANDLE
*DstAmlHandle
;
888 DstAmlHandle
= AllocatePool (sizeof(*DstAmlHandle
));
889 ASSERT (DstAmlHandle
!= NULL
);
890 CopyMem (DstAmlHandle
, (VOID
*)AmlHandle
, sizeof(*DstAmlHandle
));
896 Returns the handle of the ACPI object representing the specified ACPI path
898 @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
899 @param[in] AmlPath Points to the AML path.
900 @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
903 @retval EFI_SUCCESS Success
904 @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
907 SdtFindPathFromRoot (
908 IN EFI_ACPI_HANDLE HandleIn
,
910 OUT EFI_ACPI_HANDLE
*HandleOut
913 EFI_ACPI_HANDLE ChildHandle
;
914 EFI_AML_HANDLE
*AmlHandle
;
919 AmlHandle
= (EFI_AML_HANDLE
*)HandleIn
;
922 // Handle case that AcpiPath is Root
924 if (AmlIsRootPath (AmlPath
)) {
926 // Duplicate RootHandle
928 *HandleOut
= (EFI_ACPI_HANDLE
)SdtDuplicateHandle (AmlHandle
);
933 // Let children find it.
937 Status
= GetChild (HandleIn
, &ChildHandle
);
938 if (EFI_ERROR (Status
)) {
939 return EFI_INVALID_PARAMETER
;
942 if (ChildHandle
== NULL
) {
953 AmlHandle
= (EFI_AML_HANDLE
*)ChildHandle
;
954 Status
= AmlFindPath (AmlHandle
, AmlPath
, &Buffer
, TRUE
);
955 if (EFI_ERROR (Status
)) {
956 return EFI_INVALID_PARAMETER
;
959 if (Buffer
!= NULL
) {
961 // Great! Find it, open
963 Status
= SdtOpenEx (Buffer
, (UINTN
)AmlHandle
->Buffer
+ AmlHandle
->Size
- (UINTN
)Buffer
, HandleOut
);
964 if (!EFI_ERROR (Status
)) {
968 // Not success, try next one
974 // Should not run here
979 Returns the handle of the ACPI object representing the specified ACPI path
981 @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
982 @param[in] AcpiPath Points to the ACPI path, which conforms to the ACPI encoded path format.
983 @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
986 @retval EFI_SUCCESS Success
987 @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
992 IN EFI_ACPI_HANDLE HandleIn
,
994 OUT EFI_ACPI_HANDLE
*HandleOut
997 EFI_AML_HANDLE
*AmlHandle
;
1002 // Check for invalid input parameters
1004 if (HandleIn
== NULL
) {
1005 return EFI_INVALID_PARAMETER
;
1008 AmlHandle
= (EFI_AML_HANDLE
*)HandleIn
;
1011 // Convert ASL path to AML path
1013 AmlPath
= AmlNameFromAslName (AcpiPath
);
1014 if (AmlPath
== NULL
) {
1015 return EFI_INVALID_PARAMETER
;
1018 DEBUG_CODE_BEGIN ();
1019 DEBUG ((EFI_D_ERROR
, "AcpiSdt: FindPath - "));
1020 AmlPrintNameString (AmlPath
);
1021 DEBUG ((EFI_D_ERROR
, "\n"));
1024 if (AmlHandle
->Signature
== EFI_AML_ROOT_HANDLE_SIGNATURE
) {
1028 Status
= SdtFindPathFromRoot (HandleIn
, AmlPath
, HandleOut
);
1029 } else if (AmlHandle
->Signature
== EFI_AML_HANDLE_SIGNATURE
) {
1033 Status
= SdtFindPathFromNonRoot (HandleIn
, AmlPath
, HandleOut
);
1035 Status
= EFI_INVALID_PARAMETER
;
1044 This function initializes AcpiSdt protocol in ACPI table instance.
1046 @param[in] AcpiTableInstance Instance to construct
1049 SdtAcpiTableAcpiSdtConstructor (
1050 IN EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
1054 InitializeListHead (&AcpiTableInstance
->NotifyList
);
1055 CopyMem (&AcpiTableInstance
->AcpiSdtProtocol
, &mAcpiSdtProtocolTemplate
, sizeof(mAcpiSdtProtocolTemplate
));
1056 AcpiTableInstance
->AcpiSdtProtocol
.AcpiVersion
= (EFI_ACPI_TABLE_VERSION
)PcdGet32 (PcdAcpiExposedTableVersions
);