diff options
author | Star Zeng <star.zeng@intel.com> | 2018-06-08 16:40:09 +0800 |
---|---|---|
committer | Star Zeng <star.zeng@intel.com> | 2018-09-27 14:25:35 +0800 |
commit | 44c385effde9d0b983713b12f9dd7afbb21712dc (patch) | |
tree | 23701ca3011f90b7aa0a49918de157a065db8efd | |
parent | 2ad0581b1cd49c689a3c2b0362fd4a4e1eb0f04f (diff) | |
download | edk2-44c385effde9d0b983713b12f9dd7afbb21712dc.tar.gz edk2-44c385effde9d0b983713b12f9dd7afbb21712dc.tar.bz2 edk2-44c385effde9d0b983713b12f9dd7afbb21712dc.zip |
PcAtChipsetPkg PcRtc: Use new EfiLocateFirstAcpiTable()
https://bugzilla.tianocore.org/show_bug.cgi?id=967
Request to add a library function for GetAcpiTable() in order
to get ACPI table using signature as input.
After evaluation, we found there are many duplicated code to
find ACPI table by signature in different modules.
This patch updates PcatRealTimeClockRuntimeDxe to use new
EfiLocateFirstAcpiTable() and remove the duplicated code.
Cc: Younas khan <pmdyounaskhan786@gmail.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
-rw-r--r-- | PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 80 |
1 files changed, 3 insertions, 77 deletions
diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c index 2105acf35f..7965eb8aa5 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c @@ -1203,49 +1203,6 @@ IsWithinOneDay ( }
/**
- This function find ACPI table with the specified signature in RSDT or XSDT.
-
- @param Sdt ACPI RSDT or XSDT.
- @param Signature ACPI table signature.
- @param TablePointerSize Size of table pointer: 4 or 8.
-
- @return ACPI table or NULL if not found.
-**/
-VOID *
-ScanTableInSDT (
- IN EFI_ACPI_DESCRIPTION_HEADER *Sdt,
- IN UINT32 Signature,
- IN UINTN TablePointerSize
- )
-{
- UINTN Index;
- UINTN EntryCount;
- UINTN EntryBase;
- EFI_ACPI_DESCRIPTION_HEADER *Table;
-
- EntryCount = (Sdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / TablePointerSize;
-
- EntryBase = (UINTN) (Sdt + 1);
- for (Index = 0; Index < EntryCount; Index++) {
- //
- // When TablePointerSize is 4 while sizeof (VOID *) is 8, make sure the upper 4 bytes are zero.
- //
- Table = 0;
- CopyMem (&Table, (VOID *) (EntryBase + Index * TablePointerSize), TablePointerSize);
-
- if (Table == NULL) {
- continue;
- }
-
- if (Table->Signature == Signature) {
- return Table;
- }
- }
-
- return NULL;
-}
-
-/**
Get the century RTC address from the ACPI FADT table.
@return The century RTC address or 0 if not found.
@@ -1255,42 +1212,11 @@ GetCenturyRtcAddress ( VOID
)
{
- EFI_STATUS Status;
- EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp;
EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
- Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) &Rsdp);
- if (EFI_ERROR (Status)) {
- Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) &Rsdp);
- }
-
- if (EFI_ERROR (Status) || (Rsdp == NULL)) {
- return 0;
- }
-
- Fadt = NULL;
-
- //
- // Find FADT in XSDT
- //
- if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 0) {
- Fadt = ScanTableInSDT (
- (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress,
- EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
- sizeof (UINTN)
- );
- }
-
- //
- // Find FADT in RSDT
- //
- if (Fadt == NULL && Rsdp->RsdtAddress != 0) {
- Fadt = ScanTableInSDT (
- (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress,
- EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
- sizeof (UINT32)
- );
- }
+ Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *) EfiLocateFirstAcpiTable (
+ EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE
+ );
if ((Fadt != NULL) &&
(Fadt->Century > RTC_ADDRESS_REGISTER_D) && (Fadt->Century < 0x80)
|