2 ACPI Sdt Protocol Driver
4 Copyright (c) 2010, 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
| EFI_ACPI_TABLE_VERSION_1_0B
| EFI_ACPI_TABLE_VERSION_2_0
| EFI_ACPI_TABLE_VERSION_3_0
| EFI_ACPI_TABLE_VERSION_4_0
,
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
209 @param[in] Index The zero-based index of the table to retrieve.
210 @param[out] Table Pointer for returning the table buffer.
211 @param[out] Version On return, updated with the ACPI versions to which this table belongs. Type
212 EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
213 EFI_ACPI_SDT_PROTOCOL.
214 @param[out] TableKey On return, points to the table key for the specified ACPI system definition table. This
215 is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
217 @retval EFI_SUCCESS The function completed successfully.
218 @retval EFI_NOT_FOUND The requested index is too large and a table was not found.
224 OUT EFI_ACPI_SDT_HEADER
**Table
,
225 OUT EFI_ACPI_TABLE_VERSION
*Version
,
229 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
231 LIST_ENTRY
*CurrentLink
;
232 LIST_ENTRY
*StartLink
;
233 EFI_ACPI_TABLE_LIST
*CurrentTable
;
235 ASSERT (Table
!= NULL
);
236 ASSERT (Version
!= NULL
);
237 ASSERT (TableKey
!= NULL
);
240 // Get the instance of the ACPI Table
242 AcpiTableInstance
= SdtGetAcpiTableInstance ();
247 StartLink
= &AcpiTableInstance
->TableList
;
248 CurrentLink
= StartLink
->ForwardLink
;
251 while (CurrentLink
!= StartLink
) {
252 if (TableIndex
== Index
) {
258 CurrentLink
= CurrentLink
->ForwardLink
;
262 if ((TableIndex
!= Index
) || (CurrentLink
== StartLink
)) {
263 return EFI_NOT_FOUND
;
267 // Get handle and version
269 CurrentTable
= EFI_ACPI_TABLE_LIST_FROM_LINK (CurrentLink
);
270 *TableKey
= CurrentTable
->Handle
;
271 *Version
= CurrentTable
->Version
;
272 *Table
= (EFI_ACPI_SDT_HEADER
*)CurrentTable
->Table
;
278 Register a callback when an ACPI table is installed.
280 This function registers a function which will be called whenever a new ACPI table is installed.
282 @param[in] Notification Points to the callback function to be registered
286 IN EFI_ACPI_NOTIFICATION_FN Notification
289 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
290 EFI_ACPI_NOTIFY_LIST
*CurrentNotifyList
;
293 // Get the instance of the ACPI Table
295 AcpiTableInstance
= SdtGetAcpiTableInstance ();
298 // Create a new list entry
300 CurrentNotifyList
= AllocatePool (sizeof (EFI_ACPI_NOTIFY_LIST
));
301 ASSERT (CurrentNotifyList
!= NULL
);
304 // Initialize the table contents
306 CurrentNotifyList
->Signature
= EFI_ACPI_NOTIFY_LIST_SIGNATURE
;
307 CurrentNotifyList
->Notification
= Notification
;
310 // Add the table to the current list of tables
312 InsertTailList (&AcpiTableInstance
->NotifyList
, &CurrentNotifyList
->Link
);
318 Unregister a callback when an ACPI table is installed.
320 This function unregisters a function which will be called whenever a new ACPI table is installed.
322 @param[in] Notification Points to the callback function to be unregistered.
324 @retval EFI_SUCCESS Callback successfully unregistered.
325 @retval EFI_INVALID_PARAMETER Notification does not match a known registration function.
328 SdtUnregisterNotify (
329 IN EFI_ACPI_NOTIFICATION_FN Notification
332 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
333 EFI_ACPI_NOTIFY_LIST
*CurrentNotifyList
;
334 LIST_ENTRY
*CurrentLink
;
335 LIST_ENTRY
*StartLink
;
338 // Get the instance of the ACPI Table
340 AcpiTableInstance
= SdtGetAcpiTableInstance ();
345 StartLink
= &AcpiTableInstance
->NotifyList
;
346 CurrentLink
= StartLink
->ForwardLink
;
348 while (CurrentLink
!= StartLink
) {
349 CurrentNotifyList
= EFI_ACPI_NOTIFY_LIST_FROM_LINK (CurrentLink
);
350 if (CurrentNotifyList
->Notification
== Notification
) {
352 // Good! Found notification.
354 // Remove it from list and free the node.
356 RemoveEntryList (&(CurrentNotifyList
->Link
));
357 FreePool (CurrentNotifyList
);
361 CurrentLink
= CurrentLink
->ForwardLink
;
367 return EFI_INVALID_PARAMETER
;
371 Register or unregister a callback when an ACPI table is installed.
373 This function registers or unregisters a function which will be called whenever a new ACPI table is
376 @param[in] Register If TRUE, then the specified function will be registered. If FALSE, then the specified
377 function will be unregistered.
378 @param[in] Notification Points to the callback function to be registered or unregistered.
380 @retval EFI_SUCCESS Callback successfully registered or unregistered.
381 @retval EFI_INVALID_PARAMETER Notification is NULL
382 @retval EFI_INVALID_PARAMETER Register is FALSE and Notification does not match a known registration function.
388 IN EFI_ACPI_NOTIFICATION_FN Notification
392 // Check for invalid input parameters
394 if (Notification
== NULL
) {
395 return EFI_INVALID_PARAMETER
;
400 // Register a new notify
402 SdtRegisterNotify (Notification
);
406 // Unregister an old notify
408 return SdtUnregisterNotify (Notification
);
413 Create a handle for the first ACPI opcode in an ACPI system description table.
415 @param[in] TableKey The table key for the ACPI table, as returned by GetTable().
416 @param[out] Handle On return, points to the newly created ACPI handle.
418 @retval EFI_SUCCESS Handle created successfully.
419 @retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
424 OUT EFI_ACPI_HANDLE
*Handle
427 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
429 EFI_ACPI_TABLE_LIST
*Table
;
430 EFI_AML_HANDLE
*AmlHandle
;
433 // Get the instance of the ACPI Table
435 AcpiTableInstance
= SdtGetAcpiTableInstance ();
440 Status
= FindTableByHandle (
442 &AcpiTableInstance
->TableList
,
445 if (EFI_ERROR (Status
)) {
446 return EFI_NOT_FOUND
;
449 AmlHandle
= AllocatePool (sizeof(*AmlHandle
));
450 ASSERT (AmlHandle
!= NULL
);
451 AmlHandle
->Signature
= EFI_AML_ROOT_HANDLE_SIGNATURE
;
452 AmlHandle
->Buffer
= (VOID
*)((UINTN
)Table
->Table
+ sizeof(EFI_ACPI_SDT_HEADER
));
453 AmlHandle
->Size
= Table
->Table
->Length
- sizeof(EFI_ACPI_SDT_HEADER
);
454 AmlHandle
->AmlByteEncoding
= NULL
;
455 AmlHandle
->Modified
= FALSE
;
458 // return the ACPI handle
460 *Handle
= (EFI_ACPI_HANDLE
)AmlHandle
;
466 Create a handle for the first ACPI opcode in an ACPI system description table.
468 @param[in] TableKey The table key for the ACPI table, as returned by GetTable().
469 @param[out] Handle On return, points to the newly created ACPI handle.
471 @retval EFI_SUCCESS Handle created successfully.
472 @retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
478 OUT EFI_ACPI_HANDLE
*Handle
481 if (Handle
== NULL
) {
482 return EFI_INVALID_PARAMETER
;
485 return SdtOpenSdtTable (TableKey
, Handle
);
489 Create a handle from an ACPI opcode
491 @param[in] Buffer Points to the ACPI opcode.
492 @param[in] BufferSize Max buffer size.
493 @param[out] Handle Upon return, holds the handle.
495 @retval EFI_SUCCESS Success
496 @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
504 OUT EFI_ACPI_HANDLE
*Handle
507 AML_BYTE_ENCODING
*AmlByteEncoding
;
508 EFI_AML_HANDLE
*AmlHandle
;
510 AmlByteEncoding
= AmlSearchByOpByte (Buffer
);
511 if (AmlByteEncoding
== NULL
) {
512 return EFI_INVALID_PARAMETER
;
516 // Do not open NameString as handle
518 if ((AmlByteEncoding
->Attribute
& AML_IS_NAME_CHAR
) != 0) {
519 return EFI_INVALID_PARAMETER
;
525 AmlHandle
= AllocatePool (sizeof(*AmlHandle
));
526 ASSERT (AmlHandle
!= NULL
);
528 AmlHandle
->Signature
= EFI_AML_HANDLE_SIGNATURE
;
529 AmlHandle
->Buffer
= Buffer
;
530 AmlHandle
->AmlByteEncoding
= AmlByteEncoding
;
531 AmlHandle
->Modified
= FALSE
;
533 AmlHandle
->Size
= AmlGetObjectSize (AmlByteEncoding
, Buffer
, BufferSize
);
534 if (AmlHandle
->Size
== 0) {
535 FreePool (AmlHandle
);
536 return EFI_INVALID_PARAMETER
;
539 *Handle
= (EFI_ACPI_HANDLE
)AmlHandle
;
545 Create a handle from an ACPI opcode
547 @param[in] Buffer Points to the ACPI opcode.
548 @param[out] Handle Upon return, holds the handle.
550 @retval EFI_SUCCESS Success
551 @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
559 OUT EFI_ACPI_HANDLE
*Handle
568 // Check for invalid input parameters
570 if (Buffer
== NULL
|| Handle
== NULL
) {
571 return EFI_INVALID_PARAMETER
;
574 Status
= SdtGetMaxAmlBufferSize (Buffer
, &MaxSize
);
575 if (EFI_ERROR (Status
)) {
576 return EFI_INVALID_PARAMETER
;
579 return SdtOpenEx (Buffer
, MaxSize
, Handle
);
583 Close an ACPI handle.
585 @param[in] Handle Returns the handle.
587 @retval EFI_SUCCESS Success
588 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
593 IN EFI_ACPI_HANDLE Handle
596 EFI_AML_HANDLE
*AmlHandle
;
600 // Check for invalid input parameters
602 if (Handle
== NULL
) {
603 return EFI_INVALID_PARAMETER
;
606 AmlHandle
= (EFI_AML_HANDLE
*)Handle
;
607 if ((AmlHandle
->Signature
!= EFI_AML_ROOT_HANDLE_SIGNATURE
) &&
608 (AmlHandle
->Signature
!= EFI_AML_HANDLE_SIGNATURE
)) {
609 return EFI_INVALID_PARAMETER
;
613 // Update Checksum only if modified
615 if (AmlHandle
->Modified
) {
616 Status
= SdtUpdateAmlChecksum (AmlHandle
->Buffer
);
617 if (EFI_ERROR (Status
)) {
618 return EFI_INVALID_PARAMETER
;
622 FreePool (AmlHandle
);
628 Retrieve information about an ACPI object.
630 @param[in] Handle ACPI object handle.
631 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
632 in the ACPI encoding, with index 0 always being the ACPI opcode.
633 @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
634 for the specified index.
635 @param[out] Data Upon return, points to the pointer to the data.
636 @param[out] DataSize Upon return, points to the size of Data.
638 @retval EFI_SUCCESS Success.
639 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
644 IN EFI_ACPI_HANDLE Handle
,
646 OUT EFI_ACPI_DATA_TYPE
*DataType
,
647 OUT CONST VOID
**Data
,
651 EFI_AML_HANDLE
*AmlHandle
;
652 AML_BYTE_ENCODING
*AmlByteEncoding
;
655 ASSERT (DataType
!= NULL
);
656 ASSERT (Data
!= NULL
);
657 ASSERT (DataSize
!= NULL
);
660 // Check for invalid input parameters
662 if (Handle
== NULL
) {
663 return EFI_INVALID_PARAMETER
;
666 AmlHandle
= (EFI_AML_HANDLE
*)Handle
;
668 // Do not check EFI_AML_ROOT_HANDLE_SIGNATURE because there is no option for Root handle
670 if (AmlHandle
->Signature
!= EFI_AML_HANDLE_SIGNATURE
) {
671 return EFI_INVALID_PARAMETER
;
674 AmlByteEncoding
= AmlHandle
->AmlByteEncoding
;
675 if (Index
> AmlByteEncoding
->MaxIndex
) {
676 *DataType
= EFI_ACPI_DATA_TYPE_NONE
;
683 Status
= AmlParseOptionHandleCommon (AmlHandle
, (AML_OP_PARSE_INDEX
)Index
, DataType
, (VOID
**)Data
, DataSize
);
684 if (EFI_ERROR (Status
)) {
685 return EFI_INVALID_PARAMETER
;
692 Change information about an ACPI object.
694 @param[in] Handle ACPI object handle.
695 @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
696 in the ACPI encoding, with index 0 always being the ACPI opcode.
697 @param[in] Data Points to the data.
698 @param[in] DataSize The size of the Data.
700 @retval EFI_SUCCESS Success
701 @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
702 @retval EFI_BAD_BUFFER_SIZE Data cannot be accommodated in the space occupied by
709 IN EFI_ACPI_HANDLE Handle
,
715 EFI_AML_HANDLE
*AmlHandle
;
716 AML_BYTE_ENCODING
*AmlByteEncoding
;
718 EFI_ACPI_DATA_TYPE DataType
;
722 ASSERT (Data
!= NULL
);
725 // Check for invalid input parameters
727 if (Handle
== NULL
) {
728 return EFI_INVALID_PARAMETER
;
731 AmlHandle
= (EFI_AML_HANDLE
*)Handle
;
733 // Do not check EFI_AML_ROOT_HANDLE_SIGNATURE because there is no option for Root handle
735 if (AmlHandle
->Signature
!= EFI_AML_HANDLE_SIGNATURE
) {
736 return EFI_INVALID_PARAMETER
;
738 AmlByteEncoding
= AmlHandle
->AmlByteEncoding
;
740 if (Index
> AmlByteEncoding
->MaxIndex
) {
741 return EFI_INVALID_PARAMETER
;
747 Status
= AmlParseOptionHandleCommon (AmlHandle
, (AML_OP_PARSE_INDEX
)Index
, &DataType
, &OrgData
, &OrgDataSize
);
748 if (EFI_ERROR (Status
)) {
749 return EFI_INVALID_PARAMETER
;
751 if (DataType
== EFI_ACPI_DATA_TYPE_NONE
) {
752 return EFI_INVALID_PARAMETER
;
755 if (DataSize
> OrgDataSize
) {
756 return EFI_BAD_BUFFER_SIZE
;
762 CopyMem (OrgData
, Data
, DataSize
);
763 AmlHandle
->Modified
= TRUE
;
769 Return the child ACPI objects.
771 @param[in] ParentHandle Parent handle.
772 @param[in, out] Handle On entry, points to the previously returned handle or NULL to start with the first
773 handle. On return, points to the next returned ACPI handle or NULL if there are no
776 @retval EFI_SUCCESS Success
777 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
782 IN EFI_ACPI_HANDLE ParentHandle
,
783 IN OUT EFI_ACPI_HANDLE
*Handle
786 EFI_AML_HANDLE
*AmlParentHandle
;
787 EFI_AML_HANDLE
*AmlHandle
;
791 ASSERT (Handle
!= NULL
);
794 // Check for invalid input parameters
796 if (ParentHandle
== NULL
) {
797 return EFI_INVALID_PARAMETER
;
801 if ((AmlHandle
!= NULL
) && (AmlHandle
->Signature
!= EFI_AML_HANDLE_SIGNATURE
)) {
802 return EFI_INVALID_PARAMETER
;
805 AmlParentHandle
= (EFI_AML_HANDLE
*)ParentHandle
;
806 if (AmlParentHandle
->Signature
== EFI_AML_ROOT_HANDLE_SIGNATURE
) {
810 Status
= AmlGetChildFromRoot (AmlParentHandle
, AmlHandle
, &Buffer
);
811 } else if (AmlParentHandle
->Signature
== EFI_AML_HANDLE_SIGNATURE
) {
815 Status
= AmlGetChildFromNonRoot (AmlParentHandle
, AmlHandle
, &Buffer
);
820 return EFI_INVALID_PARAMETER
;
823 if (EFI_ERROR (Status
)) {
824 return EFI_INVALID_PARAMETER
;
826 if (Buffer
== NULL
) {
830 return SdtOpenEx (Buffer
, (UINTN
)AmlParentHandle
->Buffer
+ AmlParentHandle
->Size
- (UINTN
)Buffer
, Handle
);
834 Returns the handle of the ACPI object representing the specified ACPI path
836 @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
837 @param[in] AmlPath Points to the AML path.
838 @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
841 @retval EFI_SUCCESS Success
842 @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
845 SdtFindPathFromNonRoot (
846 IN EFI_ACPI_HANDLE HandleIn
,
848 OUT EFI_ACPI_HANDLE
*HandleOut
851 EFI_AML_HANDLE
*AmlHandle
;
855 AmlHandle
= (EFI_AML_HANDLE
*)HandleIn
;
858 // For non-root handle, we need search from THIS node instead of ROOT.
860 Status
= AmlFindPath (AmlHandle
, AmlPath
, &Buffer
, FALSE
);
861 if (EFI_ERROR (Status
)) {
862 return EFI_INVALID_PARAMETER
;
864 if (Buffer
== NULL
) {
868 return SdtOpenEx (Buffer
, (UINTN
)AmlHandle
->Buffer
+ AmlHandle
->Size
- (UINTN
)Buffer
, HandleOut
);
872 Duplicate AML handle.
874 @param[in] AmlHandle Handle to be duplicated.
876 @return Duplicated AML handle.
880 IN EFI_AML_HANDLE
*AmlHandle
883 EFI_AML_HANDLE
*DstAmlHandle
;
885 DstAmlHandle
= AllocatePool (sizeof(*DstAmlHandle
));
886 ASSERT (DstAmlHandle
!= NULL
);
887 CopyMem (DstAmlHandle
, (VOID
*)AmlHandle
, sizeof(*DstAmlHandle
));
893 Returns the handle of the ACPI object representing the specified ACPI path
895 @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
896 @param[in] AmlPath Points to the AML path.
897 @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
900 @retval EFI_SUCCESS Success
901 @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
904 SdtFindPathFromRoot (
905 IN EFI_ACPI_HANDLE HandleIn
,
907 OUT EFI_ACPI_HANDLE
*HandleOut
910 EFI_ACPI_HANDLE ChildHandle
;
911 EFI_AML_HANDLE
*AmlHandle
;
915 AmlHandle
= (EFI_AML_HANDLE
*)HandleIn
;
918 // Handle case that AcpiPath is Root
920 if (AmlIsRootPath (AmlPath
)) {
922 // Duplicate RootHandle
924 *HandleOut
= (EFI_ACPI_HANDLE
)SdtDuplicateHandle (AmlHandle
);
929 // Let children find it.
933 Status
= GetChild (HandleIn
, &ChildHandle
);
934 if (EFI_ERROR (Status
)) {
935 return EFI_INVALID_PARAMETER
;
938 if (ChildHandle
== NULL
) {
949 AmlHandle
= (EFI_AML_HANDLE
*)ChildHandle
;
950 Status
= AmlFindPath (AmlHandle
, AmlPath
, &Buffer
, TRUE
);
951 if (EFI_ERROR (Status
)) {
952 return EFI_INVALID_PARAMETER
;
955 if (Buffer
!= NULL
) {
957 // Great! Find it, open
959 Status
= SdtOpenEx (Buffer
, (UINTN
)AmlHandle
->Buffer
+ AmlHandle
->Size
- (UINTN
)Buffer
, HandleOut
);
960 if (!EFI_ERROR (Status
)) {
964 // Not success, try next one
970 // Should not run here
975 Returns the handle of the ACPI object representing the specified ACPI path
977 @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
978 @param[in] AcpiPath Points to the ACPI path, which conforms to the ACPI encoded path format.
979 @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
982 @retval EFI_SUCCESS Success
983 @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
988 IN EFI_ACPI_HANDLE HandleIn
,
990 OUT EFI_ACPI_HANDLE
*HandleOut
993 EFI_AML_HANDLE
*AmlHandle
;
998 // Check for invalid input parameters
1000 if (HandleIn
== NULL
) {
1001 return EFI_INVALID_PARAMETER
;
1004 AmlHandle
= (EFI_AML_HANDLE
*)HandleIn
;
1007 // Convert ASL path to AML path
1009 AmlPath
= AmlNameFromAslName (AcpiPath
);
1010 if (AmlPath
== NULL
) {
1011 return EFI_INVALID_PARAMETER
;
1014 DEBUG_CODE_BEGIN ();
1015 DEBUG ((EFI_D_ERROR
, "AcpiSdt: FindPath - "));
1016 AmlPrintNameString (AmlPath
);
1017 DEBUG ((EFI_D_ERROR
, "\n"));
1020 if (AmlHandle
->Signature
== EFI_AML_ROOT_HANDLE_SIGNATURE
) {
1024 Status
= SdtFindPathFromRoot (HandleIn
, AmlPath
, HandleOut
);
1025 } else if (AmlHandle
->Signature
== EFI_AML_HANDLE_SIGNATURE
) {
1029 Status
= SdtFindPathFromNonRoot (HandleIn
, AmlPath
, HandleOut
);
1031 Status
= EFI_INVALID_PARAMETER
;
1040 ExitPmAuth Protocol notification event handler.
1042 @param[in] Event Event whose notification function is being invoked.
1043 @param[in] Context Pointer to the notification function's context.
1047 ExitPmAuthNotification (
1053 VOID
*DxeSmmReadyToLock
;
1056 // Add more check to locate protocol after got event, because
1057 // the library will signal this event immediately once it is register
1058 // just in case it is already installed.
1060 Status
= gBS
->LocateProtocol (
1061 &gEfiDxeSmmReadyToLockProtocolGuid
,
1065 if (EFI_ERROR (Status
)) {
1070 // Uninstall ACPI SDT protocol, so that we can make sure no one update ACPI table from API level.
1072 Status
= gBS
->UninstallProtocolInterface (
1074 &gEfiAcpiSdtProtocolGuid
,
1075 &mPrivateData
->AcpiSdtProtocol
1077 ASSERT_EFI_ERROR (Status
);
1080 // Close event, so it will not be invoked again.
1082 gBS
->CloseEvent (Event
);
1088 This function initializes AcpiSdt protocol in ACPI table instance.
1090 @param[in] AcpiTableInstance Instance to construct
1093 SdtAcpiTableAcpiSdtConstructor (
1094 IN EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
1099 InitializeListHead (&AcpiTableInstance
->NotifyList
);
1100 CopyMem (&AcpiTableInstance
->AcpiSdtProtocol
, &mAcpiSdtProtocolTemplate
, sizeof(mAcpiSdtProtocolTemplate
));
1103 // Register event for ExitPmAuth, so that we can uninstall ACPI SDT protocol after ExitPmAuth.
1105 EfiCreateProtocolNotifyEvent (
1106 &gEfiDxeSmmReadyToLockProtocolGuid
,
1108 ExitPmAuthNotification
,