4 Copyright (c) 2013-2016 Intel Corporation.
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Protocol/AcpiTable.h>
17 #include <IndustryStandard/Pci22.h>
18 #include "AcpiPlatform.h"
23 EFI_GLOBAL_NVS_AREA_PROTOCOL mGlobalNvsArea
;
24 EFI_ACPI_SDT_PROTOCOL
*mAcpiSdt
;
26 EFI_ACPI_HANDLE mDsdtHandle
= NULL
;
30 LocateSupportProtocol (
31 IN EFI_GUID
*Protocol
,
39 Locate the first instance of a protocol. If the protocol requested is an
40 FV protocol, then it will return the first FV that contains the ACPI table
45 Protocol The protocol to find.
46 Instance Return pointer to the first instance of the protocol
50 EFI_SUCCESS The function completed successfully.
51 EFI_NOT_FOUND The protocol could not be located.
52 EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
57 EFI_HANDLE
*HandleBuffer
;
58 UINTN NumberOfHandles
;
59 EFI_FV_FILETYPE FileType
;
61 EFI_FV_FILE_ATTRIBUTES Attributes
;
70 Status
= gBS
->LocateHandleBuffer (
77 if (EFI_ERROR (Status
)) {
80 // Defined errors at this time are not found and out of resources.
88 // Looking for FV with ACPI storage file
91 for (i
= 0; i
< NumberOfHandles
; i
++) {
93 // Get the protocol on this handle
94 // This should not fail because of LocateHandleBuffer
96 Status
= gBS
->HandleProtocol (
101 ASSERT_EFI_ERROR (Status
);
105 // Not looking for the FV protocol, so find the first instance of the
106 // protocol. There should not be any errors because our handle buffer
107 // should always contain at least one or LocateHandleBuffer would have
108 // returned not found.
114 // See if it has the ACPI storage file
117 Status
= ((EFI_FIRMWARE_VOLUME2_PROTOCOL
*) (*Instance
))->ReadFile (*Instance
,
118 (EFI_GUID
*)PcdGetPtr (PcdAcpiTableStorageFile
),
127 // If we found it, then we are done
129 if (Status
== EFI_SUCCESS
) {
135 // Our exit status is determined by the success of the previous operations
136 // If the protocol was found, Instance already points to it.
140 // Free any allocated buffers
142 gBS
->FreePool (HandleBuffer
);
150 IN OUT EFI_ACPI_DESCRIPTION_HEADER
*TableHeader
,
151 IN OUT EFI_ACPI_TABLE_VERSION
*Version
157 Update the DSDT table
161 Table - The table to be set
162 Version - Version to publish
178 // Loop through the ASL looking for values that we must fix up.
180 CurrPtr
= (UINT8
*) TableHeader
;
181 for (DsdtPointer
= CurrPtr
;
182 DsdtPointer
<= (CurrPtr
+ ((EFI_ACPI_COMMON_HEADER
*) CurrPtr
)->Length
);
186 Signature
= (UINT32
*) DsdtPointer
;
187 switch (*Signature
) {
189 // MNVS operation region
191 case (SIGNATURE_32 ('M', 'N', 'V', 'S')):
193 // Conditional match. For Region Objects, the Operator will always be the
194 // byte immediately before the specific name. Therefore, subtract 1 to check
197 Operation
= DsdtPointer
- 1;
198 if (*Operation
== AML_OPREGION_OP
) {
199 Address
= (UINT32
*) (DsdtPointer
+ 6);
200 *Address
= (UINT32
) (UINTN
) mGlobalNvsArea
.Area
;
201 Size
= (UINT16
*) (DsdtPointer
+ 11);
202 *Size
= sizeof (EFI_GLOBAL_NVS_AREA
);
207 // Update processor PBLK register I/O base address
209 case (SIGNATURE_32 ('P', 'R', 'I', 'O')):
211 // Conditional match. Update the following ASL code:
212 // Processor (CPU0, 0x01, 0x4F495250, 0x06) {}
213 // The 3rd parameter will be updated to the actual PBLK I/O base address.
216 Operation
= DsdtPointer
- 8;
217 if ((*Operation
== AML_EXT_OP
) && (*(Operation
+ 1) == AML_EXT_PROCESSOR_OP
)) {
218 *(UINT32
*)DsdtPointer
= PcdGet16(PcdPmbaIoBaseAddress
);
230 IN OUT EFI_ACPI_DESCRIPTION_HEADER
*TableHeader
,
231 IN OUT EFI_ACPI_TABLE_VERSION
*Version
237 Update the processors information in the APIC table
241 Table - The table to be set
242 Version - Version to publish
251 EFI_MP_SERVICES_PROTOCOL
*MpService
;
257 UINTN NumberOfEnabledCPUs
;
258 EFI_PROCESSOR_INFORMATION MpContext
;
259 ACPI_APIC_STRUCTURE_PTR
*ApicPtr
;
264 // Find the MP Protocol. This is an MP platform, so MP protocol must be
267 Status
= gBS
->LocateProtocol (
268 &gEfiMpServiceProtocolGuid
,
272 if (EFI_ERROR (Status
)) {
274 // Failed to get MP information, doesn't publish the invalid table
276 *Version
= EFI_ACPI_TABLE_VERSION_NONE
;
281 // Determine the number of processors
283 MpService
->GetNumberOfProcessors (
289 CurrPtr
= (UINT8
*) &(TableHeader
[1]);
290 CurrPtr
= CurrPtr
+ 8; // Size of Local APIC Address & Flag
291 EndPtr
= (UINT8
*) TableHeader
;
292 EndPtr
= EndPtr
+ TableHeader
->Length
;
294 while (CurrPtr
< EndPtr
) {
296 ApicPtr
= (ACPI_APIC_STRUCTURE_PTR
*) CurrPtr
;
297 switch (ApicPtr
->AcpiApicCommon
.Type
) {
299 case EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC
:
300 ApicPtr
->AcpiLocalApic
.Flags
= 0;
301 ApicPtr
->AcpiLocalApic
.ApicId
= 0;
302 Status
= MpService
->GetProcessorInfo (
308 if (!EFI_ERROR (Status
)) {
309 if (MpContext
.StatusFlag
& PROCESSOR_ENABLED_BIT
) {
310 ApicPtr
->AcpiLocalApic
.Flags
= EFI_ACPI_3_0_LOCAL_APIC_ENABLED
;
312 ApicPtr
->AcpiLocalApic
.ApicId
= (UINT8
)MpContext
.ProcessorId
;
317 case EFI_ACPI_1_0_IO_APIC
:
319 // IO APIC entries can be patched here
321 if (CurrIoApic
== 0) {
323 // Update SOC internel IOAPIC base
325 ApicPtr
->AcpiIoApic
.IoApicId
= PcdGet8 (PcdIoApicSettingIoApicId
);
326 ApicPtr
->AcpiIoApic
.IoApicAddress
= (UINT32
)PcdGet64(PcdIoApicBaseAddress
);
327 ApicPtr
->AcpiIoApic
.GlobalSystemInterruptBase
= 0;
330 // Porting is required to update other IOAPIC entries if available
340 CurrPtr
= CurrPtr
+ ApicPtr
->AcpiApicCommon
.Length
;
346 IN OUT EFI_ACPI_DESCRIPTION_HEADER
*TableHeader
,
347 IN OUT EFI_ACPI_TABLE_VERSION
*Version
353 Set the correct table revision upon the setup value
357 Table - The table to be set
358 Version - Version to publish
367 EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE
*FadtHeader1
;
368 EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE
*FadtHeader2
;
369 EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE
*FadtHeader3
;
370 EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE
*AllocationStructurePtr
;
372 if (TableHeader
!= NULL
&& Version
!= NULL
) {
374 *Version
= EFI_ACPI_TABLE_VERSION_1_0B
| EFI_ACPI_TABLE_VERSION_2_0
| EFI_ACPI_TABLE_VERSION_3_0
;
376 // Here we use all 3.0 signature because all version use same signature if they supported
378 switch (TableHeader
->Signature
) {
380 // "APIC" Multiple APIC Description Table
382 case EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE
:
383 ApicTableUpdate (TableHeader
, Version
);
386 // "DSDT" Differentiated System Description Table
388 case EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
:
389 DsdtTableUpdate (TableHeader
, Version
);
393 // "FACP" Fixed ACPI Description Table (FADT)
395 case EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
:
396 *Version
= EFI_ACPI_TABLE_VERSION_NONE
;
397 if (TableHeader
->Revision
== EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION
) {
398 *Version
= EFI_ACPI_TABLE_VERSION_1_0B
;
399 FadtHeader1
= (EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE
*) TableHeader
;
400 FadtHeader1
->SmiCmd
= PcdGet16(PcdSmmActivationPort
);
401 FadtHeader1
->Pm1aEvtBlk
= PcdGet16(PcdPm1blkIoBaseAddress
);
402 FadtHeader1
->Pm1aCntBlk
= PcdGet16(PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
;
403 FadtHeader1
->PmTmrBlk
= PcdGet16(PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1T
;
404 FadtHeader1
->Gpe0Blk
= PcdGet16(PcdGpe0blkIoBaseAddress
);
405 } else if (TableHeader
->Revision
== EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION
) {
406 *Version
= EFI_ACPI_TABLE_VERSION_2_0
;
407 FadtHeader2
= (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE
*) TableHeader
;
408 FadtHeader2
->SmiCmd
= PcdGet16(PcdSmmActivationPort
);
409 FadtHeader2
->Pm1aEvtBlk
= PcdGet16(PcdPm1blkIoBaseAddress
);
410 FadtHeader2
->Pm1aCntBlk
= PcdGet16(PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
;
411 FadtHeader2
->PmTmrBlk
= PcdGet16(PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1T
;
412 FadtHeader2
->Gpe0Blk
= PcdGet16(PcdGpe0blkIoBaseAddress
);
413 FadtHeader2
->XPm1aEvtBlk
.Address
= FadtHeader2
->Pm1aEvtBlk
;
414 FadtHeader2
->XPm1aCntBlk
.Address
= FadtHeader2
->Pm1aCntBlk
;
415 FadtHeader2
->XPmTmrBlk
.Address
= FadtHeader2
->PmTmrBlk
;
416 FadtHeader2
->XGpe0Blk
.Address
= FadtHeader2
->Gpe0Blk
;
417 } else if (TableHeader
->Revision
== EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION
) {
418 *Version
= EFI_ACPI_TABLE_VERSION_3_0
;
419 FadtHeader3
= (EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE
*) TableHeader
;
420 FadtHeader3
->SmiCmd
= PcdGet16(PcdSmmActivationPort
);
421 FadtHeader3
->Pm1aEvtBlk
= PcdGet16(PcdPm1blkIoBaseAddress
);
422 FadtHeader3
->Pm1aCntBlk
= PcdGet16(PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
;
423 FadtHeader3
->PmTmrBlk
= PcdGet16(PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1T
;
424 FadtHeader3
->Gpe0Blk
= PcdGet16(PcdGpe0blkIoBaseAddress
);
425 FadtHeader3
->XPm1aEvtBlk
.Address
= FadtHeader3
->Pm1aEvtBlk
;
426 FadtHeader3
->XPm1aCntBlk
.Address
= FadtHeader3
->Pm1aCntBlk
;
427 FadtHeader3
->XPmTmrBlk
.Address
= FadtHeader3
->PmTmrBlk
;
428 FadtHeader3
->XGpe0Blk
.Address
= FadtHeader3
->Gpe0Blk
;
432 // "FACS" Firmware ACPI Control Structure
434 case EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE
:
437 // "SSDT" Secondary System Description Table
439 case EFI_ACPI_3_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
:
442 // "HPET" IA-PC High Precision Event Timer Table
444 case EFI_ACPI_3_0_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE
:
446 // If HPET is disabled in setup, don't publish the table.
448 if (mGlobalNvsArea
.Area
->HpetEnable
== 0) {
449 *Version
= EFI_ACPI_TABLE_VERSION_NONE
;
451 ((EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_HEADER
*) TableHeader
)->BaseAddressLower32Bit
.Address
452 = PcdGet64 (PcdHpetBaseAddress
);
455 // "SPCR" Serial Port Concole Redirection Table
457 case EFI_ACPI_3_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE
:
460 // "MCFG" PCI Express Memory Mapped Configuration Space Base Address Description Table
462 case EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE
:
463 AllocationStructurePtr
= (EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE
*)
464 ((UINT8
*)TableHeader
+ sizeof(EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER
));
465 AllocationStructurePtr
->BaseAddress
= PcdGet64(PcdPciExpressBaseAddress
);
467 // Lakeport platform doesn't support the following table
470 // "ECDT" Embedded Controller Boot Resources Table
472 case EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_SIGNATURE:
475 // "PSDT" Persistent System Description Table
477 case EFI_ACPI_3_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE:
480 // "SBST" Smart Battery Specification Table
482 case EFI_ACPI_3_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE:
485 // "SLIT" System Locality Information Table
487 case EFI_ACPI_3_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE:
490 // "SRAT" Static Resource Affinity Table
492 case EFI_ACPI_3_0_STATIC_RESOURCE_AFFINITY_TABLE_SIGNATURE:
495 // "XSDT" Extended System Description Table
497 case EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE:
500 // "BOOT" MS Simple Boot Spec
502 case EFI_ACPI_3_0_SIMPLE_BOOT_FLAG_TABLE_SIGNATURE:
505 // "CPEP" Corrected Platform Error Polling Table
507 case EFI_ACPI_3_0_CORRECTED_PLATFORM_ERROR_POLLING_TABLE_SIGNATURE:
510 // "DBGP" MS Debug Port Spec
512 case EFI_ACPI_3_0_DEBUG_PORT_TABLE_SIGNATURE:
515 // "ETDT" Event Timer Description Table
517 case EFI_ACPI_3_0_EVENT_TIMER_DESCRIPTION_TABLE_SIGNATURE:
520 // "SPMI" Server Platform Management Interface Table
522 case EFI_ACPI_3_0_SERVER_PLATFORM_MANAGEMENT_INTERFACE_TABLE_SIGNATURE:
525 // "TCPA" Trusted Computing Platform Alliance Capabilities Table
527 case EFI_ACPI_3_0_TRUSTED_COMPUTING_PLATFORM_ALLIANCE_CAPABILITIES_TABLE_SIGNATURE:
538 // Entrypoint of Acpi Platform driver
545 // EFI_OUT_OF_RESOURCES
549 AcpiPlatformEntryPoint (
550 IN EFI_HANDLE ImageHandle
,
551 IN EFI_SYSTEM_TABLE
*SystemTable
555 EFI_ACPI_TABLE_PROTOCOL
*AcpiTable
;
556 EFI_FIRMWARE_VOLUME2_PROTOCOL
*FwVol
;
558 EFI_ACPI_COMMON_HEADER
*CurrentTable
;
562 EFI_ACPI_TABLE_VERSION Version
;
565 PCI_DEVICE_INFO
*PciDeviceInfo
;
566 EFI_ACPI_HANDLE PciRootHandle
;
569 PCI_DEVICE_SETTING
*mConfigData
;
571 DEBUG((DEBUG_INFO
, "ACPI Platform start...\n"));
579 // Initialize the EFI Driver Library
582 ASSERT (sizeof (EFI_GLOBAL_NVS_AREA
) == 512);
584 Status
= gBS
->AllocatePool (
586 sizeof (EFI_GLOBAL_NVS_AREA
),
587 (VOID
**)&mGlobalNvsArea
.Area
591 Status
= gBS
->InstallProtocolInterface (
593 &gEfiGlobalNvsAreaProtocolGuid
,
594 EFI_NATIVE_INTERFACE
,
598 ASSERT_EFI_ERROR (Status
);
599 if (!EFI_ERROR (Status
)) {
602 sizeof (EFI_GLOBAL_NVS_AREA
),
608 // Initialize the data. Eventually, this will be controlled by setup options.
610 mGlobalNvsArea
.Area
->HpetEnable
= PcdGetBool (PcdHpetEnable
);
611 mGlobalNvsArea
.Area
->Pm1blkIoBaseAddress
= PcdGet16(PcdPm1blkIoBaseAddress
);
612 mGlobalNvsArea
.Area
->PmbaIoBaseAddress
= PcdGet16(PcdPmbaIoBaseAddress
);
613 mGlobalNvsArea
.Area
->Gpe0blkIoBaseAddress
= PcdGet16(PcdGpe0blkIoBaseAddress
);
614 mGlobalNvsArea
.Area
->GbaIoBaseAddress
= PcdGet16(PcdGbaIoBaseAddress
);
615 mGlobalNvsArea
.Area
->SmbaIoBaseAddress
= PcdGet16(PcdSmbaIoBaseAddress
);
616 mGlobalNvsArea
.Area
->WdtbaIoBaseAddress
= PcdGet16(PcdWdtbaIoBaseAddress
);
617 mGlobalNvsArea
.Area
->HpetBaseAddress
= (UINT32
)PcdGet64(PcdHpetBaseAddress
);
618 mGlobalNvsArea
.Area
->HpetSize
= (UINT32
)PcdGet64(PcdHpetSize
);
619 mGlobalNvsArea
.Area
->PciExpressBaseAddress
= (UINT32
)PcdGet64(PcdPciExpressBaseAddress
);
620 mGlobalNvsArea
.Area
->PciExpressSize
= (UINT32
)PcdGet64(PcdPciExpressSize
);
621 mGlobalNvsArea
.Area
->RcbaMmioBaseAddress
= (UINT32
)PcdGet64(PcdRcbaMmioBaseAddress
);
622 mGlobalNvsArea
.Area
->RcbaMmioSize
= (UINT32
)PcdGet64(PcdRcbaMmioSize
);
623 mGlobalNvsArea
.Area
->IoApicBaseAddress
= (UINT32
)PcdGet64(PcdIoApicBaseAddress
);
624 mGlobalNvsArea
.Area
->IoApicSize
= (UINT32
)PcdGet64(PcdIoApicSize
);
625 mGlobalNvsArea
.Area
->TpmPresent
= (UINT32
)(FALSE
);
626 mGlobalNvsArea
.Area
->DBG2Present
= (UINT32
)(FALSE
);
627 mGlobalNvsArea
.Area
->PlatformType
= (UINT32
)PcdGet16 (PcdPlatformType
);
630 // Configure platform IO expander I2C Slave Address.
632 if (mGlobalNvsArea
.Area
->PlatformType
== Galileo
) {
633 if (PlatformLegacyGpioGetLevel (R_QNC_GPIO_RGLVL_RESUME_WELL
, GALILEO_DETERMINE_IOEXP_SLA_RESUMEWELL_GPIO
)) {
634 mGlobalNvsArea
.Area
->AlternateSla
= FALSE
;
636 mGlobalNvsArea
.Area
->AlternateSla
= TRUE
;
641 // Find the AcpiTable protocol
643 Status
= gBS
->LocateProtocol (&gEfiAcpiTableProtocolGuid
, NULL
, (VOID
**)&AcpiTable
);
644 if (EFI_ERROR (Status
)) {
649 // Initialize MADT table
651 Status
= MadtTableInitialize (&CurrentTable
, &Size
);
652 ASSERT_EFI_ERROR (Status
);
654 // Perform any table specific updates.
656 AcpiUpdateTable ((EFI_ACPI_DESCRIPTION_HEADER
*) CurrentTable
, &Version
);
659 // Update the check sum
660 // It needs to be zeroed before the checksum calculation
662 ((EFI_ACPI_SDT_HEADER
*)CurrentTable
)->Checksum
= 0;
663 ((EFI_ACPI_SDT_HEADER
*)CurrentTable
)->Checksum
=
664 CalculateCheckSum8 ((VOID
*)CurrentTable
, CurrentTable
->Length
);
670 Status
= AcpiTable
->InstallAcpiTable (
673 CurrentTable
->Length
,
676 ASSERT_EFI_ERROR (Status
);
680 // Init Pci Device PRT PRW information structure from PCD
682 mConfigData
= (PCI_DEVICE_SETTING
*)AllocateZeroPool (sizeof (PCI_DEVICE_SETTING
));
683 ASSERT_EFI_ERROR (mConfigData
);
684 InitPciDeviceInfoStructure (mConfigData
);
686 // Get the Acpi SDT protocol for manipulation on acpi table
688 Status
= gBS
->LocateProtocol (&gEfiAcpiSdtProtocolGuid
, NULL
, (VOID
**)&mAcpiSdt
);
689 ASSERT_EFI_ERROR (Status
);
691 // Locate the firmware volume protocol
693 Status
= LocateSupportProtocol (&gEfiFirmwareVolume2ProtocolGuid
, (VOID
**)&FwVol
, 1);
694 if (EFI_ERROR (Status
)) {
698 // Read tables from the storage file.
701 while (Status
== EFI_SUCCESS
) {
703 Status
= FwVol
->ReadSection (
705 (EFI_GUID
*)PcdGetPtr (PcdAcpiTableStorageFile
),
708 (VOID
**)&CurrentTable
,
713 if (!EFI_ERROR(Status
)) {
715 // Perform any table specific updates.
717 AcpiUpdateTable ((EFI_ACPI_DESCRIPTION_HEADER
*) CurrentTable
, &Version
);
720 // Update the check sum
721 // It needs to be zeroed before the checksum calculation
723 ((EFI_ACPI_SDT_HEADER
*)CurrentTable
)->Checksum
= 0;
724 ((EFI_ACPI_SDT_HEADER
*)CurrentTable
)->Checksum
=
725 CalculateCheckSum8 ((VOID
*)CurrentTable
, CurrentTable
->Length
);
731 Status
= AcpiTable
->InstallAcpiTable (
734 ((EFI_ACPI_DESCRIPTION_HEADER
*) CurrentTable
)->Length
,
737 if (EFI_ERROR(Status
)) {
741 // If this table is the DSDT table, then update the _PRT and _PRW based on
742 // the settings from pcds
744 if (CurrentTable
->Signature
== EFI_ACPI_2_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
) {
746 // Create the root handle for DSDT table
748 Status
= mAcpiSdt
->OpenSdt (TableHandle
, &mDsdtHandle
);
749 ASSERT_EFI_ERROR (Status
);
751 PciRootHandle
= NULL
;
752 PciRootHandle
= SdtGetRootBridgeHandle (mAcpiSdt
, mDsdtHandle
);
753 ASSERT (PciRootHandle
!= NULL
);
755 PciDeviceInfo
= NULL
;
756 for (Index
= 0; Index
< mConfigData
->PciDeviceInfoNumber
; Index
++) {
757 PciDeviceInfo
= &(mConfigData
->PciDeviceInfo
[Index
]);
760 // Check whether this is a valid item
762 if ((PciDeviceInfo
->BridgeAddress
!= 0xFFFFFFFF) && (PciDeviceInfo
->DeviceAddress
!= 0xFFFFFFFF)) {
764 //DEBUG ((EFI_D_ERROR, "Valid pci info structure: bridge address:0x%x, device address:0x%x\n", PciDeviceInfo->BridgeAddress, PciDeviceInfo->DeviceAddress));
769 SdtCheckPciDeviceInfoChanged (PciDeviceInfo
, &UpdatePRT
, &UpdatePRW
);
771 // Check whether there is any valid pci routing item
775 // Update the pci routing information
777 //DEBUG ((EFI_D_ERROR, "Update _PRT\n"));
778 SdtUpdatePciRouting (mAcpiSdt
, PciRootHandle
, PciDeviceInfo
);
781 // Check whether there is any valid pci routing item
785 // Update the pci wakeup information
787 //DEBUG ((EFI_D_ERROR, "Update _PRW\n"));
788 SdtUpdatePowerWake (mAcpiSdt
, PciRootHandle
, PciDeviceInfo
);
792 Status
= mAcpiSdt
->Close (PciRootHandle
);
793 ASSERT_EFI_ERROR (Status
);
795 // Mark the root handle as modified , let SDT protocol recaculate the checksum
797 ((EFI_AML_HANDLE
*)mDsdtHandle
)->Modified
= TRUE
;
798 Status
= mAcpiSdt
->Close (mDsdtHandle
);
799 ASSERT_EFI_ERROR (Status
);
802 // Increment the instance
809 gBS
->FreePool (mConfigData
);