OvmfPkg/LsiScsiDxe: Map DMA buffer
Map DMA buffer and perpare for the implementation of LsiScsiPassThru(). v2: - Replace 0x10000 with SIZE_64KB macro for the DMA buffer data array - Remove DUAL_ADDRESS_CYCLE from PciIo since we don't really need 64-bit DMA address Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Signed-off-by: Gary Lin <glin@suse.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20200717061130.8881-9-glin@suse.com>
This commit is contained in:
@@ -356,6 +356,8 @@ LsiScsiControllerStart (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
LSI_SCSI_DEV *Dev;
|
||||
UINTN Pages;
|
||||
UINTN BytesMapped;
|
||||
|
||||
Dev = AllocateZeroPool (sizeof (*Dev));
|
||||
if (Dev == NULL) {
|
||||
@@ -411,11 +413,45 @@ LsiScsiControllerStart (
|
||||
goto CloseProtocol;
|
||||
}
|
||||
|
||||
Status = LsiScsiReset (Dev);
|
||||
//
|
||||
// Create buffers for data transfer
|
||||
//
|
||||
Pages = EFI_SIZE_TO_PAGES (sizeof (*Dev->Dma));
|
||||
Status = Dev->PciIo->AllocateBuffer (
|
||||
Dev->PciIo,
|
||||
AllocateAnyPages,
|
||||
EfiBootServicesData,
|
||||
Pages,
|
||||
(VOID **)&Dev->Dma,
|
||||
EFI_PCI_ATTRIBUTE_MEMORY_CACHED
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto RestoreAttributes;
|
||||
}
|
||||
|
||||
BytesMapped = EFI_PAGES_TO_SIZE (Pages);
|
||||
Status = Dev->PciIo->Map (
|
||||
Dev->PciIo,
|
||||
EfiPciIoOperationBusMasterCommonBuffer,
|
||||
Dev->Dma,
|
||||
&BytesMapped,
|
||||
&Dev->DmaPhysical,
|
||||
&Dev->DmaMapping
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreeBuffer;
|
||||
}
|
||||
|
||||
if (BytesMapped != EFI_PAGES_TO_SIZE (Pages)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Unmap;
|
||||
}
|
||||
|
||||
Status = LsiScsiReset (Dev);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Unmap;
|
||||
}
|
||||
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_SIGNAL_EXIT_BOOT_SERVICES,
|
||||
TPL_CALLBACK,
|
||||
@@ -462,6 +498,19 @@ CloseExitBoot:
|
||||
UninitDev:
|
||||
LsiScsiReset (Dev);
|
||||
|
||||
Unmap:
|
||||
Dev->PciIo->Unmap (
|
||||
Dev->PciIo,
|
||||
Dev->DmaMapping
|
||||
);
|
||||
|
||||
FreeBuffer:
|
||||
Dev->PciIo->FreeBuffer (
|
||||
Dev->PciIo,
|
||||
Pages,
|
||||
Dev->Dma
|
||||
);
|
||||
|
||||
RestoreAttributes:
|
||||
Dev->PciIo->Attributes (
|
||||
Dev->PciIo,
|
||||
@@ -524,6 +573,17 @@ LsiScsiControllerStop (
|
||||
|
||||
LsiScsiReset (Dev);
|
||||
|
||||
Dev->PciIo->Unmap (
|
||||
Dev->PciIo,
|
||||
Dev->DmaMapping
|
||||
);
|
||||
|
||||
Dev->PciIo->FreeBuffer (
|
||||
Dev->PciIo,
|
||||
EFI_SIZE_TO_PAGES (sizeof (*Dev->Dma)),
|
||||
Dev->Dma
|
||||
);
|
||||
|
||||
Dev->PciIo->Attributes (
|
||||
Dev->PciIo,
|
||||
EfiPciIoAttributeOperationSet,
|
||||
|
Reference in New Issue
Block a user