summaryrefslogtreecommitdiffstats
path: root/src/interface
diff options
context:
space:
mode:
authorMichael Brown2025-07-08 13:38:05 +0200
committerMichael Brown2025-07-08 16:13:19 +0200
commit22de0c4edf2fe1cdbca5e22c52c86a2289d04816 (patch)
tree04b655d0e3c1e572cda0d568783840b9d27b381e /src/interface
parent[build] Handle isohybrid with xorrisofs (diff)
downloadipxe-22de0c4edf2fe1cdbca5e22c52c86a2289d04816.tar.gz
ipxe-22de0c4edf2fe1cdbca5e22c52c86a2289d04816.tar.xz
ipxe-22de0c4edf2fe1cdbca5e22c52c86a2289d04816.zip
[dma] Use virtual addresses for dma_map()
Cache management operations must generally be performed on virtual addresses rather than physical addresses. Change the address parameter in dma_map() to be a virtual address, and make dma() the API-level primitive instead of dma_phys(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface')
-rw-r--r--src/interface/efi/efi_pci.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c
index 1b1f05816..ae0ec4264 100644
--- a/src/interface/efi/efi_pci.c
+++ b/src/interface/efi/efi_pci.c
@@ -455,7 +455,7 @@ PROVIDE_PCIAPI ( efi, pci_ioremap, efipci_ioremap );
* @ret rc Return status code
*/
static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map,
- physaddr_t addr, size_t len, int flags ) {
+ void *addr, size_t len, int flags ) {
struct efi_pci_device *efipci =
container_of ( dma, struct efi_pci_device, pci.dma );
struct pci_device *pci = &efipci->pci;
@@ -464,6 +464,7 @@ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map,
EFI_PHYSICAL_ADDRESS bus;
UINTN count;
VOID *mapping;
+ physaddr_t phys;
EFI_STATUS efirc;
int rc;
@@ -486,18 +487,19 @@ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map,
}
/* Map buffer (if non-zero length) */
+ phys = virt_to_phys ( addr );
count = len;
if ( len ) {
- if ( ( efirc = pci_io->Map ( pci_io, op, phys_to_virt ( addr ),
- &count, &bus, &mapping ) ) != 0 ) {
+ if ( ( efirc = pci_io->Map ( pci_io, op, addr, &count, &bus,
+ &mapping ) ) != 0 ) {
rc = -EEFI ( efirc );
- DBGC ( pci, "EFIPCI " PCI_FMT " cannot map %08lx+%zx: "
+ DBGC ( pci, "EFIPCI " PCI_FMT " cannot map %p+%zx: "
"%s\n", PCI_ARGS ( pci ), addr, len,
strerror ( rc ) );
goto err_map;
}
} else {
- bus = addr;
+ bus = phys;
mapping = NULL;
}
@@ -508,14 +510,14 @@ static int efipci_dma_map ( struct dma_device *dma, struct dma_mapping *map,
*/
if ( count != len ) {
DBGC ( pci, "EFIPCI " PCI_FMT " attempted split mapping for "
- "%08lx+%zx\n", PCI_ARGS ( pci ), addr, len );
+ "%p+%zx\n", PCI_ARGS ( pci ), addr, len );
rc = -ENOTSUP;
goto err_len;
}
/* Populate mapping */
map->dma = dma;
- map->offset = ( bus - addr );
+ map->offset = ( bus - phys );
map->token = mapping;
/* Increment mapping count (for debugging) */
@@ -594,8 +596,7 @@ static void * efipci_dma_alloc ( struct dma_device *dma,
memset ( addr, 0, ( pages * EFI_PAGE_SIZE ) );
/* Map buffer */
- if ( ( rc = efipci_dma_map ( dma, map, virt_to_phys ( addr ),
- ( pages * EFI_PAGE_SIZE ),
+ if ( ( rc = efipci_dma_map ( dma, map, addr, ( pages * EFI_PAGE_SIZE ),
DMA_BI ) ) != 0 )
goto err_map;