From: Star Zeng <star.zeng@intel.com>
To: edk2-devel@lists.01.org
Cc: Star Zeng <star.zeng@intel.com>,
Younas khan <pmdyounaskhan786@gmail.com>,
Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <liming.gao@intel.com>,
Jiewen Yao <jiewen.yao@intel.com>
Subject: [PATCH 2/6] IntelSiliconPkg IntelVTdDxe: Use new EfiFindAcpiTableBySignature()
Date: Fri, 31 Aug 2018 19:29:15 +0800 [thread overview]
Message-ID: <1535714959-73472-3-git-send-email-star.zeng@intel.com> (raw)
In-Reply-To: <1535714959-73472-1-git-send-email-star.zeng@intel.com>
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 IntelVTdDxe to use new
EfiFindAcpiTableBySignature() 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>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
.../Feature/VTd/IntelVTdDxe/DmarAcpiTable.c | 136 +--------------------
1 file changed, 3 insertions(+), 133 deletions(-)
diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c
index 24723fe4972a..1e8c1f620c98 100644
--- a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c
+++ b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c
@@ -868,116 +868,6 @@ ParseDmarAcpiTableRmrr (
}
/**
- This function scan ACPI table in RSDT.
-
- @param[in] Rsdt ACPI RSDT
- @param[in] 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 != NULL) && (Table->Signature == Signature)) {
- return Table;
- }
- }
-
- return NULL;
-}
-
-/**
- This function scan ACPI table in XSDT.
-
- @param[in] Xsdt ACPI XSDT
- @param[in] 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 != NULL) && (Table->Signature == Signature)) {
- return Table;
- }
- }
-
- return NULL;
-}
-
-/**
- This function scan ACPI table in RSDP.
-
- @param[in] Rsdp ACPI RSDP
- @param[in] Signature ACPI table signature
-
- @return ACPI table
-**/
-VOID *
-FindAcpiPtr (
- IN EFI_ACPI_2_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 the DMAR ACPI table.
@retval EFI_SUCCESS The DMAR ACPI table is got.
@@ -989,33 +879,13 @@ GetDmarAcpiTable (
VOID
)
{
- VOID *AcpiTable;
- EFI_STATUS Status;
-
if (mAcpiDmarTable != NULL) {
return EFI_ALREADY_STARTED;
}
- AcpiTable = NULL;
- Status = EfiGetSystemConfigurationTable (
- &gEfiAcpi20TableGuid,
- &AcpiTable
- );
- if (EFI_ERROR (Status)) {
- Status = EfiGetSystemConfigurationTable (
- &gEfiAcpi10TableGuid,
- &AcpiTable
- );
- }
- if (EFI_ERROR (Status)) {
- return EFI_NOT_FOUND;
- }
- ASSERT (AcpiTable != NULL);
-
- mAcpiDmarTable = FindAcpiPtr (
- (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiTable,
- EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE
- );
+ mAcpiDmarTable = (EFI_ACPI_DMAR_HEADER *) EfiFindAcpiTableBySignature (
+ EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE
+ );
if (mAcpiDmarTable == NULL) {
return EFI_NOT_FOUND;
}
--
2.7.0.windows.1
next prev parent reply other threads:[~2018-08-31 11:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-31 11:29 [PATCH 0/6] Add new EfiFindAcpiTableBySignature() API Star Zeng
2018-08-31 11:29 ` [PATCH 1/6] MdePkg UefiLib: " Star Zeng
2018-08-31 11:57 ` Yao, Jiewen
2018-08-31 16:28 ` Ni, Ruiyu
2018-08-31 16:29 ` Ni, Ruiyu
2018-08-31 23:04 ` Yao, Jiewen
2018-09-03 3:26 ` Zeng, Star
2018-09-03 5:09 ` Ni, Ruiyu
2018-09-03 6:11 ` Zeng, Star
2018-09-03 6:14 ` Yao, Jiewen
2018-09-03 6:32 ` Ni, Ruiyu
2018-09-05 10:02 ` Zeng, Star
2018-08-31 11:29 ` Star Zeng [this message]
2018-08-31 11:29 ` [PATCH 3/6] MdeModulePkg S3SaveStateDxe: Use new EfiFindAcpiTableBySignature() Star Zeng
2018-08-31 11:29 ` [PATCH 4/6] PcAtChipsetPkg PcRtc: " Star Zeng
2018-08-31 11:29 ` [PATCH 5/6] ShellPkg DpDynamicCommand: " Star Zeng
2018-08-31 11:29 ` [PATCH 6/6] UefiCpuPkg PiSmmCpuDxeSmm: " Star Zeng
2018-08-31 20:33 ` Laszlo Ersek
2018-09-03 3:28 ` Zeng, Star
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1535714959-73472-3-git-send-email-star.zeng@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox