IntelSiliconPkg/VtdPmrPei: Add premem support.
Remove memory discovered dependency to support both premem VTD_INFO_PPI and postmem VTD_INFO_PPI. If VTD_INFO_PPI is installed before memory is ready, this driver protects all memory region. If VTD_INFO_PPI is installed or reinstalled after memory is ready, this driver allocates DMA buffer and protect rest. Cc: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
#define __DMA_ACCESS_LIB_H__
|
||||
|
||||
typedef struct {
|
||||
EFI_ACPI_DMAR_HEADER *AcpiDmarTable;
|
||||
UINT64 EngineMask;
|
||||
UINT8 HostAddressWidth;
|
||||
UINTN VTdEngineCount;
|
||||
UINT64 VTdEngineAddress[1];
|
||||
@@ -24,6 +26,7 @@ typedef struct {
|
||||
/**
|
||||
Set DMA protected region.
|
||||
|
||||
@param VTdInfo The VTd engine context information.
|
||||
@param EngineMask The mask of the VTd engine to be accessed.
|
||||
@param LowMemoryBase The protected low memory region base.
|
||||
@param LowMemoryLength The protected low memory region length.
|
||||
@@ -35,6 +38,7 @@ typedef struct {
|
||||
**/
|
||||
EFI_STATUS
|
||||
SetDmaProtectedRange (
|
||||
IN VTD_INFO *VTdInfo,
|
||||
IN UINT64 EngineMask,
|
||||
IN UINT32 LowMemoryBase,
|
||||
IN UINT32 LowMemoryLength,
|
||||
@@ -45,38 +49,127 @@ SetDmaProtectedRange (
|
||||
/**
|
||||
Diable DMA protection.
|
||||
|
||||
@param VTdInfo The VTd engine context information.
|
||||
@param EngineMask The mask of the VTd engine to be accessed.
|
||||
|
||||
@retval DMA protection is disabled.
|
||||
**/
|
||||
EFI_STATUS
|
||||
DisableDmaProtection (
|
||||
IN VTD_INFO *VTdInfo,
|
||||
IN UINT64 EngineMask
|
||||
);
|
||||
|
||||
/**
|
||||
Return if the DMA protection is enabled.
|
||||
|
||||
@param VTdInfo The VTd engine context information.
|
||||
@param EngineMask The mask of the VTd engine to be accessed.
|
||||
|
||||
@retval TRUE DMA protection is enabled in at least one VTd engine.
|
||||
@retval FALSE DMA protection is disabled in all VTd engines.
|
||||
**/
|
||||
UINT64
|
||||
GetDmaProtectionEnabledEngineMask (
|
||||
IN VTD_INFO *VTdInfo,
|
||||
IN UINT64 EngineMask
|
||||
);
|
||||
|
||||
/**
|
||||
Get protected low memory alignment.
|
||||
|
||||
@param VTdInfo The VTd engine context information.
|
||||
@param EngineMask The mask of the VTd engine to be accessed.
|
||||
|
||||
@return protected low memory alignment.
|
||||
**/
|
||||
UINT32
|
||||
GetLowMemoryAlignment (
|
||||
IN VTD_INFO *VTdInfo,
|
||||
IN UINT64 EngineMask
|
||||
);
|
||||
|
||||
/**
|
||||
Get protected high memory alignment.
|
||||
|
||||
@param VTdInfo The VTd engine context information.
|
||||
@param EngineMask The mask of the VTd engine to be accessed.
|
||||
|
||||
@return protected high memory alignment.
|
||||
**/
|
||||
UINT64
|
||||
GetHighMemoryAlignment (
|
||||
IN VTD_INFO *VTdInfo,
|
||||
IN UINT64 EngineMask
|
||||
);
|
||||
|
||||
/**
|
||||
Enable VTd translation table protection.
|
||||
|
||||
@param VTdInfo The VTd engine context information.
|
||||
@param EngineMask The mask of the VTd engine to be accessed.
|
||||
**/
|
||||
VOID
|
||||
EnableVTdTranslationProtection (
|
||||
IN VTD_INFO *VTdInfo,
|
||||
IN UINT64 EngineMask
|
||||
);
|
||||
|
||||
/**
|
||||
Disable VTd translation table protection.
|
||||
|
||||
@param VTdInfo The VTd engine context information.
|
||||
@param EngineMask The mask of the VTd engine to be accessed.
|
||||
**/
|
||||
VOID
|
||||
DisableVTdTranslationProtection (
|
||||
IN VTD_INFO *VTdInfo,
|
||||
IN UINT64 EngineMask
|
||||
);
|
||||
|
||||
/**
|
||||
Parse DMAR DRHD table.
|
||||
|
||||
@param[in] AcpiDmarTable DMAR ACPI table
|
||||
|
||||
@return EFI_SUCCESS The DMAR DRHD table is parsed.
|
||||
**/
|
||||
EFI_STATUS
|
||||
ParseDmarAcpiTableDrhd (
|
||||
IN EFI_ACPI_DMAR_HEADER *AcpiDmarTable
|
||||
);
|
||||
|
||||
/**
|
||||
Parse DMAR DRHD table.
|
||||
|
||||
@param VTdInfo The VTd engine context information.
|
||||
**/
|
||||
VOID
|
||||
ParseDmarAcpiTableRmrr (
|
||||
IN VTD_INFO *VTdInfo
|
||||
);
|
||||
|
||||
/**
|
||||
Dump DMAR ACPI table.
|
||||
|
||||
@param[in] Dmar DMAR ACPI table
|
||||
**/
|
||||
VOID
|
||||
DumpAcpiDMAR (
|
||||
IN EFI_ACPI_DMAR_HEADER *Dmar
|
||||
);
|
||||
|
||||
/**
|
||||
Get the highest memory.
|
||||
|
||||
@return the highest memory.
|
||||
**/
|
||||
UINT64
|
||||
GetTopMemory (
|
||||
VOID
|
||||
);
|
||||
|
||||
extern EFI_GUID mVTdInfoGuid;
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user