mirror of
https://github.com/ipxe/ipxe
synced 2025-12-24 06:22:59 +03:00
[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>
This commit is contained in:
@@ -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) */
|
||||
|
||||
Reference in New Issue
Block a user