summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2018-01-17 11:10:57 +0800
committerStar Zeng <star.zeng@intel.com>2018-05-10 14:23:47 +0800
commit8bb7fa235f13f3e74b2d967dde6a621724e8c076 (patch)
tree30a0adfc582aa1458c1c2c357fba3447d003ebd8
parent1cc04b839baa9945dcd89a9ef0e5192f52714ae6 (diff)
downloadedk2-8bb7fa235f13f3e74b2d967dde6a621724e8c076.zip
edk2-8bb7fa235f13f3e74b2d967dde6a621724e8c076.tar.gz
edk2-8bb7fa235f13f3e74b2d967dde6a621724e8c076.tar.bz2
IntelSiliconPkg IntelVTdPmrPei: Get high top by host address width
Get high top by host address width instead of resource HOB. Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> (cherry picked from commit b2725f57c7a1e6feeb176f1563a4f1a8c2eb6c6f)
-rw-r--r--IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c4
-rw-r--r--IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c167
-rw-r--r--IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.h12
3 files changed, 5 insertions, 178 deletions
diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c
index 891efa6..ea853bd 100644
--- a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c
+++ b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/DmarTable.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -528,7 +528,7 @@ ProcessRmrr (
LowBottom = 0;
LowTop = (UINTN)DmarRmrr->ReservedMemoryRegionBaseAddress;
HighBottom = (UINTN)DmarRmrr->ReservedMemoryRegionLimitAddress + 1;
- HighTop = GetTopMemory ();
+ HighTop = LShiftU64 (1, VTdInfo->HostAddressWidth + 1);
SetDmaProtectedRange (
VTdInfo,
diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c
index bb7ace4..63ba94d 100644
--- a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c
+++ b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.c
@@ -60,7 +60,7 @@ typedef struct {
PEI Memory Layout:
- +------------------+ <=============== PHMR.Limit (+ alignment) (Top of memory)
+ +------------------+ <=============== PHMR.Limit (+ alignment) (1 << (HostAddressWidth + 1))
| Mem Resource |
| |
@@ -377,159 +377,6 @@ CONST EFI_PEI_PPI_DESCRIPTOR mIoMmuPpiList = {
(VOID *) &mIoMmuPpi
};
-#define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
- EFI_RESOURCE_ATTRIBUTE_TESTED | \
- EFI_RESOURCE_ATTRIBUTE_16_BIT_IO | \
- EFI_RESOURCE_ATTRIBUTE_32_BIT_IO | \
- EFI_RESOURCE_ATTRIBUTE_64_BIT_IO \
- )
-
-#define TESTED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | EFI_RESOURCE_ATTRIBUTE_TESTED)
-
-#define INITIALIZED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED)
-
-#define PRESENT_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT)
-
-GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *mResourceTypeShortName[] = {
- "Mem",
- "MMIO",
- "I/O",
- "FD",
- "MM Port I/O",
- "Reserved Mem",
- "Reserved I/O",
-};
-
-/**
- Return the short name of resource type.
-
- @param Type resource type.
-
- @return the short name of resource type.
-**/
-CHAR8 *
-ShortNameOfResourceType (
- IN UINT32 Type
- )
-{
- if (Type < sizeof(mResourceTypeShortName) / sizeof(mResourceTypeShortName[0])) {
- return mResourceTypeShortName[Type];
- } else {
- return "Unknown";
- }
-}
-
-/**
- Dump resource hob.
-
- @param HobList the HOB list.
-**/
-VOID
-DumpResourceHob (
- IN VOID *HobList
- )
-{
- EFI_PEI_HOB_POINTERS Hob;
- EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
-
- DEBUG ((DEBUG_VERBOSE, "Resource Descriptor HOBs\n"));
- for (Hob.Raw = HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
- if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
- ResourceHob = Hob.ResourceDescriptor;
- DEBUG ((DEBUG_VERBOSE,
- " BA=%016lx L=%016lx Attr=%08x ",
- ResourceHob->PhysicalStart,
- ResourceHob->ResourceLength,
- ResourceHob->ResourceAttribute
- ));
- DEBUG ((DEBUG_VERBOSE, ShortNameOfResourceType(ResourceHob->ResourceType)));
- switch (ResourceHob->ResourceType) {
- case EFI_RESOURCE_SYSTEM_MEMORY:
- if ((ResourceHob->ResourceAttribute & EFI_RESOURCE_ATTRIBUTE_PERSISTENT) != 0) {
- DEBUG ((DEBUG_VERBOSE, " (Persistent)"));
- } else if ((ResourceHob->ResourceAttribute & EFI_RESOURCE_ATTRIBUTE_MORE_RELIABLE) != 0) {
- DEBUG ((DEBUG_VERBOSE, " (MoreReliable)"));
- } else if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES) {
- DEBUG ((DEBUG_VERBOSE, " (Tested)"));
- } else if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == INITIALIZED_MEMORY_ATTRIBUTES) {
- DEBUG ((DEBUG_VERBOSE, " (Init)"));
- } else if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == PRESENT_MEMORY_ATTRIBUTES) {
- DEBUG ((DEBUG_VERBOSE, " (Present)"));
- } else {
- DEBUG ((DEBUG_VERBOSE, " (Unknown)"));
- }
- break;
- default:
- break;
- }
- DEBUG ((DEBUG_VERBOSE, "\n"));
- }
- }
-}
-
-/**
- Dump PHIT hob.
-
- @param HobList the HOB list.
-**/
-VOID
-DumpPhitHob (
- IN VOID *HobList
- )
-{
- EFI_HOB_HANDOFF_INFO_TABLE *PhitHob;
-
- PhitHob = HobList;
- ASSERT(GET_HOB_TYPE(HobList) == EFI_HOB_TYPE_HANDOFF);
- DEBUG ((DEBUG_VERBOSE, "PHIT HOB\n"));
- DEBUG ((DEBUG_VERBOSE, " PhitHob - 0x%x\n", PhitHob));
- DEBUG ((DEBUG_VERBOSE, " BootMode - 0x%x\n", PhitHob->BootMode));
- DEBUG ((DEBUG_VERBOSE, " EfiMemoryTop - 0x%016lx\n", PhitHob->EfiMemoryTop));
- DEBUG ((DEBUG_VERBOSE, " EfiMemoryBottom - 0x%016lx\n", PhitHob->EfiMemoryBottom));
- DEBUG ((DEBUG_VERBOSE, " EfiFreeMemoryTop - 0x%016lx\n", PhitHob->EfiFreeMemoryTop));
- DEBUG ((DEBUG_VERBOSE, " EfiFreeMemoryBottom - 0x%016lx\n", PhitHob->EfiFreeMemoryBottom));
- DEBUG ((DEBUG_VERBOSE, " EfiEndOfHobList - 0x%lx\n", PhitHob->EfiEndOfHobList));
-}
-
-/**
- Get the highest memory.
-
- @return the highest memory.
-**/
-UINT64
-GetTopMemory (
- VOID
- )
-{
- VOID *HobList;
- EFI_PEI_HOB_POINTERS Hob;
- EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
- UINT64 TopMemory;
- UINT64 ResourceTop;
-
- HobList = GetHobList ();
-
- TopMemory = 0;
- for (Hob.Raw = HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
- if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
- ResourceHob = Hob.ResourceDescriptor;
- switch (ResourceHob->ResourceType) {
- case EFI_RESOURCE_SYSTEM_MEMORY:
- ResourceTop = ResourceHob->PhysicalStart + ResourceHob->ResourceLength;
- if (TopMemory < ResourceTop) {
- TopMemory = ResourceTop;
- }
- break;
- default:
- break;
- }
- DEBUG ((DEBUG_VERBOSE, "\n"));
- }
- }
- return TopMemory;
-}
-
/**
Initialize DMA protection.
@@ -548,8 +395,6 @@ InitDmaProtection (
)
{
EFI_STATUS Status;
- VOID *HobList;
- EFI_HOB_HANDOFF_INFO_TABLE *PhitHob;
UINT32 LowMemoryAlignment;
UINT64 HighMemoryAlignment;
UINTN MemoryAlignment;
@@ -558,14 +403,6 @@ InitDmaProtection (
UINTN HighBottom;
UINT64 HighTop;
- HobList = GetHobList ();
- DumpPhitHob (HobList);
- DumpResourceHob (HobList);
-
- PhitHob = HobList;
-
- ASSERT (PhitHob->EfiMemoryBottom < PhitHob->EfiMemoryTop);
-
LowMemoryAlignment = GetLowMemoryAlignment (VTdInfo, VTdInfo->EngineMask);
HighMemoryAlignment = GetHighMemoryAlignment (VTdInfo, VTdInfo->EngineMask);
if (LowMemoryAlignment < HighMemoryAlignment) {
@@ -584,7 +421,7 @@ InitDmaProtection (
LowBottom = 0;
LowTop = *DmaBufferBase;
HighBottom = *DmaBufferBase + DmaBufferSize;
- HighTop = GetTopMemory ();
+ HighTop = LShiftU64 (1, VTdInfo->HostAddressWidth + 1);
Status = SetDmaProtectedRange (
VTdInfo,
diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.h b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.h
index 499119d..c53f69c 100644
--- a/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.h
+++ b/IntelSiliconPkg/Feature/VTd/IntelVTdPmrPei/IntelVTdPmrPei.h
@@ -1,7 +1,7 @@
/** @file
The definition for DMA access Library.
- Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -159,16 +159,6 @@ DumpAcpiDMAR (
IN EFI_ACPI_DMAR_HEADER *Dmar
);
-/**
- Get the highest memory.
-
- @return the highest memory.
-**/
-UINT64
-GetTopMemory (
- VOID
- );
-
extern EFI_GUID mVTdInfoGuid;
#endif