summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/dma.h
diff options
context:
space:
mode:
authorSimon Rettberg2026-01-28 12:53:53 +0100
committerSimon Rettberg2026-01-28 12:53:53 +0100
commit8e82785c584dc13e20f9229decb95bd17bbe9cd1 (patch)
treea8b359e59196be5b2e3862bed189107f4bc9975f /src/include/ipxe/dma.h
parentMerge branch 'master' into openslx (diff)
parent[prefix] Make unlzma.S compatible with 386 class CPUs (diff)
downloadipxe-openslx.tar.gz
ipxe-openslx.tar.xz
ipxe-openslx.zip
Merge branch 'master' into openslxopenslx
Diffstat (limited to 'src/include/ipxe/dma.h')
-rw-r--r--src/include/ipxe/dma.h77
1 files changed, 35 insertions, 42 deletions
diff --git a/src/include/ipxe/dma.h b/src/include/ipxe/dma.h
index 385e4baf7..e6e7a4793 100644
--- a/src/include/ipxe/dma.h
+++ b/src/include/ipxe/dma.h
@@ -8,6 +8,7 @@
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+FILE_SECBOOT ( PERMITTED );
#include <stdint.h>
#include <ipxe/api.h>
@@ -68,14 +69,16 @@ 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
*
* @v dma DMA device
* @v map DMA mapping
+ * @v len Used length
*/
- void ( * unmap ) ( struct dma_device *dma, struct dma_mapping *map );
+ void ( * unmap ) ( struct dma_device *dma, struct dma_mapping *map,
+ size_t len );
/**
* Allocate and map DMA-coherent buffer
*
@@ -106,9 +109,9 @@ struct dma_operations {
* @v align Physical alignment
* @ret addr Buffer address, or NULL on error
*/
- userptr_t ( * umalloc ) ( struct dma_device *dma,
- struct dma_mapping *map,
- size_t len, size_t align );
+ void * ( * umalloc ) ( struct dma_device *dma,
+ struct dma_mapping *map,
+ size_t len, size_t align );
/**
* Unmap and free DMA-coherent buffer from external (user) memory
*
@@ -118,7 +121,7 @@ struct dma_operations {
* @v len Length of buffer
*/
void ( * ufree ) ( struct dma_device *dma, struct dma_mapping *map,
- userptr_t addr, size_t len );
+ void *addr, size_t len );
/**
* Set addressable space mask
*
@@ -178,8 +181,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) */
@@ -195,9 +197,11 @@ DMAAPI_INLINE ( flat, dma_map ) ( struct dma_device *dma,
* Unmap buffer
*
* @v map DMA mapping
+ * @v len Used length
*/
static inline __always_inline void
-DMAAPI_INLINE ( flat, dma_unmap ) ( struct dma_mapping *map ) {
+DMAAPI_INLINE ( flat, dma_unmap ) ( struct dma_mapping *map,
+ size_t len __unused ) {
/* Decrement mapping count (for debugging) */
if ( DBG_LOG ) {
@@ -265,11 +269,11 @@ DMAAPI_INLINE ( flat, dma_free ) ( struct dma_mapping *map,
* @v align Physical alignment
* @ret addr Buffer address, or NULL on error
*/
-static inline __always_inline userptr_t
+static inline __always_inline void *
DMAAPI_INLINE ( flat, dma_umalloc ) ( struct dma_device *dma,
struct dma_mapping *map,
size_t len, size_t align __unused ) {
- userptr_t addr;
+ void *addr;
/* Allocate buffer */
addr = umalloc ( len );
@@ -292,7 +296,7 @@ DMAAPI_INLINE ( flat, dma_umalloc ) ( struct dma_device *dma,
*/
static inline __always_inline void
DMAAPI_INLINE ( flat, dma_ufree ) ( struct dma_mapping *map,
- userptr_t addr, size_t len __unused ) {
+ void *addr, size_t len __unused ) {
/* Free buffer */
ufree ( addr );
@@ -319,34 +323,36 @@ 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 );
}
+/* Include all architecture-dependent DMA API headers */
+#include <bits/dma.h>
+
/**
* Map buffer for DMA
*
@@ -358,14 +364,15 @@ 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
*
* @v map DMA mapping
+ * @v len Used length
*/
-void dma_unmap ( struct dma_mapping *map );
+void dma_unmap ( struct dma_mapping *map, size_t len );
/**
* Allocate and map DMA-coherent buffer
@@ -397,8 +404,8 @@ void dma_free ( struct dma_mapping *map, void *addr, size_t len );
* @v align Physical alignment
* @ret addr Buffer address, or NULL on error
*/
-userptr_t dma_umalloc ( struct dma_device *dma, struct dma_mapping *map,
- size_t len, size_t align );
+void * dma_umalloc ( struct dma_device *dma, struct dma_mapping *map,
+ size_t len, size_t align );
/**
* Unmap and free DMA-coherent buffer from external (user) memory
@@ -407,7 +414,7 @@ userptr_t dma_umalloc ( struct dma_device *dma, struct dma_mapping *map,
* @v addr Buffer address
* @v len Length of buffer
*/
-void dma_ufree ( struct dma_mapping *map, userptr_t addr, size_t len );
+void dma_ufree ( struct dma_mapping *map, void *addr, size_t len );
/**
* Set addressable space mask
@@ -418,27 +425,13 @@ void dma_ufree ( struct dma_mapping *map, userptr_t 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