17UINTN mEfiAcpiMaxNumTables = EFI_ACPI_MAX_NUM_TABLES;
47 IN EFI_ACPI_TABLE_VERSION Version,
67 IN EFI_ACPI_TABLE_VERSION Version,
120 IN EFI_ACPI_TABLE_VERSION Version
124 UINT32 *CurrentRsdtEntry;
125 VOID *CurrentXsdtEntry;
136 if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
138 *CurrentRsdtEntry = (UINT32)(
UINTN)AcpiTableInstance->Fadt1;
141 *CurrentRsdtEntry = (UINT32)(
UINTN)AcpiTableInstance->Fadt3;
144 if ((Version & ACPI_TABLE_VERSION_GTE_2_0) != 0) {
150 Buffer64 = (UINT64)(
UINTN)AcpiTableInstance->Fadt3;
167 if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
168 Status =
gBS->InstallConfigurationTable (&gEfiAcpi10TableGuid, AcpiTableInstance->Rsdp1);
169 if (EFI_ERROR (Status)) {
174 if ((Version & ACPI_TABLE_VERSION_GTE_2_0) != 0) {
175 Status =
gBS->InstallConfigurationTable (&gEfiAcpiTableGuid, AcpiTableInstance->Rsdp3);
176 if (EFI_ERROR (Status)) {
208 IN VOID *AcpiTableBuffer,
215 VOID *AcpiTableBufferConst;
216 EFI_ACPI_TABLE_VERSION Version;
221 if ( (AcpiTableBuffer ==
NULL) || (TableKey ==
NULL)
224 return EFI_INVALID_PARAMETER;
227 Version =
PcdGet32 (PcdAcpiExposedTableVersions);
232 AcpiTableInstance = EFI_ACPI_TABLE_INSTANCE_FROM_THIS (This);
237 AcpiTableBufferConst =
AllocateCopyPool (AcpiTableBufferSize, AcpiTableBuffer);
241 AcpiTableBufferConst,
247 if (!EFI_ERROR (Status)) {
260 if (!EFI_ERROR (Status)) {
291 EFI_ACPI_TABLE_VERSION Version;
296 AcpiTableInstance = EFI_ACPI_TABLE_INSTANCE_FROM_THIS (This);
298 Version =
PcdGet32 (PcdAcpiExposedTableVersions);
308 if (!EFI_ERROR (Status)) {
315 if (EFI_ERROR (Status)) {
316 return EFI_NOT_FOUND;
336 UINTN NewMaxTableNumber;
349 NewMaxTableNumber = mEfiAcpiMaxNumTables + EFI_ACPI_MAX_NUM_TABLES;
354 NewMaxTableNumber *
sizeof (UINT64);
356 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
358 NewMaxTableNumber *
sizeof (UINT32) +
360 NewMaxTableNumber *
sizeof (UINT32);
379 PageAddress = 0xFFFFFFFF;
380 Status =
gBS->AllocatePages (
382 AcpiAllocateMemoryType,
387 Status =
gBS->AllocatePool (
388 AcpiAllocateMemoryType,
394 if (EFI_ERROR (Status)) {
395 return EFI_OUT_OF_RESOURCES;
399 Pointer = (UINT8 *)(
UINTN)PageAddress;
405 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
416 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
417 AcpiTableInstance->Rsdp1->RsdtAddress = (UINT32)(
UINTN)AcpiTableInstance->Rsdt1;
418 AcpiTableInstance->Rsdp3->RsdtAddress = (UINT32)(
UINTN)AcpiTableInstance->Rsdt3;
421 CurrentData = (UINT64)(
UINTN)AcpiTableInstance->Xsdt;
422 CopyMem (&AcpiTableInstance->Rsdp3->XsdtAddress, &CurrentData, sizeof (UINT64));
427 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
439 mEfiAcpiMaxNumTables *
sizeof (UINT64);
441 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
443 mEfiAcpiMaxNumTables *
sizeof (UINT32) +
445 mEfiAcpiMaxNumTables *
sizeof (UINT32);
453 gBS->FreePool (TempPrivateData.Rsdt1);
459 mEfiAcpiMaxNumTables = NewMaxTableNumber;
475 if (TableEntry->PoolAllocation) {
476 gBS->FreePool (TableEntry->Table);
508 IN EFI_ACPI_TABLE_VERSION Version,
509 IN BOOLEAN IsFromHob,
515 UINT32 CurrentTableSignature;
516 UINT32 CurrentTableSize;
517 UINT32 *CurrentRsdtEntry;
518 VOID *CurrentXsdtEntry;
527 ASSERT (AcpiTableInstance);
540 ASSERT (CurrentTableList);
557 AllocPhysAddress = 0xFFFFFFFF;
558 CurrentTableList->TableSize = CurrentTableSize;
559 CurrentTableList->PoolAllocation =
FALSE;
583 ASSERT ((EFI_PAGE_SIZE % 64) == 0);
585 AllocPhysAddress = (
UINTN)Table;
588 Status =
gBS->AllocatePages (
601 Status =
gBS->AllocatePool (
602 AcpiAllocateMemoryType,
603 CurrentTableList->TableSize,
604 (VOID **)&CurrentTableList->Table
606 CurrentTableList->PoolAllocation =
TRUE;
611 Status =
gBS->AllocatePages (
613 AcpiAllocateMemoryType,
623 if (EFI_ERROR (Status)) {
624 gBS->FreePool (CurrentTableList);
625 return EFI_OUT_OF_RESOURCES;
628 if (!CurrentTableList->PoolAllocation) {
635 CurrentTableList->Signature = EFI_ACPI_TABLE_LIST_SIGNATURE;
636 CopyMem (CurrentTableList->Table, Table, CurrentTableSize);
637 CurrentTableList->Handle = AcpiTableInstance->CurrentHandle++;
638 *Handle = CurrentTableList->Handle;
639 CurrentTableList->Version = Version;
647 switch (CurrentTableSignature) {
659 if ((((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) && (AcpiTableInstance->Fadt1 !=
NULL)) ||
660 (((Version & ACPI_TABLE_VERSION_GTE_2_0) != 0) && (AcpiTableInstance->Fadt3 !=
NULL))
664 gBS->FreePool (CurrentTableList);
665 return EFI_ACCESS_DENIED;
671 if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
680 AcpiTableInstance->Fadt1->FirmwareCtrl = (UINT32)(
UINTN)AcpiTableInstance->Facs1;
681 AcpiTableInstance->Fadt1->Dsdt = (UINT32)(
UINTN)AcpiTableInstance->Dsdt1;
687 &AcpiTableInstance->Rsdp1->OemId,
688 &AcpiTableInstance->Fadt1->Header.OemId,
696 &AcpiTableInstance->Rsdt1->OemId,
697 &AcpiTableInstance->Fadt1->Header.OemId,
702 &AcpiTableInstance->Rsdt1->OemTableId,
703 &AcpiTableInstance->Fadt1->Header.OemTableId,
706 AcpiTableInstance->Rsdt1->OemRevision = AcpiTableInstance->Fadt1->Header.OemRevision;
709 if ((Version & ACPI_TABLE_VERSION_GTE_2_0) != 0) {
720 if ((UINT64)(
UINTN)AcpiTableInstance->Facs3 < BASE_4GB) {
721 AcpiTableInstance->Fadt3->FirmwareCtrl = (UINT32)(
UINTN)AcpiTableInstance->Facs3;
722 ZeroMem (&AcpiTableInstance->Fadt3->XFirmwareCtrl, sizeof (UINT64));
724 Buffer64 = (UINT64)(
UINTN)AcpiTableInstance->Facs3;
726 &AcpiTableInstance->Fadt3->XFirmwareCtrl,
730 AcpiTableInstance->Fadt3->FirmwareCtrl = 0;
733 if ((UINT64)(
UINTN)AcpiTableInstance->Dsdt3 < BASE_4GB) {
734 AcpiTableInstance->Fadt3->Dsdt = (UINT32)(
UINTN)AcpiTableInstance->Dsdt3;
751 Buffer64 = AcpiTableInstance->Fadt3->Dsdt;
753 AcpiTableInstance->Fadt3->Dsdt = 0;
754 Buffer64 = (UINT64)(
UINTN)AcpiTableInstance->Dsdt3;
757 CopyMem (&AcpiTableInstance->Fadt3->XDsdt, &Buffer64, sizeof (UINT64));
763 &AcpiTableInstance->Rsdp3->OemId,
764 &AcpiTableInstance->Fadt3->Header.OemId,
768 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
773 &AcpiTableInstance->Rsdt3->OemId,
774 &AcpiTableInstance->Fadt3->Header.OemId,
778 &AcpiTableInstance->Rsdt3->OemTableId,
779 &AcpiTableInstance->Fadt3->Header.OemTableId,
782 AcpiTableInstance->Rsdt3->OemRevision = AcpiTableInstance->Fadt3->Header.OemRevision;
789 &AcpiTableInstance->Xsdt->OemId,
790 &AcpiTableInstance->Fadt3->Header.OemId,
794 &AcpiTableInstance->Xsdt->OemTableId,
795 &AcpiTableInstance->Fadt3->Header.OemTableId,
798 AcpiTableInstance->Xsdt->OemRevision = AcpiTableInstance->Fadt3->Header.OemRevision;
806 CurrentTableList->Table,
807 CurrentTableList->Table->Length,
821 if ((((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) && (AcpiTableInstance->Facs1 !=
NULL)) ||
822 (((Version & ACPI_TABLE_VERSION_GTE_2_0) != 0) && (AcpiTableInstance->Facs3 !=
NULL))
826 gBS->FreePool (CurrentTableList);
827 return EFI_ACCESS_DENIED;
838 if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
847 if (AcpiTableInstance->Fadt1 !=
NULL) {
848 AcpiTableInstance->Fadt1->FirmwareCtrl = (UINT32)(
UINTN)AcpiTableInstance->Facs1;
854 AcpiTableInstance->Fadt1,
855 AcpiTableInstance->Fadt1->Header.Length,
864 if ((Version & ACPI_TABLE_VERSION_GTE_2_0) != 0) {
873 if (AcpiTableInstance->Fadt3 !=
NULL) {
878 if ((UINT64)(
UINTN)AcpiTableInstance->Facs3 < BASE_4GB) {
879 AcpiTableInstance->Fadt3->FirmwareCtrl = (UINT32)(
UINTN)AcpiTableInstance->Facs3;
880 ZeroMem (&AcpiTableInstance->Fadt3->XFirmwareCtrl, sizeof (UINT64));
882 Buffer64 = (UINT64)(
UINTN)AcpiTableInstance->Facs3;
884 &AcpiTableInstance->Fadt3->XFirmwareCtrl,
888 AcpiTableInstance->Fadt3->FirmwareCtrl = 0;
895 AcpiTableInstance->Fadt3,
896 AcpiTableInstance->Fadt3->Header.Length,
911 if ((((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) && (AcpiTableInstance->Dsdt1 !=
NULL)) ||
912 (((Version & ACPI_TABLE_VERSION_GTE_2_0) != 0) && (AcpiTableInstance->Dsdt3 !=
NULL))
916 gBS->FreePool (CurrentTableList);
917 return EFI_ACCESS_DENIED;
928 if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
937 if (AcpiTableInstance->Fadt1 !=
NULL) {
938 AcpiTableInstance->Fadt1->Dsdt = (UINT32)(
UINTN)AcpiTableInstance->Dsdt1;
944 AcpiTableInstance->Fadt1,
945 AcpiTableInstance->Fadt1->Header.Length,
954 if ((Version & ACPI_TABLE_VERSION_GTE_2_0) != 0) {
963 if (AcpiTableInstance->Fadt3 !=
NULL) {
964 if ((UINT64)(
UINTN)AcpiTableInstance->Dsdt3 < BASE_4GB) {
965 AcpiTableInstance->Fadt3->Dsdt = (UINT32)(
UINTN)AcpiTableInstance->Dsdt3;
982 Buffer64 = AcpiTableInstance->Fadt3->Dsdt;
984 AcpiTableInstance->Fadt3->Dsdt = 0;
985 Buffer64 = (UINT64)(
UINTN)AcpiTableInstance->Dsdt3;
988 CopyMem (&AcpiTableInstance->Fadt3->XDsdt, &Buffer64, sizeof (UINT64));
994 AcpiTableInstance->Fadt3,
995 AcpiTableInstance->Fadt3->Header.Length,
1009 CurrentTableList->Table,
1010 CurrentTableList->Table->Length,
1026 CurrentTableList->Table,
1027 CurrentTableList->Table->Length,
1041 InsertTailList (&AcpiTableInstance->TableList, &CurrentTableList->Link);
1049 if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
1054 if (AcpiTableInstance->NumberOfTableEntries1 >= mEfiAcpiMaxNumTables) {
1059 CurrentRsdtEntry = (UINT32 *)
1061 (UINT8 *)AcpiTableInstance->Rsdt1 +
1063 AcpiTableInstance->NumberOfTableEntries1 *
1070 *CurrentRsdtEntry = (UINT32)(
UINTN)CurrentTableList->Table;
1075 AcpiTableInstance->Rsdt1->Length = AcpiTableInstance->Rsdt1->Length +
sizeof (UINT32);
1077 AcpiTableInstance->NumberOfTableEntries1++;
1084 if ((Version & ACPI_TABLE_VERSION_GTE_2_0) != 0) {
1089 if (AcpiTableInstance->NumberOfTableEntries3 >= mEfiAcpiMaxNumTables) {
1094 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
1099 CurrentRsdtEntry = (UINT32 *)
1101 (UINT8 *)AcpiTableInstance->Rsdt3 +
1103 AcpiTableInstance->NumberOfTableEntries3 *
1110 *CurrentRsdtEntry = (UINT32)(
UINTN)CurrentTableList->Table;
1115 AcpiTableInstance->Rsdt3->Length = AcpiTableInstance->Rsdt3->Length +
sizeof (UINT32);
1122 CurrentXsdtEntry = (VOID *)
1124 (UINT8 *)AcpiTableInstance->Xsdt +
1126 AcpiTableInstance->NumberOfTableEntries3 *
1134 Buffer64 = (UINT64)(
UINTN)CurrentTableList->Table;
1144 AcpiTableInstance->Xsdt->Length = AcpiTableInstance->Xsdt->Length +
sizeof (UINT64);
1146 AcpiTableInstance->NumberOfTableEntries3++;
1185 CurrentLink = TableList->ForwardLink;
1187 while (CurrentLink != TableList) {
1188 CurrentTable = EFI_ACPI_TABLE_LIST_FROM_LINK (CurrentLink);
1189 if (CurrentTable->Handle == Handle) {
1193 *Table = CurrentTable;
1197 CurrentLink = CurrentLink->ForwardLink;
1203 return EFI_NOT_FOUND;
1228 UINT32 *CurrentRsdtEntry;
1229 VOID *CurrentXsdtEntry;
1230 UINT64 CurrentTablePointer64;
1237 ASSERT (NumberOfTableEntries);
1238 ASSERT (Rsdt || Xsdt);
1243 for (Index = 0; Index < *NumberOfTableEntries; Index++) {
1251 CurrentRsdtEntry =
NULL;
1264 CopyMem (&CurrentTablePointer64, CurrentXsdtEntry,
sizeof (UINT64));
1269 CurrentXsdtEntry = 0;
1270 CurrentTablePointer64 = 0;
1276 if (((Rsdt ==
NULL) || (*CurrentRsdtEntry == (UINT32)(
UINTN)Table->Table)) &&
1277 ((Xsdt ==
NULL) || (CurrentTablePointer64 == (UINT64)(
UINTN)Table->Table))
1284 CopyMem (CurrentRsdtEntry, CurrentRsdtEntry + 1, (*NumberOfTableEntries - Index - 1) *
sizeof (UINT32));
1286 Rsdt->Length = Rsdt->Length -
sizeof (UINT32);
1290 CopyMem (CurrentXsdtEntry, ((UINT64 *)CurrentXsdtEntry) + 1, (*NumberOfTableEntries - Index - 1) *
sizeof (UINT64));
1292 Xsdt->Length = Xsdt->Length -
sizeof (UINT64);
1296 }
else if (Index + 1 == *NumberOfTableEntries) {
1300 return EFI_INVALID_PARAMETER;
1332 (*NumberOfTableEntries)--;
1350 IN EFI_ACPI_TABLE_VERSION Version,
1354 UINT32 CurrentTableSignature;
1355 BOOLEAN RemoveFromRsdt;
1360 ASSERT (AcpiTableInstance);
1366 RemoveFromRsdt =
TRUE;
1370 ASSERT (Table->Table !=
NULL);
1391 RemoveFromRsdt =
FALSE;
1400 RemoveFromRsdt =
FALSE;
1406 if (Table->Table !=
NULL) {
1410 if (Version & EFI_ACPI_TABLE_VERSION_NONE & Table->Version) {
1414 Table->Version = Table->Version &~EFI_ACPI_TABLE_VERSION_NONE;
1417 if (Version & EFI_ACPI_TABLE_VERSION_1_0B & Table->Version) {
1421 Table->Version = Table->Version &~EFI_ACPI_TABLE_VERSION_1_0B;
1428 if (RemoveFromRsdt) {
1431 &AcpiTableInstance->NumberOfTableEntries1,
1432 AcpiTableInstance->Rsdt1,
1438 if (Version & ACPI_TABLE_VERSION_GTE_2_0 & Table->Version) {
1442 Table->Version = Table->Version &~(Version & ACPI_TABLE_VERSION_GTE_2_0);
1449 if (RemoveFromRsdt) {
1452 &AcpiTableInstance->NumberOfTableEntries3,
1453 AcpiTableInstance->Rsdt3,
1454 AcpiTableInstance->Xsdt
1462 switch (Table->Table->Signature) {
1464 if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
1465 AcpiTableInstance->Fadt1 =
NULL;
1468 if ((Version & ACPI_TABLE_VERSION_GTE_2_0) != 0) {
1469 AcpiTableInstance->Fadt3 =
NULL;
1475 if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
1476 AcpiTableInstance->Facs1 =
NULL;
1481 if (AcpiTableInstance->Fadt1 !=
NULL) {
1482 AcpiTableInstance->Fadt1->FirmwareCtrl = 0;
1488 AcpiTableInstance->Fadt1,
1489 AcpiTableInstance->Fadt1->Header.Length,
1498 if ((Version & ACPI_TABLE_VERSION_GTE_2_0) != 0) {
1499 AcpiTableInstance->Facs3 =
NULL;
1504 if (AcpiTableInstance->Fadt3 !=
NULL) {
1505 AcpiTableInstance->Fadt3->FirmwareCtrl = 0;
1506 ZeroMem (&AcpiTableInstance->Fadt3->XFirmwareCtrl, sizeof (UINT64));
1512 AcpiTableInstance->Fadt3,
1513 AcpiTableInstance->Fadt3->Header.Length,
1525 if ((Version & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
1526 AcpiTableInstance->Dsdt1 =
NULL;
1531 if (AcpiTableInstance->Fadt1 !=
NULL) {
1532 AcpiTableInstance->Fadt1->Dsdt = 0;
1538 AcpiTableInstance->Fadt1,
1539 AcpiTableInstance->Fadt1->Header.Length,
1548 if ((Version & ACPI_TABLE_VERSION_GTE_2_0) != 0) {
1549 AcpiTableInstance->Dsdt3 =
NULL;
1554 if (AcpiTableInstance->Fadt3 !=
NULL) {
1555 AcpiTableInstance->Fadt3->Dsdt = 0;
1556 ZeroMem (&AcpiTableInstance->Fadt3->XDsdt, sizeof (UINT64));
1562 AcpiTableInstance->Fadt3,
1563 AcpiTableInstance->Fadt3->Header.Length,
1585 if (Table->Version == 0) {
1591 gBS->FreePool (Table);
1615 IN EFI_ACPI_TABLE_VERSION Version,
1627 ASSERT (AcpiTableInstance);
1634 &AcpiTableInstance->TableList,
1637 if (EFI_ERROR (Status)) {
1638 return EFI_NOT_FOUND;
1644 Status =
DeleteTable (AcpiTableInstance, Version, Table);
1645 if (EFI_ERROR (Status)) {
1684 Ptr[ChecksumOffset] = 0;
1689 while ((Size--) != 0) {
1690 Sum = (UINT8)(Sum + (*Ptr++));
1697 Ptr[ChecksumOffset] = (UINT8)(0xff - Sum + 1);
1718 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
1720 AcpiTableInstance->Rsdp1,
1733 AcpiTableInstance->Rsdp3,
1745 AcpiTableInstance->Rsdp3,
1753 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
1758 AcpiTableInstance->Rsdt1,
1759 AcpiTableInstance->Rsdt1->Length,
1767 AcpiTableInstance->Rsdt3,
1768 AcpiTableInstance->Rsdt3->Length,
1780 AcpiTableInstance->Xsdt,
1781 AcpiTableInstance->Xsdt->Length,
1807 EFI_ACPI_TABLE_VERSION Version;
1811 UINT64 ChildTableAddress;
1818 VOID *TableToInstall;
1823 Version =
PcdGet32 (PcdAcpiExposedTableVersions);
1829 if (GuidHob ==
NULL) {
1830 return EFI_NOT_FOUND;
1835 return EFI_NOT_FOUND;
1838 if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_ACPI_TABLE_REVISION) {
1847 return EFI_NOT_FOUND;
1856 ASSERT ((
UINTN)Rsdp->XsdtAddress == Rsdp->XsdtAddress);
1858 EntrySize =
sizeof (UINT64);
1865 EntrySize =
sizeof (UINT32);
1874 for (Index = 0; Index < Count; Index++) {
1875 ChildTableAddress = 0;
1876 CopyMem (&ChildTableAddress, (UINT8 *)(Rsdt + 1) + EntrySize * Index, EntrySize);
1881 ASSERT (ChildTableAddress == (
UINTN)ChildTableAddress);
1882 if (ChildTableAddress != (
UINTN)ChildTableAddress) {
1883 Status = EFI_ABORTED;
1889 if (EFI_ERROR (Status)) {
1890 DEBUG ((DEBUG_ERROR,
"InstallAcpiTableFromHob: Fail to add ACPI table at 0x%p\n", ChildTable));
1902 if (EFI_ERROR (Status)) {
1903 DEBUG ((DEBUG_ERROR,
"InstallAcpiTableFromHob: Fail to add ACPI table FACS\n"));
1918 DEBUG ((DEBUG_ERROR,
"DSDT table not found\n"));
1923 if (EFI_ERROR (Status)) {
1924 DEBUG ((DEBUG_ERROR,
"InstallAcpiTableFromHob: Fail to add ACPI table DSDT\n"));
1931 return EFI_NOT_FOUND;
1934 if (EFI_ERROR (Status)) {
1972 UINTN NumOfTblEntries;
1974 DEBUG ((DEBUG_INFO,
"InstallAcpiTableFromAcpiSiliconHob\n"));
1978 SiAcpiHobRsdp =
NULL;
1979 SiCommonAcpiTable =
NULL;
1980 AcpiSiliconHob = GET_GUID_HOB_DATA (GuidHob);
1986 if (SiAcpiHobRsdp ==
NULL) {
1987 DEBUG ((DEBUG_ERROR,
"InstallAcpiTableFromAcpiSiliconHob: Fail to locate RSDP Acpi table!!\n"));
1988 return EFI_NOT_FOUND;
1991 DEBUG ((DEBUG_INFO,
"Silicon ACPI RSDP address : 0x%lx\n", SiAcpiHobRsdp));
1992 AcpiTableInstance->Rsdp3 = SiAcpiHobRsdp;
1994 if (SiAcpiHobRsdp->RsdtAddress != 0x00000000) {
1998 TempBuffer = (UINT8 *)(
UINTN)(SiAcpiHobRsdp->RsdtAddress);
2000 AcpiTableInstance->Rsdt3 = SiCommonAcpiTable;
2003 DEBUG ((DEBUG_ERROR,
"RSDT length is incorrect\n"));
2011 AcpiTableInstance->NumberOfTableEntries1 = NumOfTblEntries;
2012 DEBUG ((DEBUG_INFO,
"32bit NumOfTblEntries : 0x%x\n", NumOfTblEntries));
2016 if (AcpiTableInstance->NumberOfTableEntries1 >= EFI_ACPI_MAX_NUM_TABLES) {
2017 mEfiAcpiMaxNumTables = AcpiTableInstance->NumberOfTableEntries1 + EFI_ACPI_MAX_NUM_TABLES;
2018 DEBUG ((DEBUG_ERROR,
"mEfiAcpiMaxNumTables : 0x%x\n", mEfiAcpiMaxNumTables));
2024 TempBuffer = (UINT8 *)(
UINTN)(SiAcpiHobRsdp->XsdtAddress);
2026 AcpiTableInstance->Xsdt = SiCommonAcpiTable;
2029 DEBUG ((DEBUG_ERROR,
"XSDT length is incorrect\n"));
2037 AcpiTableInstance->NumberOfTableEntries3 = NumOfTblEntries;
2038 DEBUG ((DEBUG_ERROR,
"64bit NumOfTblEntries : 0x%x\n", NumOfTblEntries));
2042 if (AcpiTableInstance->NumberOfTableEntries3 >= EFI_ACPI_MAX_NUM_TABLES) {
2043 mEfiAcpiMaxNumTables = AcpiTableInstance->NumberOfTableEntries3 + EFI_ACPI_MAX_NUM_TABLES;
2044 DEBUG ((DEBUG_ERROR,
"mEfiAcpiMaxNumTables : 0x%x\n", mEfiAcpiMaxNumTables));
2069 UINTN RsdpTableSize;
2078 ASSERT (AcpiTableInstance);
2084 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
2091 AcpiTableInstance->CurrentHandle = 1;
2104 if (GuidHob !=
NULL) {
2107 DEBUG ((DEBUG_INFO,
"Installed ACPI Table from AcpiSiliconHob.\n"));
2110 DEBUG ((DEBUG_ERROR,
"Fail to Installed ACPI Table from AcpiSiliconHob!!\n"));
2114 DEBUG ((DEBUG_INFO,
"Fail to locate AcpiSiliconHob!!\n"));
2121 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
2132 PageAddress = 0xFFFFFFFF;
2133 Status =
gBS->AllocatePages (
2134 mAcpiTableAllocType,
2135 AcpiAllocateMemoryType,
2140 Status =
gBS->AllocatePool (
2141 AcpiAllocateMemoryType,
2147 if (EFI_ERROR (Status)) {
2148 return EFI_OUT_OF_RESOURCES;
2152 Pointer = (UINT8 *)(
UINTN)PageAddress;
2155 ZeroMem (Pointer, RsdpTableSize);
2158 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
2168 mEfiAcpiMaxNumTables *
sizeof (UINT64);
2170 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
2172 mEfiAcpiMaxNumTables *
sizeof (UINT32) +
2174 mEfiAcpiMaxNumTables *
sizeof (UINT32);
2187 PageAddress = 0xFFFFFFFF;
2188 Status =
gBS->AllocatePages (
2189 mAcpiTableAllocType,
2190 AcpiAllocateMemoryType,
2195 Status =
gBS->AllocatePool (
2196 AcpiAllocateMemoryType,
2202 if (EFI_ERROR (Status)) {
2209 gBS->FreePool (AcpiTableInstance->Rsdp1);
2212 return EFI_OUT_OF_RESOURCES;
2216 Pointer = (UINT8 *)(
UINTN)PageAddress;
2222 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
2233 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
2235 CopyMem (&AcpiTableInstance->Rsdp1->Signature, &CurrentData, sizeof (UINT64));
2236 CopyMem (AcpiTableInstance->Rsdp1->OemId,
PcdGetPtr (PcdAcpiDefaultOemId),
sizeof (AcpiTableInstance->Rsdp1->OemId));
2237 AcpiTableInstance->Rsdp1->Reserved = EFI_ACPI_RESERVED_BYTE;
2238 AcpiTableInstance->Rsdp1->RsdtAddress = (UINT32)(
UINTN)AcpiTableInstance->Rsdt1;
2242 CopyMem (&AcpiTableInstance->Rsdp3->Signature, &CurrentData, sizeof (UINT64));
2243 CopyMem (AcpiTableInstance->Rsdp3->OemId,
PcdGetPtr (PcdAcpiDefaultOemId),
sizeof (AcpiTableInstance->Rsdp3->OemId));
2246 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
2247 AcpiTableInstance->Rsdp3->RsdtAddress = (UINT32)(
UINTN)AcpiTableInstance->Rsdt3;
2250 CurrentData = (UINT64)(
UINTN)AcpiTableInstance->Xsdt;
2251 CopyMem (&AcpiTableInstance->Rsdp3->XsdtAddress, &CurrentData, sizeof (UINT64));
2252 SetMem (AcpiTableInstance->Rsdp3->Reserved, 3, EFI_ACPI_RESERVED_BYTE);
2254 if ((
PcdGet32 (PcdAcpiExposedTableVersions) & EFI_ACPI_TABLE_VERSION_1_0B) != 0) {
2265 CopyMem (AcpiTableInstance->Rsdt1->OemId,
PcdGetPtr (PcdAcpiDefaultOemId),
sizeof (AcpiTableInstance->Rsdt1->OemId));
2266 CurrentData =
PcdGet64 (PcdAcpiDefaultOemTableId);
2267 CopyMem (&AcpiTableInstance->Rsdt1->OemTableId, &CurrentData, sizeof (UINT64));
2268 AcpiTableInstance->Rsdt1->OemRevision =
PcdGet32 (PcdAcpiDefaultOemRevision);
2269 AcpiTableInstance->Rsdt1->CreatorId =
PcdGet32 (PcdAcpiDefaultCreatorId);
2270 AcpiTableInstance->Rsdt1->CreatorRevision =
PcdGet32 (PcdAcpiDefaultCreatorRevision);
2274 AcpiTableInstance->NumberOfTableEntries1 = 1;
2275 AcpiTableInstance->Rsdt1->Length = AcpiTableInstance->Rsdt1->Length +
sizeof (UINT32);
2280 CopyMem (AcpiTableInstance->Rsdt3->OemId,
PcdGetPtr (PcdAcpiDefaultOemId),
sizeof (AcpiTableInstance->Rsdt3->OemId));
2281 CurrentData =
PcdGet64 (PcdAcpiDefaultOemTableId);
2282 CopyMem (&AcpiTableInstance->Rsdt3->OemTableId, &CurrentData, sizeof (UINT64));
2283 AcpiTableInstance->Rsdt3->OemRevision =
PcdGet32 (PcdAcpiDefaultOemRevision);
2284 AcpiTableInstance->Rsdt3->CreatorId =
PcdGet32 (PcdAcpiDefaultCreatorId);
2285 AcpiTableInstance->Rsdt3->CreatorRevision =
PcdGet32 (PcdAcpiDefaultCreatorRevision);
2289 AcpiTableInstance->Rsdt3->Length = AcpiTableInstance->Rsdt3->Length +
sizeof (UINT32);
2292 AcpiTableInstance->NumberOfTableEntries3 = 1;
2300 CopyMem (AcpiTableInstance->Xsdt->OemId,
PcdGetPtr (PcdAcpiDefaultOemId),
sizeof (AcpiTableInstance->Xsdt->OemId));
2301 CurrentData =
PcdGet64 (PcdAcpiDefaultOemTableId);
2302 CopyMem (&AcpiTableInstance->Xsdt->OemTableId, &CurrentData, sizeof (UINT64));
2303 AcpiTableInstance->Xsdt->OemRevision =
PcdGet32 (PcdAcpiDefaultOemRevision);
2304 AcpiTableInstance->Xsdt->CreatorId =
PcdGet32 (PcdAcpiDefaultCreatorId);
2305 AcpiTableInstance->Xsdt->CreatorRevision =
PcdGet32 (PcdAcpiDefaultCreatorRevision);
2309 AcpiTableInstance->Xsdt->Length = AcpiTableInstance->Xsdt->Length +
sizeof (UINT64);
#define EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE
#define EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
#define EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
#define EFI_ACPI_1_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
#define EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION
#define EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE
#define EFI_ACPI_2_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
#define EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE
#define EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION
#define EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
#define EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
#define EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE
#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE
#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION
#define EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION
ACPISpec (Revision 3.0b) says current value is 2.
#define EFI_ACPI_4_0_UEFI_ACPI_DATA_TABLE_SIGNATURE
VOID SdtAcpiTableAcpiSdtConstructor(IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance)
VOID SdtNotifyAcpiList(IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance, IN EFI_ACPI_TABLE_VERSION Version, IN UINTN Handle)
EFI_STATUS SdtGetAcpiTable(IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance, IN UINTN Index, OUT EFI_ACPI_SDT_HEADER **Table, OUT EFI_ACPI_TABLE_VERSION *Version, OUT UINTN *TableKey)
EFI_STATUS ChecksumCommonTables(IN OUT EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance)
EFI_STATUS InstallAcpiTableFromAcpiSiliconHob(EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance, EFI_HOB_GUID_TYPE *GuidHob)
EFI_STATUS FindTableByHandle(IN UINTN Handle, IN LIST_ENTRY *TableList, OUT EFI_ACPI_TABLE_LIST **Table)
EFI_STATUS AddTableToList(IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance, IN VOID *Table, IN BOOLEAN Checksum, IN EFI_ACPI_TABLE_VERSION Version, IN BOOLEAN IsFromHob, OUT UINTN *Handle)
EFI_STATUS RemoveTableFromList(IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance, IN EFI_ACPI_TABLE_VERSION Version, IN UINTN Handle)
EFI_STATUS ReallocateAcpiTableBuffer(IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance)
EFI_STATUS EFIAPI InstallAcpiTable(IN EFI_ACPI_TABLE_PROTOCOL *This, IN VOID *AcpiTableBuffer, IN UINTN AcpiTableBufferSize, OUT UINTN *TableKey)
EFI_STATUS EFIAPI UninstallAcpiTable(IN EFI_ACPI_TABLE_PROTOCOL *This, IN UINTN TableKey)
EFI_STATUS DeleteTable(IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance, IN EFI_ACPI_TABLE_VERSION Version, IN OUT EFI_ACPI_TABLE_LIST *Table)
EFI_STATUS RemoveTableFromRsdt(IN OUT EFI_ACPI_TABLE_LIST *Table, IN OUT UINTN *NumberOfTableEntries, IN OUT EFI_ACPI_DESCRIPTION_HEADER *Rsdt OPTIONAL, IN OUT EFI_ACPI_DESCRIPTION_HEADER *Xsdt OPTIONAL)
EFI_STATUS EFIAPI PublishTables(IN EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance, IN EFI_ACPI_TABLE_VERSION Version)
EFI_STATUS AcpiTableAcpiTableConstructor(EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance)
EFI_STATUS InstallAcpiTableFromHob(EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance)
EFI_STATUS AcpiPlatformChecksum(IN VOID *Buffer, IN UINTN Size, IN UINTN ChecksumOffset)
STATIC VOID FreeTableMemory(EFI_ACPI_TABLE_LIST *TableEntry)
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define OFFSET_OF(TYPE, Field)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdGet64(TokenName)
#define PcdGet32(TokenName)
#define PcdGetBool(TokenName)
#define PcdGetPtr(TokenName)
#define FeaturePcdGet(TokenName)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_SIZE_TO_PAGES(Size)
#define UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD(TYPE, Field)