diff options
| author | Michael Brown | 2020-11-25 16:52:00 +0100 |
|---|---|---|
| committer | Michael Brown | 2020-11-25 17:15:55 +0100 |
| commit | cf12a41703a8b2292e5d2d7528c2733c37869681 (patch) | |
| tree | 72e60b6240cdd10816b7dce5fcc98822ae94e957 /src/interface/efi/efi_pci.c | |
| parent | [intelxl] Configure DMA mask as 64-bit (diff) | |
| download | ipxe-cf12a41703a8b2292e5d2d7528c2733c37869681.tar.gz ipxe-cf12a41703a8b2292e5d2d7528c2733c37869681.tar.xz ipxe-cf12a41703a8b2292e5d2d7528c2733c37869681.zip | |
[dma] Modify DMA API to simplify calculation of medial addresses
Redefine the value stored within a DMA mapping to be the offset
between physical addresses and DMA addresses within the mapped region.
Provide a dma() wrapper function to calculate the DMA address for any
pointer within a mapped region, thereby simplifying the use cases when
a device needs to be given addresses other than the region start
address.
On a platform using the "flat" DMA implementation the DMA offset for
any mapped region is always zero, with the result that dma_map() can
be optimised away completely and dma() reduces to a straightforward
call to virt_to_phys().
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/efi/efi_pci.c')
| -rw-r--r-- | src/interface/efi/efi_pci.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index 6c6ac5c77..e33a8980d 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -335,7 +335,7 @@ static int efipci_dma_map ( struct dma_device *dma, physaddr_t addr, size_t len, int rc; /* Sanity check */ - assert ( map->addr == 0 ); + assert ( map->offset == 0 ); assert ( map->token == NULL ); /* Determine operation */ @@ -374,7 +374,7 @@ static int efipci_dma_map ( struct dma_device *dma, physaddr_t addr, size_t len, } /* Populate mapping */ - map->addr = bus; + map->offset = ( bus - addr ); map->token = mapping; /* Increment mapping count (for debugging) */ @@ -408,7 +408,7 @@ static void efipci_dma_unmap ( struct dma_device *dma, pci_io->Unmap ( pci_io, map->token ); /* Clear mapping */ - map->addr = 0; + map->offset = 0; map->token = NULL; /* Decrement mapping count (for debugging) */ |
