2 ACPI Table Protocol Implementation
4 Copyright (c) 2006, 2008, 2009, Intel Corporation<BR>
5 All rights reserved. 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"
22 This function adds an ACPI table to the table list. It will detect FACS and
23 allocate the correct type of memory and properly align the table.
25 @param AcpiTableInstance Instance of the protocol.
26 @param Table Table to add.
27 @param Checksum Does the table require checksumming.
28 @param Version The version of the list to add the table to.
29 @param Handle Pointer for returning the handle.
31 @return EFI_SUCCESS The function completed successfully.
32 @return EFI_OUT_OF_RESOURCES Could not allocate a required resource.
33 @return EFI_ABORTED The table is a duplicate of a table that is required
39 IN EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
,
42 IN EFI_ACPI_TABLE_VERSION Version
,
47 This function finds and removes the table specified by the handle.
49 @param AcpiTableInstance Instance of the protocol.
50 @param Version Bitmask of which versions to remove.
51 @param Handle Table to remove.
53 @return EFI_SUCCESS The function completed successfully.
54 @return EFI_ABORTED An error occurred.
55 @return EFI_NOT_FOUND Handle not found in table list.
60 IN EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
,
61 IN EFI_ACPI_TABLE_VERSION Version
,
66 This function calculates and updates an UINT8 checksum.
68 @param Buffer Pointer to buffer to checksum
69 @param Size Number of bytes to checksum
70 @param ChecksumOffset Offset to place the checksum result in
72 @return EFI_SUCCESS The function completed successfully.
76 AcpiPlatformChecksum (
79 IN UINTN ChecksumOffset
83 Checksum all versions of the common tables, RSDP, RSDT, XSDT.
85 @param AcpiTableInstance Protocol instance private data.
87 @return EFI_SUCCESS The function completed successfully.
91 ChecksumCommonTables (
92 IN OUT EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
96 // Protocol function implementations.
100 This function adds, removes, or updates ACPI tables. If the address is not
101 null and the handle value is null, the table is added. If both the address and
102 handle are not null, the table at handle is updated with the table at address.
103 If the address is null and the handle is not, the table at handle is deleted.
105 @param AcpiTableInstance Instance of the protocol.
106 @param Table Pointer to a table.
107 @param Checksum Boolean indicating if the checksum should be calculated.
108 @param Version Version(s) to set.
109 @param Handle Handle of the table.
111 @return EFI_SUCCESS The function completed successfully.
112 @return EFI_INVALID_PARAMETER Both the Table and *Handle were NULL.
113 @return EFI_ABORTED Could not complete the desired request.
119 IN EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
,
120 IN VOID
*Table OPTIONAL
,
122 IN EFI_ACPI_TABLE_VERSION Version
,
130 // Check for invalid input parameters
138 // Determine desired action
143 // Invalid parameter combination
145 return EFI_INVALID_PARAMETER
;
150 Status
= AddTableToList (AcpiTableInstance
, Table
, Checksum
, Version
, Handle
);
158 // Delete the table list entry
160 Status
= RemoveTableFromList (AcpiTableInstance
, Version
, *Handle
);
161 if (EFI_ERROR (Status
)) {
163 // Should not get an error here ever, but abort if we do.
168 // Set the handle to replace the table at the same handle
170 SavedHandle
= AcpiTableInstance
->CurrentHandle
;
171 AcpiTableInstance
->CurrentHandle
= *Handle
;
176 Status
= AddTableToList (AcpiTableInstance
, Table
, Checksum
, Version
, Handle
);
179 // Restore the saved current handle
181 AcpiTableInstance
->CurrentHandle
= SavedHandle
;
186 Status
= RemoveTableFromList (AcpiTableInstance
, Version
, *Handle
);
190 if (EFI_ERROR (Status
)) {
192 // Should not get an error here ever, but abort if we do.
203 This function publishes the specified versions of the ACPI tables by
204 installing EFI configuration table entries for them. Any combination of
205 table versions can be published.
207 @param AcpiTableInstance Instance of the protocol.
208 @param Version Version(s) to publish.
210 @return EFI_SUCCESS The function completed successfully.
211 @return EFI_ABORTED The function could not complete successfully.
217 IN EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
,
218 IN EFI_ACPI_TABLE_VERSION Version
222 UINT32
*CurrentRsdtEntry
;
223 VOID
*CurrentXsdtEntry
;
227 // Reorder tables as some operating systems don't seem to find the
228 // FADT correctly if it is not in the first few entries
232 // Add FADT as the first entry
234 if ((Version
& EFI_ACPI_TABLE_VERSION_1_0B
) != 0) {
235 CurrentRsdtEntry
= (UINT32
*) ((UINT8
*) AcpiTableInstance
->Rsdt1
+ sizeof (EFI_ACPI_DESCRIPTION_HEADER
));
236 *CurrentRsdtEntry
= (UINT32
) (UINTN
) AcpiTableInstance
->Fadt1
;
238 if ((Version
& EFI_ACPI_TABLE_VERSION_2_0
) != 0 ||
239 (Version
& EFI_ACPI_TABLE_VERSION_3_0
) != 0) {
240 CurrentRsdtEntry
= (UINT32
*) ((UINT8
*) AcpiTableInstance
->Rsdt3
+ sizeof (EFI_ACPI_DESCRIPTION_HEADER
));
241 *CurrentRsdtEntry
= (UINT32
) (UINTN
) AcpiTableInstance
->Fadt3
;
242 CurrentXsdtEntry
= (VOID
*) ((UINT8
*) AcpiTableInstance
->Xsdt
+ sizeof (EFI_ACPI_DESCRIPTION_HEADER
));
244 // Add entry to XSDT, XSDT expects 64 bit pointers, but
245 // the table pointers in XSDT are not aligned on 8 byte boundary.
247 Buffer64
= (UINT64
) (UINTN
) AcpiTableInstance
->Fadt3
;
256 // Do checksum again because Dsdt/Xsdt is updated.
258 ChecksumCommonTables (AcpiTableInstance
);
261 // Add the RSD_PTR to the system table and store that we have installed the
264 if (((Version
& EFI_ACPI_TABLE_VERSION_1_0B
) != 0) &&
265 !AcpiTableInstance
->TablesInstalled1
) {
266 Status
= gBS
->InstallConfigurationTable (&gEfiAcpi10TableGuid
, AcpiTableInstance
->Rsdp1
);
267 if (EFI_ERROR (Status
)) {
271 AcpiTableInstance
->TablesInstalled1
= TRUE
;
274 if (((Version
& EFI_ACPI_TABLE_VERSION_2_0
) != 0 ||
275 (Version
& EFI_ACPI_TABLE_VERSION_3_0
) != 0) &&
276 !AcpiTableInstance
->TablesInstalled3
) {
277 Status
= gBS
->InstallConfigurationTable (&gEfiAcpiTableGuid
, AcpiTableInstance
->Rsdp3
);
278 if (EFI_ERROR (Status
)) {
282 AcpiTableInstance
->TablesInstalled3
= TRUE
;
290 Installs an ACPI table into the RSDT/XSDT.
292 @param This Protocol instance pointer.
293 @param AcpiTableBuffer A pointer to a buffer containing the ACPI table to be installed.
294 @param AcpiTableBufferSize Specifies the size, in bytes, of the AcpiTableBuffer buffer.
295 @param TableKey Reurns a key to refer to the ACPI table.
297 @return EFI_SUCCESS The table was successfully inserted.
298 @return EFI_INVALID_PARAMETER Either AcpiTableBuffer is NULL, TableKey is NULL, or AcpiTableBufferSize
299 and the size field embedded in the ACPI table pointed to by AcpiTableBuffer
301 @return EFI_OUT_OF_RESOURCES Insufficient resources exist to complete the request.
307 IN CONST EFI_ACPI_TABLE_PROTOCOL
*This
,
308 IN CONST VOID
*AcpiTableBuffer
,
309 IN UINTN AcpiTableBufferSize
,
313 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
315 VOID
*AcpiTableBufferConst
;
318 // Check for invalid input parameters
320 if ((AcpiTableBuffer
== NULL
) || (TableKey
== NULL
)
321 || (((EFI_ACPI_DESCRIPTION_HEADER
*) AcpiTableBuffer
)->Length
!= AcpiTableBufferSize
)) {
322 return EFI_INVALID_PARAMETER
;
326 // Get the instance of the ACPI table protocol
328 AcpiTableInstance
= EFI_ACPI_TABLE_INSTANCE_FROM_THIS (This
);
331 // Install the ACPI table
333 AcpiTableBufferConst
= AllocateCopyPool (AcpiTableBufferSize
,AcpiTableBuffer
);
335 Status
= SetAcpiTable (
337 AcpiTableBufferConst
,
339 EFI_ACPI_TABLE_VERSION_1_0B
| EFI_ACPI_TABLE_VERSION_2_0
,
342 if (!EFI_ERROR (Status
)) {
343 Status
= PublishTables (
345 EFI_ACPI_TABLE_VERSION_1_0B
| EFI_ACPI_TABLE_VERSION_2_0
348 FreePool (AcpiTableBufferConst
);
355 Removes an ACPI table from the RSDT/XSDT.
357 @param This Protocol instance pointer.
358 @param TableKey Specifies the table to uninstall. The key was returned from InstallAcpiTable().
360 @return EFI_SUCCESS The table was successfully uninstalled.
361 @return EFI_NOT_FOUND TableKey does not refer to a valid key for a table entry.
367 IN CONST EFI_ACPI_TABLE_PROTOCOL
*This
,
371 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
;
375 // Get the instance of the ACPI table protocol
377 AcpiTableInstance
= EFI_ACPI_TABLE_INSTANCE_FROM_THIS (This
);
380 // Uninstall the ACPI table
382 Status
= SetAcpiTable (
386 EFI_ACPI_TABLE_VERSION_1_0B
| EFI_ACPI_TABLE_VERSION_2_0
,
389 if (!EFI_ERROR (Status
)) {
390 Status
= PublishTables (
392 EFI_ACPI_TABLE_VERSION_1_0B
| EFI_ACPI_TABLE_VERSION_2_0
396 if (EFI_ERROR (Status
)) {
397 return EFI_NOT_FOUND
;
405 This function adds an ACPI table to the table list. It will detect FACS and
406 allocate the correct type of memory and properly align the table.
408 @param AcpiTableInstance Instance of the protocol.
409 @param Table Table to add.
410 @param Checksum Does the table require checksumming.
411 @param Version The version of the list to add the table to.
412 @param Handle Pointer for returning the handle.
414 @return EFI_SUCCESS The function completed successfully.
415 @return EFI_OUT_OF_RESOURCES Could not allocate a required resource.
416 @return EFI_ABORTED The table is a duplicate of a table that is required
422 IN EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
,
425 IN EFI_ACPI_TABLE_VERSION Version
,
430 EFI_ACPI_TABLE_LIST
*CurrentTableList
;
431 UINT32 CurrentTableSignature
;
432 UINT32 CurrentTableSize
;
433 UINT32
*CurrentRsdtEntry
;
434 VOID
*CurrentXsdtEntry
;
439 // Check for invalid input parameters
441 ASSERT (AcpiTableInstance
);
451 // Create a new list entry
453 CurrentTableList
= AllocatePool (sizeof (EFI_ACPI_TABLE_LIST
));
454 ASSERT (CurrentTableList
);
457 // Determine table type and size
459 CurrentTableSignature
= ((EFI_ACPI_COMMON_HEADER
*) Table
)->Signature
;
460 CurrentTableSize
= ((EFI_ACPI_COMMON_HEADER
*) Table
)->Length
;
463 // Allocate a buffer for the table. All tables are allocated in the lower 32 bits of address space
464 // for backwards compatibility with ACPI 1.0 OS.
466 // This is done because ACPI 1.0 pointers are 32 bit values.
467 // ACPI 2.0 OS and all 64 bit OS must use the 64 bit ACPI table addresses.
468 // There is no architectural reason these should be below 4GB, it is purely
469 // for convenience of implementation that we force memory below 4GB.
471 CurrentTableList
->PageAddress
= 0xFFFFFFFF;
472 CurrentTableList
->NumberOfPages
= EFI_SIZE_TO_PAGES (CurrentTableSize
);
475 // Allocation memory type depends on the type of the table
477 if (CurrentTableSignature
== EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE
||
478 CurrentTableSignature
== EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE
) {
480 // Allocate memory for the FACS. This structure must be aligned
481 // on a 64 byte boundary and must be ACPI NVS memory.
482 // Using AllocatePages should ensure that it is always aligned.
484 ASSERT ((EFI_PAGE_SIZE
% 64) == 0);
485 Status
= gBS
->AllocatePages (
488 CurrentTableList
->NumberOfPages
,
489 &CurrentTableList
->PageAddress
493 // All other tables are ACPI reclaim memory, no alignment requirements.
495 Status
= gBS
->AllocatePages (
497 EfiACPIReclaimMemory
,
498 CurrentTableList
->NumberOfPages
,
499 &CurrentTableList
->PageAddress
503 // Check return value from memory alloc.
505 if (EFI_ERROR (Status
)) {
506 gBS
->FreePool (CurrentTableList
);
507 return EFI_OUT_OF_RESOURCES
;
510 // Update the table pointer with the allocated memory start
512 CurrentTableList
->Table
= (EFI_ACPI_COMMON_HEADER
*) (UINTN
) CurrentTableList
->PageAddress
;
515 // Initialize the table contents
517 CurrentTableList
->Signature
= EFI_ACPI_TABLE_LIST_SIGNATURE
;
518 CopyMem (CurrentTableList
->Table
, Table
, CurrentTableSize
);
519 CurrentTableList
->Handle
= AcpiTableInstance
->CurrentHandle
++;
520 *Handle
= CurrentTableList
->Handle
;
521 CurrentTableList
->Version
= Version
;
524 // Update internal pointers if this is a required table. If it is a required
525 // table and a table of that type already exists, return an error.
527 // Calculate the checksum if the table is not FACS.
529 switch (CurrentTableSignature
) {
531 case EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
:
533 // We don't add the FADT in the standard way because some
534 // OS expect the FADT to be early in the table list.
535 // So we always add it as the first element in the list.
540 // Check that the table has not been previously added.
542 if (((Version
& EFI_ACPI_TABLE_VERSION_1_0B
) != 0 && AcpiTableInstance
->Fadt1
!= NULL
) ||
543 ((Version
& EFI_ACPI_TABLE_VERSION_2_0
) != 0 && AcpiTableInstance
->Fadt3
!= NULL
) ||
544 ((Version
& EFI_ACPI_TABLE_VERSION_3_0
) != 0 && AcpiTableInstance
->Fadt3
!= NULL
)
546 gBS
->FreePages (CurrentTableList
->PageAddress
, CurrentTableList
->NumberOfPages
);
547 gBS
->FreePool (CurrentTableList
);
551 // Add the table to the appropriate table version
553 if ((Version
& EFI_ACPI_TABLE_VERSION_1_0B
) != 0) {
555 // Save a pointer to the table
557 AcpiTableInstance
->Fadt1
= (EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE
*) CurrentTableList
->Table
;
560 // Update pointers in FADT. If tables don't exist this will put NULL pointers there.
562 AcpiTableInstance
->Fadt1
->FirmwareCtrl
= (UINT32
) (UINTN
) AcpiTableInstance
->Facs1
;
563 AcpiTableInstance
->Fadt1
->Dsdt
= (UINT32
) (UINTN
) AcpiTableInstance
->Dsdt1
;
566 // RSDP OEM information is updated to match the FADT OEM information
569 &AcpiTableInstance
->Rsdp1
->OemId
,
570 &AcpiTableInstance
->Fadt1
->Header
.OemId
,
575 // RSDT OEM information is updated to match the FADT OEM information.
578 &AcpiTableInstance
->Rsdt1
->OemId
,
579 &AcpiTableInstance
->Fadt1
->Header
.OemId
,
584 &AcpiTableInstance
->Rsdt1
->OemTableId
,
585 &AcpiTableInstance
->Fadt1
->Header
.OemTableId
,
588 AcpiTableInstance
->Rsdt1
->OemRevision
= AcpiTableInstance
->Fadt1
->Header
.OemRevision
;
591 if ((Version
& EFI_ACPI_TABLE_VERSION_2_0
) != 0 ||
592 (Version
& EFI_ACPI_TABLE_VERSION_3_0
) != 0) {
594 // Save a pointer to the table
596 AcpiTableInstance
->Fadt3
= (EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE
*) CurrentTableList
->Table
;
599 // Update pointers in FADT. If tables don't exist this will put NULL pointers there.
601 if (AcpiTableInstance
->Fadt3
!= NULL
) {
602 AcpiTableInstance
->Fadt3
->FirmwareCtrl
= (UINT32
) (UINTN
) AcpiTableInstance
->Facs3
;
603 Buffer64
= (UINT64
) (UINTN
) AcpiTableInstance
->Facs3
;
605 &AcpiTableInstance
->Fadt3
->XFirmwareCtrl
,
609 AcpiTableInstance
->Fadt3
->Dsdt
= (UINT32
) (UINTN
) AcpiTableInstance
->Dsdt3
;
610 Buffer64
= (UINT64
) (UINTN
) AcpiTableInstance
->Dsdt3
;
612 &AcpiTableInstance
->Fadt3
->XDsdt
,
618 // RSDP OEM information is updated to match the FADT OEM information
621 &AcpiTableInstance
->Rsdp3
->OemId
,
622 &AcpiTableInstance
->Fadt3
->Header
.OemId
,
627 // RSDT OEM information is updated to match FADT OEM information.
630 &AcpiTableInstance
->Rsdt3
->OemId
,
631 &AcpiTableInstance
->Fadt3
->Header
.OemId
,
635 &AcpiTableInstance
->Rsdt3
->OemTableId
,
636 &AcpiTableInstance
->Fadt3
->Header
.OemTableId
,
639 AcpiTableInstance
->Rsdt3
->OemRevision
= AcpiTableInstance
->Fadt3
->Header
.OemRevision
;
642 // XSDT OEM information is updated to match FADT OEM information.
645 &AcpiTableInstance
->Xsdt
->OemId
,
646 &AcpiTableInstance
->Fadt3
->Header
.OemId
,
650 &AcpiTableInstance
->Xsdt
->OemTableId
,
651 &AcpiTableInstance
->Fadt3
->Header
.OemTableId
,
654 AcpiTableInstance
->Xsdt
->OemRevision
= AcpiTableInstance
->Fadt3
->Header
.OemRevision
;
657 // Checksum the table
660 AcpiPlatformChecksum (
661 CurrentTableList
->Table
,
662 CurrentTableList
->Table
->Length
,
663 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
669 case EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE
:
671 // Check that the table has not been previously added.
673 if (((Version
& EFI_ACPI_TABLE_VERSION_1_0B
) != 0 && AcpiTableInstance
->Facs1
!= NULL
) ||
674 ((Version
& EFI_ACPI_TABLE_VERSION_2_0
) != 0 && AcpiTableInstance
->Facs3
!= NULL
) ||
675 ((Version
& EFI_ACPI_TABLE_VERSION_3_0
) != 0 && AcpiTableInstance
->Facs3
!= NULL
)
677 gBS
->FreePages (CurrentTableList
->PageAddress
, CurrentTableList
->NumberOfPages
);
678 gBS
->FreePool (CurrentTableList
);
682 // FACS is referenced by FADT and is not part of RSDT
687 // Add the table to the appropriate table version
689 if ((Version
& EFI_ACPI_TABLE_VERSION_1_0B
) != 0) {
691 // Save a pointer to the table
693 AcpiTableInstance
->Facs1
= (EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE
*) CurrentTableList
->Table
;
696 // If FADT already exists, update table pointers.
698 if (AcpiTableInstance
->Fadt1
!= NULL
) {
699 AcpiTableInstance
->Fadt1
->FirmwareCtrl
= (UINT32
) (UINTN
) AcpiTableInstance
->Facs1
;
702 // Checksum FADT table
704 AcpiPlatformChecksum (
705 AcpiTableInstance
->Fadt1
,
706 AcpiTableInstance
->Fadt1
->Header
.Length
,
707 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
713 if ((Version
& EFI_ACPI_TABLE_VERSION_2_0
) != 0 ||
714 (Version
& EFI_ACPI_TABLE_VERSION_3_0
) != 0) {
716 // Save a pointer to the table
718 AcpiTableInstance
->Facs3
= (EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE
*) CurrentTableList
->Table
;
721 // If FADT already exists, update table pointers.
723 if (AcpiTableInstance
->Fadt3
!= NULL
) {
724 AcpiTableInstance
->Fadt3
->FirmwareCtrl
= (UINT32
) (UINTN
) AcpiTableInstance
->Facs3
;
725 Buffer64
= (UINT64
) (UINTN
) AcpiTableInstance
->Facs3
;
727 &AcpiTableInstance
->Fadt3
->XFirmwareCtrl
,
733 // Checksum FADT table
735 AcpiPlatformChecksum (
736 AcpiTableInstance
->Fadt3
,
737 AcpiTableInstance
->Fadt3
->Header
.Length
,
738 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
746 case EFI_ACPI_1_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
:
748 // Check that the table has not been previously added.
750 if (((Version
& EFI_ACPI_TABLE_VERSION_1_0B
) != 0 && AcpiTableInstance
->Dsdt1
!= NULL
) ||
751 ((Version
& EFI_ACPI_TABLE_VERSION_2_0
) != 0 && AcpiTableInstance
->Dsdt3
!= NULL
) ||
752 ((Version
& EFI_ACPI_TABLE_VERSION_3_0
) != 0 && AcpiTableInstance
->Dsdt3
!= NULL
)
754 gBS
->FreePages (CurrentTableList
->PageAddress
, CurrentTableList
->NumberOfPages
);
755 gBS
->FreePool (CurrentTableList
);
759 // DSDT is referenced by FADT and is not part of RSDT
764 // Add the table to the appropriate table version
766 if ((Version
& EFI_ACPI_TABLE_VERSION_1_0B
) != 0) {
768 // Save a pointer to the table
770 AcpiTableInstance
->Dsdt1
= (EFI_ACPI_DESCRIPTION_HEADER
*) CurrentTableList
->Table
;
773 // If FADT already exists, update table pointers.
775 if (AcpiTableInstance
->Fadt1
!= NULL
) {
776 AcpiTableInstance
->Fadt1
->Dsdt
= (UINT32
) (UINTN
) AcpiTableInstance
->Dsdt1
;
779 // Checksum FADT table
781 AcpiPlatformChecksum (
782 AcpiTableInstance
->Fadt1
,
783 AcpiTableInstance
->Fadt1
->Header
.Length
,
784 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
790 if ((Version
& EFI_ACPI_TABLE_VERSION_2_0
) != 0 ||
791 (Version
& EFI_ACPI_TABLE_VERSION_3_0
) != 0) {
793 // Save a pointer to the table
795 AcpiTableInstance
->Dsdt3
= (EFI_ACPI_DESCRIPTION_HEADER
*) CurrentTableList
->Table
;
798 // If FADT already exists, update table pointers.
800 if (AcpiTableInstance
->Fadt3
!= NULL
) {
801 AcpiTableInstance
->Fadt3
->Dsdt
= (UINT32
) (UINTN
) AcpiTableInstance
->Dsdt3
;
802 Buffer64
= (UINT64
) (UINTN
) AcpiTableInstance
->Dsdt3
;
804 &AcpiTableInstance
->Fadt3
->XDsdt
,
810 // Checksum FADT table
812 AcpiPlatformChecksum (
813 AcpiTableInstance
->Fadt3
,
814 AcpiTableInstance
->Fadt3
->Header
.Length
,
815 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
821 // Checksum the table
824 AcpiPlatformChecksum (
825 CurrentTableList
->Table
,
826 CurrentTableList
->Table
->Length
,
827 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
835 // Checksum the table
838 AcpiPlatformChecksum (
839 CurrentTableList
->Table
,
840 CurrentTableList
->Table
->Length
,
841 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
848 // Add the table to the current list of tables
850 InsertTailList (&AcpiTableInstance
->TableList
, &CurrentTableList
->Link
);
853 // Add the table to RSDT and/or XSDT table entry lists.
856 // Add to ACPI 1.0b table tree
858 if ((Version
& EFI_ACPI_TABLE_VERSION_1_0B
) != 0) {
859 CurrentRsdtEntry
= (UINT32
*)
861 (UINT8
*) AcpiTableInstance
->Rsdt1
+
862 sizeof (EFI_ACPI_DESCRIPTION_HEADER
) +
863 AcpiTableInstance
->NumberOfTableEntries1
*
868 // Add entry to the RSDT unless its the FACS or DSDT
871 *CurrentRsdtEntry
= (UINT32
) (UINTN
) CurrentTableList
->Table
;
874 // Update RSDT length
876 AcpiTableInstance
->Rsdt1
->Length
= AcpiTableInstance
->Rsdt1
->Length
+ sizeof (UINT32
);
878 AcpiTableInstance
->NumberOfTableEntries1
++;
881 ASSERT (AcpiTableInstance
->NumberOfTableEntries1
<= EFI_ACPI_MAX_NUM_TABLES
);
884 // Add to ACPI 2.0/3.0 table tree
886 if ((Version
& EFI_ACPI_TABLE_VERSION_2_0
) != 0 ||
887 (Version
& EFI_ACPI_TABLE_VERSION_3_0
) != 0) {
890 // At this time, it is assumed that RSDT and XSDT maintain parallel lists of tables.
891 // If it becomes necessary to maintain separate table lists, changes will be required.
893 CurrentRsdtEntry
= (UINT32
*)
895 (UINT8
*) AcpiTableInstance
->Rsdt3
+
896 sizeof (EFI_ACPI_DESCRIPTION_HEADER
) +
897 AcpiTableInstance
->NumberOfTableEntries3
*
902 // This pointer must not be directly dereferenced as the XSDT entries may not
903 // be 64 bit aligned resulting in a possible fault. Use CopyMem to update.
905 CurrentXsdtEntry
= (VOID
*)
907 (UINT8
*) AcpiTableInstance
->Xsdt
+
908 sizeof (EFI_ACPI_DESCRIPTION_HEADER
) +
909 AcpiTableInstance
->NumberOfTableEntries3
*
914 // Add entry to the RSDT
916 *CurrentRsdtEntry
= (UINT32
) (UINTN
) CurrentTableList
->Table
;
919 // Update RSDT length
921 AcpiTableInstance
->Rsdt3
->Length
= AcpiTableInstance
->Rsdt3
->Length
+ sizeof (UINT32
);
924 // Add entry to XSDT, XSDT expects 64 bit pointers, but
925 // the table pointers in XSDT are not aligned on 8 byte boundary.
927 Buffer64
= (UINT64
) (UINTN
) CurrentTableList
->Table
;
937 AcpiTableInstance
->Xsdt
->Length
= AcpiTableInstance
->Xsdt
->Length
+ sizeof (UINT64
);
939 AcpiTableInstance
->NumberOfTableEntries3
++;
942 ASSERT (AcpiTableInstance
->NumberOfTableEntries3
<= EFI_ACPI_MAX_NUM_TABLES
);
945 ChecksumCommonTables (AcpiTableInstance
);
951 This function finds the table specified by the handle and returns a pointer to it.
952 If the handle is not found, EFI_NOT_FOUND is returned and the contents of Table are
955 @param Handle Table to find.
956 @param TableList Table list to search
957 @param Table Pointer to table found.
959 @return EFI_SUCCESS The function completed successfully.
960 @return EFI_NOT_FOUND No table found matching the handle specified.
966 IN LIST_ENTRY
*TableList
,
967 OUT EFI_ACPI_TABLE_LIST
**Table
970 LIST_ENTRY
*CurrentLink
;
971 EFI_ACPI_TABLE_LIST
*CurrentTable
;
974 // Check for invalid input parameters
981 CurrentLink
= TableList
->ForwardLink
;
983 while (CurrentLink
!= TableList
) {
984 CurrentTable
= EFI_ACPI_TABLE_LIST_FROM_LINK (CurrentLink
);
985 if (CurrentTable
->Handle
== Handle
) {
987 // Found handle, so return this table.
989 *Table
= CurrentTable
;
993 CurrentLink
= CurrentLink
->ForwardLink
;
998 return EFI_NOT_FOUND
;
1003 This function removes a basic table from the RSDT and/or XSDT.
1004 For Acpi 1.0 tables, pass in the Rsdt.
1005 For Acpi 2.0 tables, pass in both Rsdt and Xsdt.
1007 @param Table Pointer to table found.
1008 @param NumberOfTableEntries Current number of table entries in the RSDT/XSDT
1009 @param Rsdt Pointer to the RSDT to remove from
1010 @param Xsdt Pointer to the Xsdt to remove from
1012 @return EFI_SUCCESS The function completed successfully.
1013 @return EFI_INVALID_PARAMETER The table was not found in both Rsdt and Xsdt.
1017 RemoveTableFromRsdt (
1018 IN OUT EFI_ACPI_TABLE_LIST
* Table
,
1019 IN OUT UINTN
*NumberOfTableEntries
,
1020 IN OUT EFI_ACPI_DESCRIPTION_HEADER
* Rsdt
,
1021 IN OUT EFI_ACPI_DESCRIPTION_HEADER
* Xsdt OPTIONAL
1024 UINT32
*CurrentRsdtEntry
;
1025 VOID
*CurrentXsdtEntry
;
1026 UINT64 CurrentTablePointer64
;
1030 // Check for invalid input parameters
1033 ASSERT (NumberOfTableEntries
);
1037 // Find the table entry in the RSDT and XSDT
1039 for (Index
= 0; Index
< *NumberOfTableEntries
; Index
++) {
1041 // At this time, it is assumed that RSDT and XSDT maintain parallel lists of tables.
1042 // If it becomes necessary to maintain separate table lists, changes will be required.
1044 CurrentRsdtEntry
= (UINT32
*) ((UINT8
*) Rsdt
+ sizeof (EFI_ACPI_DESCRIPTION_HEADER
) + Index
* sizeof (UINT32
));
1047 // This pointer must not be directly dereferenced as the XSDT entries may not
1048 // be 64 bit aligned resulting in a possible fault. Use CopyMem to update.
1050 CurrentXsdtEntry
= (VOID
*) ((UINT8
*) Xsdt
+ sizeof (EFI_ACPI_DESCRIPTION_HEADER
) + Index
* sizeof (UINT64
));
1053 // Read the entry value out of the XSDT
1055 CopyMem (&CurrentTablePointer64
, CurrentXsdtEntry
, sizeof (UINT64
));
1058 // Initialize to NULL
1060 CurrentXsdtEntry
= 0;
1061 CurrentTablePointer64
= 0;
1064 // Check if we have found the corresponding entry in both RSDT and XSDT
1066 if (*CurrentRsdtEntry
== (UINT32
) (UINTN
) Table
->Table
&&
1067 ((Xsdt
== NULL
) || CurrentTablePointer64
== (UINT64
) (UINTN
) Table
->Table
)
1070 // Found entry, so copy all following entries and shrink table
1071 // We actually copy all + 1 to copy the initialized value of memory over
1074 CopyMem (CurrentRsdtEntry
, CurrentRsdtEntry
+ 1, (*NumberOfTableEntries
- Index
) * sizeof (UINT32
));
1075 Rsdt
->Length
= Rsdt
->Length
- sizeof (UINT32
);
1077 CopyMem (CurrentXsdtEntry
, ((UINT64
*) CurrentXsdtEntry
) + 1, (*NumberOfTableEntries
- Index
) * sizeof (UINT64
));
1078 Xsdt
->Length
= Xsdt
->Length
- sizeof (UINT64
);
1081 } else if (Index
+ 1 == *NumberOfTableEntries
) {
1083 // At the last entry, and table not found
1085 return EFI_INVALID_PARAMETER
;
1089 // Checksum the tables
1091 AcpiPlatformChecksum (
1094 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
1099 AcpiPlatformChecksum (
1102 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
1107 // Decrement the number of tables
1109 (*NumberOfTableEntries
)--;
1116 This function removes a table and frees any associated memory.
1118 @param AcpiTableInstance Instance of the protocol.
1119 @param Version Version(s) to delete.
1120 @param Table Pointer to table found.
1122 @return EFI_SUCCESS The function completed successfully.
1127 IN EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
,
1128 IN EFI_ACPI_TABLE_VERSION Version
,
1129 IN OUT EFI_ACPI_TABLE_LIST
*Table
1132 UINT32 CurrentTableSignature
;
1133 BOOLEAN RemoveFromRsdt
;
1136 // Check for invalid input parameters
1138 ASSERT (AcpiTableInstance
);
1144 RemoveFromRsdt
= TRUE
;
1145 CurrentTableSignature
= ((EFI_ACPI_COMMON_HEADER
*) Table
->Table
)->Signature
;
1148 // Basic tasks to accomplish delete are:
1149 // Determine removal requirements (in RSDT/XSDT or not)
1150 // Remove entry from RSDT/XSDT
1151 // Remove any table references to the table
1152 // If no one is using the table
1153 // Free the table (removing pointers from private data and tables)
1155 // Free list structure
1158 // Determine if this table is in the RSDT or XSDT
1160 if ((CurrentTableSignature
== EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE
) ||
1161 (CurrentTableSignature
== EFI_ACPI_2_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
) ||
1162 (CurrentTableSignature
== EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
)
1164 RemoveFromRsdt
= FALSE
;
1167 // We don't remove the FADT in the standard way because some
1168 // OS expect the FADT to be early in the table list.
1169 // So we always put it as the first element in the list.
1171 if (CurrentTableSignature
== EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
) {
1172 RemoveFromRsdt
= FALSE
;
1176 // Remove the table from RSDT and XSDT
1178 if (Table
->Table
!= NULL
) {
1180 // This is a basic table, remove it from any lists and the Rsdt and/or Xsdt
1182 if (Version
& EFI_ACPI_TABLE_VERSION_NONE
& Table
->Version
) {
1184 // Remove this version from the table
1186 Table
->Version
= Table
->Version
&~EFI_ACPI_TABLE_VERSION_NONE
;
1189 if (Version
& EFI_ACPI_TABLE_VERSION_1_0B
& Table
->Version
) {
1191 // Remove this version from the table
1193 Table
->Version
= Table
->Version
&~EFI_ACPI_TABLE_VERSION_1_0B
;
1196 // Remove from Rsdt. We don't care about the return value because it is
1197 // acceptable for the table to not exist in Rsdt.
1198 // We didn't add some tables so we don't remove them.
1200 if (RemoveFromRsdt
) {
1201 RemoveTableFromRsdt (
1203 &AcpiTableInstance
->NumberOfTableEntries1
,
1204 AcpiTableInstance
->Rsdt1
,
1210 if ((Version
& EFI_ACPI_TABLE_VERSION_2_0
& Table
->Version
) ||
1211 (Version
& EFI_ACPI_TABLE_VERSION_3_0
& Table
->Version
)) {
1213 // Remove this version from the table
1215 if (Version
& EFI_ACPI_TABLE_VERSION_2_0
& Table
->Version
) {
1216 Table
->Version
= Table
->Version
&~EFI_ACPI_TABLE_VERSION_2_0
;
1218 if (Version
& EFI_ACPI_TABLE_VERSION_3_0
& Table
->Version
) {
1219 Table
->Version
= Table
->Version
&~EFI_ACPI_TABLE_VERSION_3_0
;
1223 // Remove from Rsdt and Xsdt. We don't care about the return value
1224 // because it is acceptable for the table to not exist in Rsdt/Xsdt.
1225 // We didn't add some tables so we don't remove them.
1227 if (RemoveFromRsdt
) {
1228 RemoveTableFromRsdt (
1230 &AcpiTableInstance
->NumberOfTableEntries3
,
1231 AcpiTableInstance
->Rsdt3
,
1232 AcpiTableInstance
->Xsdt
1237 // Free the table, clean up any dependent tables and our private data pointers.
1239 switch (Table
->Table
->Signature
) {
1241 case EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
:
1242 if ((Version
& EFI_ACPI_TABLE_VERSION_1_0B
) != 0) {
1243 AcpiTableInstance
->Fadt1
= NULL
;
1246 if ((Version
& EFI_ACPI_TABLE_VERSION_2_0
) != 0 ||
1247 (Version
& EFI_ACPI_TABLE_VERSION_3_0
) != 0) {
1248 AcpiTableInstance
->Fadt3
= NULL
;
1252 case EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE
:
1253 if ((Version
& EFI_ACPI_TABLE_VERSION_1_0B
) != 0) {
1254 AcpiTableInstance
->Facs1
= NULL
;
1257 // Update FADT table pointers
1259 if (AcpiTableInstance
->Fadt1
!= NULL
) {
1260 AcpiTableInstance
->Fadt1
->FirmwareCtrl
= 0;
1265 AcpiPlatformChecksum (
1266 AcpiTableInstance
->Fadt1
,
1267 AcpiTableInstance
->Fadt1
->Header
.Length
,
1268 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
1274 if ((Version
& EFI_ACPI_TABLE_VERSION_2_0
) != 0 ||
1275 (Version
& EFI_ACPI_TABLE_VERSION_3_0
) != 0) {
1276 AcpiTableInstance
->Facs3
= NULL
;
1279 // Update FADT table pointers
1281 if (AcpiTableInstance
->Fadt3
!= NULL
) {
1282 AcpiTableInstance
->Fadt3
->FirmwareCtrl
= 0;
1283 ZeroMem (&AcpiTableInstance
->Fadt3
->XFirmwareCtrl
, sizeof (UINT64
));
1288 AcpiPlatformChecksum (
1289 AcpiTableInstance
->Fadt3
,
1290 AcpiTableInstance
->Fadt3
->Header
.Length
,
1291 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
1298 case EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
:
1299 if ((Version
& EFI_ACPI_TABLE_VERSION_1_0B
) != 0) {
1300 AcpiTableInstance
->Dsdt1
= NULL
;
1303 // Update FADT table pointers
1305 if (AcpiTableInstance
->Fadt1
!= NULL
) {
1306 AcpiTableInstance
->Fadt1
->Dsdt
= 0;
1311 AcpiPlatformChecksum (
1312 AcpiTableInstance
->Fadt1
,
1313 AcpiTableInstance
->Fadt1
->Header
.Length
,
1314 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
1321 if ((Version
& EFI_ACPI_TABLE_VERSION_2_0
) != 0 ||
1322 (Version
& EFI_ACPI_TABLE_VERSION_3_0
) != 0) {
1323 AcpiTableInstance
->Dsdt3
= NULL
;
1326 // Update FADT table pointers
1328 if (AcpiTableInstance
->Fadt3
!= NULL
) {
1329 AcpiTableInstance
->Fadt3
->Dsdt
= 0;
1330 ZeroMem (&AcpiTableInstance
->Fadt3
->XDsdt
, sizeof (UINT64
));
1335 AcpiPlatformChecksum (
1336 AcpiTableInstance
->Fadt3
,
1337 AcpiTableInstance
->Fadt3
->Header
.Length
,
1338 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
1353 // If no version is using this table anymore, remove and free list entry.
1355 if (Table
->Version
== 0) {
1359 gBS
->FreePages (Table
->PageAddress
, Table
->NumberOfPages
);
1360 RemoveEntryList (&(Table
->Link
));
1361 gBS
->FreePool (Table
);
1371 This function finds and removes the table specified by the handle.
1373 @param AcpiTableInstance Instance of the protocol.
1374 @param Version Bitmask of which versions to remove.
1375 @param Handle Table to remove.
1377 @return EFI_SUCCESS The function completed successfully.
1378 @return EFI_ABORTED An error occurred.
1379 @return EFI_NOT_FOUND Handle not found in table list.
1383 RemoveTableFromList (
1384 IN EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
,
1385 IN EFI_ACPI_TABLE_VERSION Version
,
1389 EFI_ACPI_TABLE_LIST
*Table
;
1393 // Check for invalid input parameters
1395 ASSERT (AcpiTableInstance
);
1400 Status
= FindTableByHandle (
1402 &AcpiTableInstance
->TableList
,
1405 if (EFI_ERROR (Status
)) {
1406 return EFI_NOT_FOUND
;
1411 Status
= DeleteTable (AcpiTableInstance
, Version
, Table
);
1412 if (EFI_ERROR (Status
)) {
1416 // Completed successfully
1423 This function calculates and updates an UINT8 checksum.
1425 @param Buffer Pointer to buffer to checksum
1426 @param Size Number of bytes to checksum
1427 @param ChecksumOffset Offset to place the checksum result in
1429 @return EFI_SUCCESS The function completed successfully.
1433 AcpiPlatformChecksum (
1436 IN UINTN ChecksumOffset
1444 // Initialize pointer
1449 // set checksum to 0 first
1451 Ptr
[ChecksumOffset
] = 0;
1454 // add all content of buffer
1456 while ((Size
--) != 0) {
1457 Sum
= (UINT8
) (Sum
+ (*Ptr
++));
1463 Ptr
[ChecksumOffset
] = (UINT8
) (0xff - Sum
+ 1);
1470 Checksum all versions of the common tables, RSDP, RSDT, XSDT.
1472 @param AcpiTableInstance Protocol instance private data.
1474 @return EFI_SUCCESS The function completed successfully.
1478 ChecksumCommonTables (
1479 IN OUT EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
1483 // RSDP ACPI 1.0 checksum for 1.0 table. This is only the first 20 bytes of the structure
1485 AcpiPlatformChecksum (
1486 AcpiTableInstance
->Rsdp1
,
1487 sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER
),
1488 OFFSET_OF (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER
,
1493 // RSDP ACPI 1.0 checksum for 2.0/3.0 table. This is only the first 20 bytes of the structure
1495 AcpiPlatformChecksum (
1496 AcpiTableInstance
->Rsdp3
,
1497 sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER
),
1498 OFFSET_OF (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER
,
1503 // RSDP ACPI 2.0/3.0 checksum, this is the entire table
1505 AcpiPlatformChecksum (
1506 AcpiTableInstance
->Rsdp3
,
1507 sizeof (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER
),
1508 OFFSET_OF (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER
,
1515 AcpiPlatformChecksum (
1516 AcpiTableInstance
->Rsdt1
,
1517 AcpiTableInstance
->Rsdt1
->Length
,
1518 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
1522 AcpiPlatformChecksum (
1523 AcpiTableInstance
->Rsdt3
,
1524 AcpiTableInstance
->Rsdt3
->Length
,
1525 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
1532 AcpiPlatformChecksum (
1533 AcpiTableInstance
->Xsdt
,
1534 AcpiTableInstance
->Xsdt
->Length
,
1535 OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER
,
1544 Constructor for the ACPI table protocol. Initializes instance
1547 @param AcpiTableInstance Instance to construct
1549 @return EFI_SUCCESS Instance initialized.
1550 @return EFI_OUT_OF_RESOURCES Unable to allocate required resources.
1554 AcpiTableAcpiTableConstructor (
1555 EFI_ACPI_TABLE_INSTANCE
*AcpiTableInstance
1562 EFI_PHYSICAL_ADDRESS PageAddress
;
1565 // Check for invalid input parameters
1567 ASSERT (AcpiTableInstance
);
1569 InitializeListHead (&AcpiTableInstance
->TableList
);
1570 AcpiTableInstance
->CurrentHandle
= 1;
1572 AcpiTableInstance
->AcpiTableProtocol
.InstallAcpiTable
= InstallAcpiTable
;
1573 AcpiTableInstance
->AcpiTableProtocol
.UninstallAcpiTable
= UninstallAcpiTable
;
1575 // Create RSDP, RSDT, XSDT structures
1576 // Allocate all buffers
1578 TotalSize
= sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER
) +
1579 sizeof (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER
) +
1580 sizeof (EFI_ACPI_DESCRIPTION_HEADER
) + // for ACPI 1.0 RSDT
1581 EFI_ACPI_MAX_NUM_TABLES
* sizeof (UINT32
) +
1582 sizeof (EFI_ACPI_DESCRIPTION_HEADER
) + // for ACPI 2.0/3.0 RSDT
1583 EFI_ACPI_MAX_NUM_TABLES
* sizeof (UINT32
) +
1584 sizeof (EFI_ACPI_DESCRIPTION_HEADER
) + // for ACPI 2.0/3.0 XSDT
1585 EFI_ACPI_MAX_NUM_TABLES
* sizeof (UINT64
);
1588 // Allocate memory in the lower 32 bit of address range for
1589 // compatibility with ACPI 1.0 OS.
1591 // This is done because ACPI 1.0 pointers are 32 bit values.
1592 // ACPI 2.0 OS and all 64 bit OS must use the 64 bit ACPI table addresses.
1593 // There is no architectural reason these should be below 4GB, it is purely
1594 // for convenience of implementation that we force memory below 4GB.
1596 PageAddress
= 0xFFFFFFFF;
1597 Status
= gBS
->AllocatePages (
1599 EfiACPIReclaimMemory
,
1600 EFI_SIZE_TO_PAGES (TotalSize
),
1604 if (EFI_ERROR (Status
)) {
1605 return EFI_OUT_OF_RESOURCES
;
1608 Pointer
= (UINT8
*) (UINTN
) PageAddress
;
1609 ZeroMem (Pointer
, TotalSize
);
1611 AcpiTableInstance
->Rsdp1
= (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER
*) Pointer
;
1612 Pointer
+= sizeof (EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER
);
1613 AcpiTableInstance
->Rsdp3
= (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER
*) Pointer
;
1614 Pointer
+= sizeof (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER
);
1616 AcpiTableInstance
->Rsdt1
= (EFI_ACPI_DESCRIPTION_HEADER
*) Pointer
;
1617 Pointer
+= (sizeof (EFI_ACPI_DESCRIPTION_HEADER
) + EFI_ACPI_MAX_NUM_TABLES
* sizeof (UINT32
));
1618 AcpiTableInstance
->Rsdt3
= (EFI_ACPI_DESCRIPTION_HEADER
*) Pointer
;
1619 Pointer
+= (sizeof (EFI_ACPI_DESCRIPTION_HEADER
) + EFI_ACPI_MAX_NUM_TABLES
* sizeof (UINT32
));
1621 AcpiTableInstance
->Xsdt
= (EFI_ACPI_DESCRIPTION_HEADER
*) Pointer
;
1626 CurrentData
= EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE
;
1627 CopyMem (&AcpiTableInstance
->Rsdp1
->Signature
, &CurrentData
, sizeof (UINT64
));
1628 CopyMem (AcpiTableInstance
->Rsdp1
->OemId
, EFI_ACPI_OEM_ID
, 6);
1629 AcpiTableInstance
->Rsdp1
->Reserved
= EFI_ACPI_RESERVED_BYTE
;
1630 AcpiTableInstance
->Rsdp1
->RsdtAddress
= (UINT32
) (UINTN
) AcpiTableInstance
->Rsdt1
;
1632 CurrentData
= EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE
;
1633 CopyMem (&AcpiTableInstance
->Rsdp3
->Signature
, &CurrentData
, sizeof (UINT64
));
1634 CopyMem (AcpiTableInstance
->Rsdp3
->OemId
, EFI_ACPI_OEM_ID
, 6);
1635 AcpiTableInstance
->Rsdp3
->Revision
= EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION
;
1636 AcpiTableInstance
->Rsdp3
->RsdtAddress
= (UINT32
) (UINTN
) AcpiTableInstance
->Rsdt3
;
1637 AcpiTableInstance
->Rsdp3
->Length
= sizeof (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER
);
1638 CurrentData
= (UINT64
) (UINTN
) AcpiTableInstance
->Xsdt
;
1639 CopyMem (&AcpiTableInstance
->Rsdp3
->XsdtAddress
, &CurrentData
, sizeof (UINT64
));
1640 SetMem (AcpiTableInstance
->Rsdp3
->Reserved
, 3, EFI_ACPI_RESERVED_BYTE
);
1645 // Note that we "reserve" one entry for the FADT so it can always be
1646 // at the beginning of the list of tables. Some OS don't seem
1647 // to find it correctly if it is too far down the list.
1649 AcpiTableInstance
->Rsdt1
->Signature
= EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
;
1650 AcpiTableInstance
->Rsdt1
->Length
= sizeof (EFI_ACPI_DESCRIPTION_HEADER
);
1651 AcpiTableInstance
->Rsdt1
->Revision
= EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION
;
1652 CopyMem (AcpiTableInstance
->Rsdt1
->OemId
, EFI_ACPI_OEM_ID
, 6);
1653 CurrentData
= EFI_ACPI_OEM_TABLE_ID
;
1654 CopyMem (&AcpiTableInstance
->Rsdt1
->OemTableId
, &CurrentData
, sizeof (UINT64
));
1655 AcpiTableInstance
->Rsdt1
->OemRevision
= EFI_ACPI_OEM_REVISION
;
1656 AcpiTableInstance
->Rsdt1
->CreatorId
= EFI_ACPI_CREATOR_ID
;
1657 AcpiTableInstance
->Rsdt1
->CreatorRevision
= EFI_ACPI_CREATOR_REVISION
;
1659 // We always reserve first one for FADT
1661 AcpiTableInstance
->NumberOfTableEntries1
= 1;
1662 AcpiTableInstance
->Rsdt1
->Length
= AcpiTableInstance
->Rsdt1
->Length
+ sizeof(UINT32
);
1664 AcpiTableInstance
->Rsdt3
->Signature
= EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
;
1665 AcpiTableInstance
->Rsdt3
->Length
= sizeof (EFI_ACPI_DESCRIPTION_HEADER
);
1666 AcpiTableInstance
->Rsdt3
->Revision
= EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION
;
1667 CopyMem (AcpiTableInstance
->Rsdt3
->OemId
, EFI_ACPI_OEM_ID
, 6);
1668 CurrentData
= EFI_ACPI_OEM_TABLE_ID
;
1669 CopyMem (&AcpiTableInstance
->Rsdt3
->OemTableId
, &CurrentData
, sizeof (UINT64
));
1670 AcpiTableInstance
->Rsdt3
->OemRevision
= EFI_ACPI_OEM_REVISION
;
1671 AcpiTableInstance
->Rsdt3
->CreatorId
= EFI_ACPI_CREATOR_ID
;
1672 AcpiTableInstance
->Rsdt3
->CreatorRevision
= EFI_ACPI_CREATOR_REVISION
;
1674 // We always reserve first one for FADT
1676 AcpiTableInstance
->NumberOfTableEntries3
= 1;
1677 AcpiTableInstance
->Rsdt3
->Length
= AcpiTableInstance
->Rsdt3
->Length
+ sizeof(UINT32
);
1682 AcpiTableInstance
->Xsdt
->Signature
= EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
;
1683 AcpiTableInstance
->Xsdt
->Length
= sizeof (EFI_ACPI_DESCRIPTION_HEADER
);
1684 AcpiTableInstance
->Xsdt
->Revision
= EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION
;
1685 CopyMem (AcpiTableInstance
->Xsdt
->OemId
, EFI_ACPI_OEM_ID
, 6);
1686 CurrentData
= EFI_ACPI_OEM_TABLE_ID
;
1687 CopyMem (&AcpiTableInstance
->Xsdt
->OemTableId
, &CurrentData
, sizeof (UINT64
));
1688 AcpiTableInstance
->Xsdt
->OemRevision
= EFI_ACPI_OEM_REVISION
;
1689 AcpiTableInstance
->Xsdt
->CreatorId
= EFI_ACPI_CREATOR_ID
;
1690 AcpiTableInstance
->Xsdt
->CreatorRevision
= EFI_ACPI_CREATOR_REVISION
;
1692 // We always reserve first one for FADT
1694 AcpiTableInstance
->Xsdt
->Length
= AcpiTableInstance
->Xsdt
->Length
+ sizeof(UINT64
);
1696 ChecksumCommonTables (AcpiTableInstance
);
1699 // Completed successfully