mirror of https://github.com/acidanthera/audk.git
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>
This commit is contained in:
parent
9eaa902a52
commit
b2725f57c7
|
@ -1,6 +1,6 @@
|
||||||
/** @file
|
/** @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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -528,7 +528,7 @@ ProcessRmrr (
|
||||||
LowBottom = 0;
|
LowBottom = 0;
|
||||||
LowTop = (UINTN)DmarRmrr->ReservedMemoryRegionBaseAddress;
|
LowTop = (UINTN)DmarRmrr->ReservedMemoryRegionBaseAddress;
|
||||||
HighBottom = (UINTN)DmarRmrr->ReservedMemoryRegionLimitAddress + 1;
|
HighBottom = (UINTN)DmarRmrr->ReservedMemoryRegionLimitAddress + 1;
|
||||||
HighTop = GetTopMemory ();
|
HighTop = LShiftU64 (1, VTdInfo->HostAddressWidth + 1);
|
||||||
|
|
||||||
SetDmaProtectedRange (
|
SetDmaProtectedRange (
|
||||||
VTdInfo,
|
VTdInfo,
|
||||||
|
|
|
@ -60,7 +60,7 @@ typedef struct {
|
||||||
|
|
||||||
PEI Memory Layout:
|
PEI Memory Layout:
|
||||||
|
|
||||||
+------------------+ <=============== PHMR.Limit (+ alignment) (Top of memory)
|
+------------------+ <=============== PHMR.Limit (+ alignment) (1 << (HostAddressWidth + 1))
|
||||||
| Mem Resource |
|
| Mem Resource |
|
||||||
| |
|
| |
|
||||||
|
|
||||||
|
@ -377,159 +377,6 @@ CONST EFI_PEI_PPI_DESCRIPTOR mIoMmuPpiList = {
|
||||||
(VOID *) &mIoMmuPpi
|
(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.
|
Initialize DMA protection.
|
||||||
|
|
||||||
|
@ -548,8 +395,6 @@ InitDmaProtection (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
VOID *HobList;
|
|
||||||
EFI_HOB_HANDOFF_INFO_TABLE *PhitHob;
|
|
||||||
UINT32 LowMemoryAlignment;
|
UINT32 LowMemoryAlignment;
|
||||||
UINT64 HighMemoryAlignment;
|
UINT64 HighMemoryAlignment;
|
||||||
UINTN MemoryAlignment;
|
UINTN MemoryAlignment;
|
||||||
|
@ -558,14 +403,6 @@ InitDmaProtection (
|
||||||
UINTN HighBottom;
|
UINTN HighBottom;
|
||||||
UINT64 HighTop;
|
UINT64 HighTop;
|
||||||
|
|
||||||
HobList = GetHobList ();
|
|
||||||
DumpPhitHob (HobList);
|
|
||||||
DumpResourceHob (HobList);
|
|
||||||
|
|
||||||
PhitHob = HobList;
|
|
||||||
|
|
||||||
ASSERT (PhitHob->EfiMemoryBottom < PhitHob->EfiMemoryTop);
|
|
||||||
|
|
||||||
LowMemoryAlignment = GetLowMemoryAlignment (VTdInfo, VTdInfo->EngineMask);
|
LowMemoryAlignment = GetLowMemoryAlignment (VTdInfo, VTdInfo->EngineMask);
|
||||||
HighMemoryAlignment = GetHighMemoryAlignment (VTdInfo, VTdInfo->EngineMask);
|
HighMemoryAlignment = GetHighMemoryAlignment (VTdInfo, VTdInfo->EngineMask);
|
||||||
if (LowMemoryAlignment < HighMemoryAlignment) {
|
if (LowMemoryAlignment < HighMemoryAlignment) {
|
||||||
|
@ -584,7 +421,7 @@ InitDmaProtection (
|
||||||
LowBottom = 0;
|
LowBottom = 0;
|
||||||
LowTop = *DmaBufferBase;
|
LowTop = *DmaBufferBase;
|
||||||
HighBottom = *DmaBufferBase + DmaBufferSize;
|
HighBottom = *DmaBufferBase + DmaBufferSize;
|
||||||
HighTop = GetTopMemory ();
|
HighTop = LShiftU64 (1, VTdInfo->HostAddressWidth + 1);
|
||||||
|
|
||||||
Status = SetDmaProtectedRange (
|
Status = SetDmaProtectedRange (
|
||||||
VTdInfo,
|
VTdInfo,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
The definition for DMA access Library.
|
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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
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
|
IN EFI_ACPI_DMAR_HEADER *Dmar
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
Get the highest memory.
|
|
||||||
|
|
||||||
@return the highest memory.
|
|
||||||
**/
|
|
||||||
UINT64
|
|
||||||
GetTopMemory (
|
|
||||||
VOID
|
|
||||||
);
|
|
||||||
|
|
||||||
extern EFI_GUID mVTdInfoGuid;
|
extern EFI_GUID mVTdInfoGuid;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue