mirror of https://github.com/acidanthera/audk.git
ShellPkg DpDynamicCommand: 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 DpDynamicCommand 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> Cc: Dandan Bi <dandan.bi@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>
This commit is contained in:
parent
44c385effd
commit
cb6fe7bb8b
|
@ -117,116 +117,6 @@ DumpStatistics( void )
|
|||
SHELL_FREE_NON_NULL (StringPtrUnknown);
|
||||
}
|
||||
|
||||
/**
|
||||
This function scan ACPI table in RSDT.
|
||||
|
||||
@param Rsdt ACPI RSDT
|
||||
@param Signature ACPI table signature
|
||||
|
||||
@return ACPI table
|
||||
**/
|
||||
VOID *
|
||||
ScanTableInRSDT (
|
||||
IN RSDT_TABLE *Rsdt,
|
||||
IN UINT32 Signature
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINT32 EntryCount;
|
||||
UINT32 *EntryPtr;
|
||||
EFI_ACPI_DESCRIPTION_HEADER *Table;
|
||||
|
||||
EntryCount = (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32);
|
||||
|
||||
EntryPtr = &Rsdt->Entry;
|
||||
for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) {
|
||||
Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr));
|
||||
if (Table->Signature == Signature) {
|
||||
return Table;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
This function scan ACPI table in XSDT.
|
||||
|
||||
@param Xsdt ACPI XSDT
|
||||
@param Signature ACPI table signature
|
||||
|
||||
@return ACPI table
|
||||
**/
|
||||
VOID *
|
||||
ScanTableInXSDT (
|
||||
IN XSDT_TABLE *Xsdt,
|
||||
IN UINT32 Signature
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINT32 EntryCount;
|
||||
UINT64 EntryPtr;
|
||||
UINTN BasePtr;
|
||||
EFI_ACPI_DESCRIPTION_HEADER *Table;
|
||||
|
||||
EntryCount = (Xsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT64);
|
||||
|
||||
BasePtr = (UINTN)(&(Xsdt->Entry));
|
||||
for (Index = 0; Index < EntryCount; Index ++) {
|
||||
CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), sizeof(UINT64));
|
||||
Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(EntryPtr));
|
||||
if (Table->Signature == Signature) {
|
||||
return Table;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
This function scan ACPI table in RSDP.
|
||||
|
||||
@param Rsdp ACPI RSDP
|
||||
@param Signature ACPI table signature
|
||||
|
||||
@return ACPI table
|
||||
**/
|
||||
VOID *
|
||||
FindAcpiPtr (
|
||||
IN EFI_ACPI_5_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp,
|
||||
IN UINT32 Signature
|
||||
)
|
||||
{
|
||||
EFI_ACPI_DESCRIPTION_HEADER *AcpiTable;
|
||||
RSDT_TABLE *Rsdt;
|
||||
XSDT_TABLE *Xsdt;
|
||||
|
||||
AcpiTable = NULL;
|
||||
|
||||
//
|
||||
// Check ACPI2.0 table
|
||||
//
|
||||
Rsdt = (RSDT_TABLE *)(UINTN)Rsdp->RsdtAddress;
|
||||
Xsdt = NULL;
|
||||
if ((Rsdp->Revision >= 2) && (Rsdp->XsdtAddress < (UINT64)(UINTN)-1)) {
|
||||
Xsdt = (XSDT_TABLE *)(UINTN)Rsdp->XsdtAddress;
|
||||
}
|
||||
//
|
||||
// Check Xsdt
|
||||
//
|
||||
if (Xsdt != NULL) {
|
||||
AcpiTable = ScanTableInXSDT (Xsdt, Signature);
|
||||
}
|
||||
//
|
||||
// Check Rsdt
|
||||
//
|
||||
if ((AcpiTable == NULL) && (Rsdt != NULL)) {
|
||||
AcpiTable = ScanTableInRSDT (Rsdt, Signature);
|
||||
}
|
||||
|
||||
return AcpiTable;
|
||||
}
|
||||
|
||||
/**
|
||||
Get Boot performance table form Acpi table.
|
||||
|
||||
|
@ -235,31 +125,11 @@ EFI_STATUS
|
|||
GetBootPerformanceTable (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *AcpiTable;
|
||||
FIRMWARE_PERFORMANCE_TABLE *FirmwarePerformanceTable;
|
||||
|
||||
AcpiTable = NULL;
|
||||
|
||||
Status = EfiGetSystemConfigurationTable (
|
||||
&gEfiAcpi20TableGuid,
|
||||
&AcpiTable
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EfiGetSystemConfigurationTable (
|
||||
&gEfiAcpi10TableGuid,
|
||||
&AcpiTable
|
||||
);
|
||||
}
|
||||
if (EFI_ERROR(Status) || AcpiTable == NULL) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_TABLE_FAIL), mDpHiiHandle);
|
||||
return Status;
|
||||
}
|
||||
|
||||
FirmwarePerformanceTable = FindAcpiPtr (
|
||||
(EFI_ACPI_5_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiTable,
|
||||
EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
|
||||
);
|
||||
FirmwarePerformanceTable = (FIRMWARE_PERFORMANCE_TABLE *) EfiLocateFirstAcpiTable (
|
||||
EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
|
||||
);
|
||||
if (FirmwarePerformanceTable == NULL) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_FPDT_FAIL), mDpHiiHandle);
|
||||
return EFI_NOT_FOUND;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <Guid/Performance.h>
|
||||
#include <Guid/ExtendedFirmwarePerformance.h>
|
||||
#include <Guid/FirmwarePerformance.h>
|
||||
#include <Guid/Acpi.h>
|
||||
|
||||
#include <Protocol/HiiPackageList.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
|
|
|
@ -94,7 +94,6 @@
|
|||
#string STR_DP_INCOMPLETE #language en-US " I "
|
||||
#string STR_DP_COMPLETE #language en-US " "
|
||||
#string STR_ALIT_UNKNOWN #language en-US "Unknown"
|
||||
#string STR_DP_GET_ACPI_TABLE_FAIL #language en-US "Fail to get ACPI Table\n"
|
||||
#string STR_DP_GET_ACPI_FPDT_FAIL #language en-US "Fail to get Firmware Performance Data Table (FPDT) in ACPI Table\n"
|
||||
|
||||
#string STR_GET_HELP_DP #language en-US ""
|
||||
|
|
|
@ -59,8 +59,6 @@
|
|||
|
||||
[Guids]
|
||||
gPerformanceProtocolGuid ## CONSUMES ## SystemTable
|
||||
gEfiAcpi20TableGuid ## CONSUMES ## SystemTable
|
||||
gEfiAcpi10TableGuid ## CONSUMES ## SystemTable
|
||||
|
||||
[Protocols]
|
||||
gEfiLoadedImageProtocolGuid ## CONSUMES
|
||||
|
|
|
@ -60,8 +60,6 @@
|
|||
|
||||
[Guids]
|
||||
gPerformanceProtocolGuid ## CONSUMES ## SystemTable
|
||||
gEfiAcpi20TableGuid ## CONSUMES
|
||||
gEfiAcpi10TableGuid ## CONSUMES
|
||||
|
||||
[Protocols]
|
||||
gEfiLoadedImageProtocolGuid ## CONSUMES
|
||||
|
|
Loading…
Reference in New Issue