4 Copyright (c) 2013-2016 Intel Corporation.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Protocol/AcpiTable.h>
11 #include <IndustryStandard/Pci22.h>
12 #include "AcpiPlatform.h"
17 EFI_GLOBAL_NVS_AREA_PROTOCOL mGlobalNvsArea
;
18 EFI_ACPI_SDT_PROTOCOL
*mAcpiSdt
;
20 EFI_ACPI_HANDLE mDsdtHandle
= NULL
;
24 LocateSupportProtocol (
25 IN EFI_GUID
*Protocol
,
33 Locate the first instance of a protocol. If the protocol requested is an
34 FV protocol, then it will return the first FV that contains the ACPI table
39 Protocol The protocol to find.
40 Instance Return pointer to the first instance of the protocol
44 EFI_SUCCESS The function completed successfully.
45 EFI_NOT_FOUND The protocol could not be located.
46 EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
51 EFI_HANDLE
*HandleBuffer
;
52 UINTN NumberOfHandles
;
53 EFI_FV_FILETYPE FileType
;
55 EFI_FV_FILE_ATTRIBUTES Attributes
;
64 Status
= gBS
->LocateHandleBuffer (
71 if (EFI_ERROR (Status
)) {
74 // Defined errors at this time are not found and out of resources.
82 // Looking for FV with ACPI storage file
85 for (i
= 0; i
< NumberOfHandles
; i
++) {
87 // Get the protocol on this handle
88 // This should not fail because of LocateHandleBuffer
90 Status
= gBS
->HandleProtocol (
95 ASSERT_EFI_ERROR (Status
);
99 // Not looking for the FV protocol, so find the first instance of the
100 // protocol. There should not be any errors because our handle buffer
101 // should always contain at least one or LocateHandleBuffer would have
102 // returned not found.
108 // See if it has the ACPI storage file
111 Status
= ((EFI_FIRMWARE_VOLUME2_PROTOCOL
*) (*Instance
))->ReadFile (*Instance
,
112 (EFI_GUID
*)PcdGetPtr (PcdAcpiTableStorageFile
),
121 // If we found it, then we are done
123 if (Status
== EFI_SUCCESS
) {
129 // Our exit status is determined by the success of the previous operations
130 // If the protocol was found, Instance already points to it.
134 // Free any allocated buffers
136 gBS
->FreePool (HandleBuffer
);
144 IN OUT EFI_ACPI_DESCRIPTION_HEADER
*TableHeader
,
145 IN OUT EFI_ACPI_TABLE_VERSION
*Version
151 Update the DSDT table
155 Table - The table to be set
156 Version - Version to publish
172 // Loop through the ASL looking for values that we must fix up.
174 CurrPtr
= (UINT8
*) TableHeader
;
175 for (DsdtPointer
= CurrPtr
;
176 DsdtPointer
<= (CurrPtr
+ ((EFI_ACPI_COMMON_HEADER
*) CurrPtr
)->Length
);
180 Signature
= (UINT32
*) DsdtPointer
;
181 switch (*Signature
) {
183 // MNVS operation region
185 case (SIGNATURE_32 ('M', 'N', 'V', 'S')):
187 // Conditional match. For Region Objects, the Operator will always be the
188 // byte immediately before the specific name. Therefore, subtract 1 to check
191 Operation
= DsdtPointer
- 1;
192 if (*Operation
== AML_OPREGION_OP
) {
193 Address
= (UINT32
*) (DsdtPointer
+ 6);
194 *Address
= (UINT32
) (UINTN
) mGlobalNvsArea
.Area
;
195 Size
= (UINT16
*) (DsdtPointer
+ 11);
196 *Size
= sizeof (EFI_GLOBAL_NVS_AREA
);
201 // Update processor PBLK register I/O base address
203 case (SIGNATURE_32 ('P', 'R', 'I', 'O')):
205 // Conditional match. Update the following ASL code:
206 // Processor (CPU0, 0x01, 0x4F495250, 0x06) {}
207 // The 3rd parameter will be updated to the actual PBLK I/O base address.
210 Operation
= DsdtPointer
- 8;
211 if ((*Operation
== AML_EXT_OP
) && (*(Operation
+ 1) == AML_EXT_PROCESSOR_OP
)) {
212 *(UINT32
*)DsdtPointer
= PcdGet16(PcdPmbaIoBaseAddress
);
224 IN OUT EFI_ACPI_DESCRIPTION_HEADER
*TableHeader
,
225 IN OUT EFI_ACPI_TABLE_VERSION
*Version
231 Update the processors information in the APIC table
235 Table - The table to be set
236 Version - Version to publish
245 EFI_MP_SERVICES_PROTOCOL
*MpService
;
251 UINTN NumberOfEnabledCPUs
;
252 EFI_PROCESSOR_INFORMATION MpContext
;
253 ACPI_APIC_STRUCTURE_PTR
*ApicPtr
;
258 // Find the MP Protocol. This is an MP platform, so MP protocol must be
261 Status
= gBS
->LocateProtocol (
262 &gEfiMpServiceProtocolGuid
,
266 if (EFI_ERROR (Status
)) {
268 // Failed to get MP information, doesn't publish the invalid table
270 *Version
= EFI_ACPI_TABLE_VERSION_NONE
;
275 // Determine the number of processors
277 MpService
->GetNumberOfProcessors (
283 CurrPtr
= (UINT8
*) &(TableHeader
[1]);
284 CurrPtr
= CurrPtr
+ 8; // Size of Local APIC Address & Flag
285 EndPtr
= (UINT8
*) TableHeader
;
286 EndPtr
= EndPtr
+ TableHeader
->Length
;
288 while (CurrPtr
< EndPtr
) {
290 ApicPtr
= (ACPI_APIC_STRUCTURE_PTR
*) CurrPtr
;
291 switch (ApicPtr
->AcpiApicCommon
.Type
) {
293 case EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC
:
294 ApicPtr
->AcpiLocalApic
.Flags
= 0;
295 ApicPtr
->AcpiLocalApic
.ApicId
= 0;
296 Status
= MpService
->GetProcessorInfo (
302 if (!EFI_ERROR (Status
)) {
303 if (MpContext
.StatusFlag
& PROCESSOR_ENABLED_BIT
) {
304 ApicPtr
->AcpiLocalApic
.Flags
= EFI_ACPI_3_0_LOCAL_APIC_ENABLED
;
306 ApicPtr
->AcpiLocalApic
.ApicId
= (UINT8
)MpContext
.ProcessorId
;
311 case EFI_ACPI_1_0_IO_APIC
:
313 // IO APIC entries can be patched here
315 if (CurrIoApic
== 0) {
317 // Update SOC internel IOAPIC base
319 ApicPtr
->AcpiIoApic
.IoApicId
= PcdGet8 (PcdIoApicSettingIoApicId
);
320 ApicPtr
->AcpiIoApic
.IoApicAddress
= (UINT32
)PcdGet64(PcdIoApicBaseAddress
);
321 ApicPtr
->AcpiIoApic
.GlobalSystemInterruptBase
= 0;
324 // Porting is required to update other IOAPIC entries if available
334 CurrPtr
= CurrPtr
+ ApicPtr
->AcpiApicCommon
.Length
;
340 IN OUT EFI_ACPI_DESCRIPTION_HEADER
*TableHeader
,
341 IN OUT EFI_ACPI_TABLE_VERSION
*Version
347 Set the correct table revision upon the setup value
351 Table - The table to be set
352 Version - Version to publish
361 EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE
*FadtHeader1
;
362 EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE
*FadtHeader2
;
363 EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE
*FadtHeader3
;
364 EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE
*AllocationStructurePtr
;
366 if (TableHeader
!= NULL
&& Version
!= NULL
) {
368 *Version
= EFI_ACPI_TABLE_VERSION_1_0B
| EFI_ACPI_TABLE_VERSION_2_0
| EFI_ACPI_TABLE_VERSION_3_0
;
370 // Here we use all 3.0 signature because all version use same signature if they supported
372 switch (TableHeader
->Signature
) {
374 // "APIC" Multiple APIC Description Table
376 case EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE
:
377 ApicTableUpdate (TableHeader
, Version
);
380 // "DSDT" Differentiated System Description Table
382 case EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
:
383 DsdtTableUpdate (TableHeader
, Version
);
387 // "FACP" Fixed ACPI Description Table (FADT)
389 case EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
:
390 *Version
= EFI_ACPI_TABLE_VERSION_NONE
;
391 if (TableHeader
->Revision
== EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION
) {
392 *Version
= EFI_ACPI_TABLE_VERSION_1_0B
;
393 FadtHeader1
= (EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE
*) TableHeader
;
394 FadtHeader1
->SmiCmd
= PcdGet16(PcdSmmActivationPort
);
395 FadtHeader1
->Pm1aEvtBlk
= PcdGet16(PcdPm1blkIoBaseAddress
);
396 FadtHeader1
->Pm1aCntBlk
= PcdGet16(PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
;
397 FadtHeader1
->PmTmrBlk
= PcdGet16(PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1T
;
398 FadtHeader1
->Gpe0Blk
= PcdGet16(PcdGpe0blkIoBaseAddress
);
399 } else if (TableHeader
->Revision
== EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION
) {
400 *Version
= EFI_ACPI_TABLE_VERSION_2_0
;
401 FadtHeader2
= (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE
*) TableHeader
;
402 FadtHeader2
->SmiCmd
= PcdGet16(PcdSmmActivationPort
);
403 FadtHeader2
->Pm1aEvtBlk
= PcdGet16(PcdPm1blkIoBaseAddress
);
404 FadtHeader2
->Pm1aCntBlk
= PcdGet16(PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
;
405 FadtHeader2
->PmTmrBlk
= PcdGet16(PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1T
;
406 FadtHeader2
->Gpe0Blk
= PcdGet16(PcdGpe0blkIoBaseAddress
);
407 FadtHeader2
->XPm1aEvtBlk
.Address
= FadtHeader2
->Pm1aEvtBlk
;
408 FadtHeader2
->XPm1aCntBlk
.Address
= FadtHeader2
->Pm1aCntBlk
;
409 FadtHeader2
->XPmTmrBlk
.Address
= FadtHeader2
->PmTmrBlk
;
410 FadtHeader2
->XGpe0Blk
.Address
= FadtHeader2
->Gpe0Blk
;
411 } else if (TableHeader
->Revision
== EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION
) {
412 *Version
= EFI_ACPI_TABLE_VERSION_3_0
;
413 FadtHeader3
= (EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE
*) TableHeader
;
414 FadtHeader3
->SmiCmd
= PcdGet16(PcdSmmActivationPort
);
415 FadtHeader3
->Pm1aEvtBlk
= PcdGet16(PcdPm1blkIoBaseAddress
);
416 FadtHeader3
->Pm1aCntBlk
= PcdGet16(PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1C
;
417 FadtHeader3
->PmTmrBlk
= PcdGet16(PcdPm1blkIoBaseAddress
) + R_QNC_PM1BLK_PM1T
;
418 FadtHeader3
->Gpe0Blk
= PcdGet16(PcdGpe0blkIoBaseAddress
);
419 FadtHeader3
->XPm1aEvtBlk
.Address
= FadtHeader3
->Pm1aEvtBlk
;
420 FadtHeader3
->XPm1aCntBlk
.Address
= FadtHeader3
->Pm1aCntBlk
;
421 FadtHeader3
->XPmTmrBlk
.Address
= FadtHeader3
->PmTmrBlk
;
422 FadtHeader3
->XGpe0Blk
.Address
= FadtHeader3
->Gpe0Blk
;
426 // "FACS" Firmware ACPI Control Structure
428 case EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE
:
431 // "SSDT" Secondary System Description Table
433 case EFI_ACPI_3_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
:
436 // "HPET" IA-PC High Precision Event Timer Table
438 case EFI_ACPI_3_0_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE
:
440 // If HPET is disabled in setup, don't publish the table.
442 if (mGlobalNvsArea
.Area
->HpetEnable
== 0) {
443 *Version
= EFI_ACPI_TABLE_VERSION_NONE
;
445 ((EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_HEADER
*) TableHeader
)->BaseAddressLower32Bit
.Address
446 = PcdGet64 (PcdHpetBaseAddress
);
449 // "SPCR" Serial Port Concole Redirection Table
451 case EFI_ACPI_3_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE
:
454 // "MCFG" PCI Express Memory Mapped Configuration Space Base Address Description Table
456 case EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE
:
457 AllocationStructurePtr
= (EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE
*)
458 ((UINT8
*)TableHeader
+ sizeof(EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER
));
459 AllocationStructurePtr
->BaseAddress
= PcdGet64(PcdPciExpressBaseAddress
);
461 // Lakeport platform doesn't support the following table
464 // "ECDT" Embedded Controller Boot Resources Table
466 case EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_SIGNATURE:
469 // "PSDT" Persistent System Description Table
471 case EFI_ACPI_3_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE:
474 // "SBST" Smart Battery Specification Table
476 case EFI_ACPI_3_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE:
479 // "SLIT" System Locality Information Table
481 case EFI_ACPI_3_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE:
484 // "SRAT" Static Resource Affinity Table
486 case EFI_ACPI_3_0_STATIC_RESOURCE_AFFINITY_TABLE_SIGNATURE:
489 // "XSDT" Extended System Description Table
491 case EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE:
494 // "BOOT" MS Simple Boot Spec
496 case EFI_ACPI_3_0_SIMPLE_BOOT_FLAG_TABLE_SIGNATURE:
499 // "CPEP" Corrected Platform Error Polling Table
501 case EFI_ACPI_3_0_CORRECTED_PLATFORM_ERROR_POLLING_TABLE_SIGNATURE:
504 // "DBGP" MS Debug Port Spec
506 case EFI_ACPI_3_0_DEBUG_PORT_TABLE_SIGNATURE:
509 // "ETDT" Event Timer Description Table
511 case EFI_ACPI_3_0_EVENT_TIMER_DESCRIPTION_TABLE_SIGNATURE:
514 // "SPMI" Server Platform Management Interface Table
516 case EFI_ACPI_3_0_SERVER_PLATFORM_MANAGEMENT_INTERFACE_TABLE_SIGNATURE:
519 // "TCPA" Trusted Computing Platform Alliance Capabilities Table
521 case EFI_ACPI_3_0_TRUSTED_COMPUTING_PLATFORM_ALLIANCE_CAPABILITIES_TABLE_SIGNATURE:
532 // Entrypoint of Acpi Platform driver
539 // EFI_OUT_OF_RESOURCES
543 AcpiPlatformEntryPoint (
544 IN EFI_HANDLE ImageHandle
,
545 IN EFI_SYSTEM_TABLE
*SystemTable
549 EFI_ACPI_TABLE_PROTOCOL
*AcpiTable
;
550 EFI_FIRMWARE_VOLUME2_PROTOCOL
*FwVol
;
552 EFI_ACPI_COMMON_HEADER
*CurrentTable
;
556 EFI_ACPI_TABLE_VERSION Version
;
559 PCI_DEVICE_INFO
*PciDeviceInfo
;
560 EFI_ACPI_HANDLE PciRootHandle
;
563 PCI_DEVICE_SETTING
*mConfigData
;
565 DEBUG((DEBUG_INFO
, "ACPI Platform start...\n"));
573 // Initialize the EFI Driver Library
576 ASSERT (sizeof (EFI_GLOBAL_NVS_AREA
) == 512);
578 Status
= gBS
->AllocatePool (
580 sizeof (EFI_GLOBAL_NVS_AREA
),
581 (VOID
**)&mGlobalNvsArea
.Area
585 Status
= gBS
->InstallProtocolInterface (
587 &gEfiGlobalNvsAreaProtocolGuid
,
588 EFI_NATIVE_INTERFACE
,
592 ASSERT_EFI_ERROR (Status
);
593 if (!EFI_ERROR (Status
)) {
596 sizeof (EFI_GLOBAL_NVS_AREA
),
602 // Initialize the data. Eventually, this will be controlled by setup options.
604 mGlobalNvsArea
.Area
->HpetEnable
= PcdGetBool (PcdHpetEnable
);
605 mGlobalNvsArea
.Area
->Pm1blkIoBaseAddress
= PcdGet16(PcdPm1blkIoBaseAddress
);
606 mGlobalNvsArea
.Area
->PmbaIoBaseAddress
= PcdGet16(PcdPmbaIoBaseAddress
);
607 mGlobalNvsArea
.Area
->Gpe0blkIoBaseAddress
= PcdGet16(PcdGpe0blkIoBaseAddress
);
608 mGlobalNvsArea
.Area
->GbaIoBaseAddress
= PcdGet16(PcdGbaIoBaseAddress
);
609 mGlobalNvsArea
.Area
->SmbaIoBaseAddress
= PcdGet16(PcdSmbaIoBaseAddress
);
610 mGlobalNvsArea
.Area
->WdtbaIoBaseAddress
= PcdGet16(PcdWdtbaIoBaseAddress
);
611 mGlobalNvsArea
.Area
->HpetBaseAddress
= (UINT32
)PcdGet64(PcdHpetBaseAddress
);
612 mGlobalNvsArea
.Area
->HpetSize
= (UINT32
)PcdGet64(PcdHpetSize
);
613 mGlobalNvsArea
.Area
->PciExpressBaseAddress
= (UINT32
)PcdGet64(PcdPciExpressBaseAddress
);
614 mGlobalNvsArea
.Area
->PciExpressSize
= (UINT32
)PcdGet64(PcdPciExpressSize
);
615 mGlobalNvsArea
.Area
->RcbaMmioBaseAddress
= (UINT32
)PcdGet64(PcdRcbaMmioBaseAddress
);
616 mGlobalNvsArea
.Area
->RcbaMmioSize
= (UINT32
)PcdGet64(PcdRcbaMmioSize
);
617 mGlobalNvsArea
.Area
->IoApicBaseAddress
= (UINT32
)PcdGet64(PcdIoApicBaseAddress
);
618 mGlobalNvsArea
.Area
->IoApicSize
= (UINT32
)PcdGet64(PcdIoApicSize
);
619 mGlobalNvsArea
.Area
->TpmPresent
= (UINT32
)(FALSE
);
620 mGlobalNvsArea
.Area
->DBG2Present
= (UINT32
)(FALSE
);
621 mGlobalNvsArea
.Area
->PlatformType
= (UINT32
)PcdGet16 (PcdPlatformType
);
624 // Configure platform IO expander I2C Slave Address.
626 if (mGlobalNvsArea
.Area
->PlatformType
== Galileo
) {
627 if (PlatformLegacyGpioGetLevel (R_QNC_GPIO_RGLVL_RESUME_WELL
, GALILEO_DETERMINE_IOEXP_SLA_RESUMEWELL_GPIO
)) {
628 mGlobalNvsArea
.Area
->AlternateSla
= FALSE
;
630 mGlobalNvsArea
.Area
->AlternateSla
= TRUE
;
635 // Find the AcpiTable protocol
637 Status
= gBS
->LocateProtocol (&gEfiAcpiTableProtocolGuid
, NULL
, (VOID
**)&AcpiTable
);
638 if (EFI_ERROR (Status
)) {
643 // Initialize MADT table
645 Status
= MadtTableInitialize (&CurrentTable
, &Size
);
646 ASSERT_EFI_ERROR (Status
);
648 // Perform any table specific updates.
650 AcpiUpdateTable ((EFI_ACPI_DESCRIPTION_HEADER
*) CurrentTable
, &Version
);
653 // Update the check sum
654 // It needs to be zeroed before the checksum calculation
656 ((EFI_ACPI_SDT_HEADER
*)CurrentTable
)->Checksum
= 0;
657 ((EFI_ACPI_SDT_HEADER
*)CurrentTable
)->Checksum
=
658 CalculateCheckSum8 ((VOID
*)CurrentTable
, CurrentTable
->Length
);
664 Status
= AcpiTable
->InstallAcpiTable (
667 CurrentTable
->Length
,
670 ASSERT_EFI_ERROR (Status
);
674 // Init Pci Device PRT PRW information structure from PCD
676 mConfigData
= (PCI_DEVICE_SETTING
*)AllocateZeroPool (sizeof (PCI_DEVICE_SETTING
));
677 ASSERT (mConfigData
!= NULL
);
678 InitPciDeviceInfoStructure (mConfigData
);
680 // Get the Acpi SDT protocol for manipulation on acpi table
682 Status
= gBS
->LocateProtocol (&gEfiAcpiSdtProtocolGuid
, NULL
, (VOID
**)&mAcpiSdt
);
683 ASSERT_EFI_ERROR (Status
);
685 // Locate the firmware volume protocol
687 Status
= LocateSupportProtocol (&gEfiFirmwareVolume2ProtocolGuid
, (VOID
**)&FwVol
, 1);
688 if (EFI_ERROR (Status
)) {
692 // Read tables from the storage file.
695 while (Status
== EFI_SUCCESS
) {
697 Status
= FwVol
->ReadSection (
699 (EFI_GUID
*)PcdGetPtr (PcdAcpiTableStorageFile
),
702 (VOID
**)&CurrentTable
,
707 if (!EFI_ERROR(Status
)) {
709 // Perform any table specific updates.
711 AcpiUpdateTable ((EFI_ACPI_DESCRIPTION_HEADER
*) CurrentTable
, &Version
);
714 // Update the check sum
715 // It needs to be zeroed before the checksum calculation
717 ((EFI_ACPI_SDT_HEADER
*)CurrentTable
)->Checksum
= 0;
718 ((EFI_ACPI_SDT_HEADER
*)CurrentTable
)->Checksum
=
719 CalculateCheckSum8 ((VOID
*)CurrentTable
, CurrentTable
->Length
);
725 Status
= AcpiTable
->InstallAcpiTable (
728 ((EFI_ACPI_DESCRIPTION_HEADER
*) CurrentTable
)->Length
,
731 if (EFI_ERROR(Status
)) {
735 // If this table is the DSDT table, then update the _PRT and _PRW based on
736 // the settings from pcds
738 if (CurrentTable
->Signature
== EFI_ACPI_2_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
) {
740 // Create the root handle for DSDT table
742 Status
= mAcpiSdt
->OpenSdt (TableHandle
, &mDsdtHandle
);
743 ASSERT_EFI_ERROR (Status
);
745 PciRootHandle
= NULL
;
746 PciRootHandle
= SdtGetRootBridgeHandle (mAcpiSdt
, mDsdtHandle
);
747 ASSERT (PciRootHandle
!= NULL
);
749 PciDeviceInfo
= NULL
;
750 for (Index
= 0; Index
< mConfigData
->PciDeviceInfoNumber
; Index
++) {
751 PciDeviceInfo
= &(mConfigData
->PciDeviceInfo
[Index
]);
754 // Check whether this is a valid item
756 if ((PciDeviceInfo
->BridgeAddress
!= 0xFFFFFFFF) && (PciDeviceInfo
->DeviceAddress
!= 0xFFFFFFFF)) {
758 //DEBUG ((EFI_D_ERROR, "Valid pci info structure: bridge address:0x%x, device address:0x%x\n", PciDeviceInfo->BridgeAddress, PciDeviceInfo->DeviceAddress));
763 SdtCheckPciDeviceInfoChanged (PciDeviceInfo
, &UpdatePRT
, &UpdatePRW
);
765 // Check whether there is any valid pci routing item
769 // Update the pci routing information
771 //DEBUG ((EFI_D_ERROR, "Update _PRT\n"));
772 SdtUpdatePciRouting (mAcpiSdt
, PciRootHandle
, PciDeviceInfo
);
775 // Check whether there is any valid pci routing item
779 // Update the pci wakeup information
781 //DEBUG ((EFI_D_ERROR, "Update _PRW\n"));
782 SdtUpdatePowerWake (mAcpiSdt
, PciRootHandle
, PciDeviceInfo
);
786 Status
= mAcpiSdt
->Close (PciRootHandle
);
787 ASSERT_EFI_ERROR (Status
);
789 // Mark the root handle as modified , let SDT protocol recaculate the checksum
791 ((EFI_AML_HANDLE
*)mDsdtHandle
)->Modified
= TRUE
;
792 Status
= mAcpiSdt
->Close (mDsdtHandle
);
793 ASSERT_EFI_ERROR (Status
);
796 // Increment the instance
803 gBS
->FreePool (mConfigData
);