summaryrefslogtreecommitdiffstats
path: root/src/include
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/include
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/include')
-rw-r--r--src/include/ipxe/dma.h42
-rw-r--r--src/include/ipxe/iobuf.h3
2 files changed, 14 insertions, 31 deletions
diff --git a/src/include/ipxe/dma.h b/src/include/ipxe/dma.h
index 6e5c43289..d450ef523 100644
--- a/src/include/ipxe/dma.h
+++ b/src/include/ipxe/dma.h
@@ -68,7 +68,7 @@ struct dma_operations {
* @ret rc Return status code
*/
int ( * map ) ( struct dma_device *dma, struct dma_mapping *map,
- physaddr_t addr, size_t len, int flags );
+ void *addr, size_t len, int flags );
/**
* Unmap buffer
*
@@ -178,8 +178,7 @@ struct dma_operations {
*/
static inline __always_inline int
DMAAPI_INLINE ( flat, dma_map ) ( struct dma_device *dma,
- struct dma_mapping *map,
- physaddr_t addr __unused,
+ struct dma_mapping *map, void *addr __unused,
size_t len __unused, int flags __unused ) {
/* Increment mapping count (for debugging) */
@@ -319,32 +318,31 @@ DMAAPI_INLINE ( flat, dma_set_mask ) ( struct dma_device *dma __unused,
}
/**
- * Get DMA address from physical address
+ * Get DMA address from virtual address
*
* @v map DMA mapping
- * @v addr Physical address within the mapped region
+ * @v addr Address within the mapped region
* @ret addr Device-side DMA address
*/
static inline __always_inline physaddr_t
-DMAAPI_INLINE ( flat, dma_phys ) ( struct dma_mapping *map __unused,
- physaddr_t addr ) {
+DMAAPI_INLINE ( flat, dma ) ( struct dma_mapping *map __unused, void *addr ) {
/* Use physical address as device address */
- return addr;
+ return virt_to_phys ( addr );
}
/**
- * Get DMA address from physical address
+ * Get DMA address from virtual address
*
* @v map DMA mapping
- * @v addr Physical address within the mapped region
+ * @v addr Address within the mapped region
* @ret addr Device-side DMA address
*/
static inline __always_inline physaddr_t
-DMAAPI_INLINE ( op, dma_phys ) ( struct dma_mapping *map, physaddr_t addr ) {
+DMAAPI_INLINE ( op, dma ) ( struct dma_mapping *map, void *addr ) {
/* Adjust physical address using mapping offset */
- return ( addr + map->offset );
+ return ( virt_to_phys ( addr ) + map->offset );
}
/**
@@ -358,7 +356,7 @@ DMAAPI_INLINE ( op, dma_phys ) ( struct dma_mapping *map, physaddr_t addr ) {
* @ret rc Return status code
*/
int 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 );
/**
* Unmap buffer
@@ -418,27 +416,13 @@ void dma_ufree ( struct dma_mapping *map, void *addr, size_t len );
void dma_set_mask ( struct dma_device *dma, physaddr_t mask );
/**
- * Get DMA address from physical address
- *
- * @v map DMA mapping
- * @v addr Physical address within the mapped region
- * @ret addr Device-side DMA address
- */
-physaddr_t dma_phys ( struct dma_mapping *map, physaddr_t addr );
-
-/**
* Get DMA address from virtual address
*
* @v map DMA mapping
- * @v addr Virtual address within the mapped region
+ * @v addr Address within the mapped region
* @ret addr Device-side DMA address
*/
-static inline __always_inline physaddr_t dma ( struct dma_mapping *map,
- void *addr ) {
-
- /* Get DMA address from corresponding physical address */
- return dma_phys ( map, virt_to_phys ( addr ) );
-}
+physaddr_t dma ( struct dma_mapping *map, void *addr );
/**
* Check if DMA unmapping is required
diff --git a/src/include/ipxe/iobuf.h b/src/include/ipxe/iobuf.h
index 2bdca6b5d..df8d0b854 100644
--- a/src/include/ipxe/iobuf.h
+++ b/src/include/ipxe/iobuf.h
@@ -230,8 +230,7 @@ static inline void iob_populate ( struct io_buffer *iobuf,
static inline __always_inline int iob_map ( struct io_buffer *iobuf,
struct dma_device *dma,
size_t len, int flags ) {
- return dma_map ( dma, &iobuf->map, virt_to_phys ( iobuf->data ),
- len, flags );
+ return dma_map ( dma, &iobuf->map, iobuf->data, len, flags );
}
/**