OvmfPkg/QemuFwCfgLib: Add option to dynamic alloc FW_CFG_DMA Access

Update InternalQemuFwCfgDmaBytes() to work with DMA Access pointer.
The change provides the flexibility to dynamically allocate the "Access"
when SEV is enabled.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
Brijesh Singh 2017-07-06 09:29:13 -04:00 committed by Jordan Justen
parent 09719a01b1
commit 7cfe445d7f

View File

@ -68,7 +68,8 @@ InternalQemuFwCfgDmaBytes (
IN UINT32 Control IN UINT32 Control
) )
{ {
volatile FW_CFG_DMA_ACCESS Access; volatile FW_CFG_DMA_ACCESS LocalAccess;
volatile FW_CFG_DMA_ACCESS *Access;
UINT32 AccessHigh, AccessLow; UINT32 AccessHigh, AccessLow;
UINT32 Status; UINT32 Status;
@ -79,9 +80,11 @@ InternalQemuFwCfgDmaBytes (
return; return;
} }
Access.Control = SwapBytes32 (Control); Access = &LocalAccess;
Access.Length = SwapBytes32 (Size);
Access.Address = SwapBytes64 ((UINTN)Buffer); Access->Control = SwapBytes32 (Control);
Access->Length = SwapBytes32 (Size);
Access->Address = SwapBytes64 ((UINTN)Buffer);
// //
// Delimit the transfer from (a) modifications to Access, (b) in case of a // Delimit the transfer from (a) modifications to Access, (b) in case of a
@ -92,8 +95,8 @@ InternalQemuFwCfgDmaBytes (
// //
// Start the transfer. // Start the transfer.
// //
AccessHigh = (UINT32)RShiftU64 ((UINTN)&Access, 32); AccessHigh = (UINT32)RShiftU64 ((UINTN)Access, 32);
AccessLow = (UINT32)(UINTN)&Access; AccessLow = (UINT32)(UINTN)Access;
IoWrite32 (FW_CFG_IO_DMA_ADDRESS, SwapBytes32 (AccessHigh)); IoWrite32 (FW_CFG_IO_DMA_ADDRESS, SwapBytes32 (AccessHigh));
IoWrite32 (FW_CFG_IO_DMA_ADDRESS + 4, SwapBytes32 (AccessLow)); IoWrite32 (FW_CFG_IO_DMA_ADDRESS + 4, SwapBytes32 (AccessLow));
@ -106,7 +109,7 @@ InternalQemuFwCfgDmaBytes (
// Wait for the transfer to complete. // Wait for the transfer to complete.
// //
do { do {
Status = SwapBytes32 (Access.Control); Status = SwapBytes32 (Access->Control);
ASSERT ((Status & FW_CFG_DMA_CTL_ERROR) == 0); ASSERT ((Status & FW_CFG_DMA_CTL_ERROR) == 0);
} while (Status != 0); } while (Status != 0);