diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-22 13:09:10 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-22 13:09:10 -0400 |
commit | 0d6d9bd4c1d587d62508ad6e8ae68fd4094bc427 (patch) | |
tree | f44b61910db0a4897c7ae70ed982f67001a5bd76 /src/sys/include/io | |
parent | e0969623d49d3380349935dfc1c3b71d62f44906 (diff) |
kern: dma: Add DMA address helpers
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/include/io')
-rw-r--r-- | src/sys/include/io/dma/alloc.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/sys/include/io/dma/alloc.h b/src/sys/include/io/dma/alloc.h index b1034c4..f18fc1d 100644 --- a/src/sys/include/io/dma/alloc.h +++ b/src/sys/include/io/dma/alloc.h @@ -31,9 +31,32 @@ #define _DMA_ALLOC_H_ #include <sys/types.h> +#include <sys/cdefs.h> #include <vm/vm.h> /* + * Represents a physical address that may be used + * with direct memory access + */ +typedef uintptr_t dma_addr_t; + +/* + * Convert virtual DMA pages to physical DMA + * addresses. + */ +__always_inline static dma_addr_t +dma_get_pa(void *pgbuf) +{ + return VIRT_TO_PHYS(pgbuf); +} + +__always_inline static void * +dma_get_va(dma_addr_t pa) +{ + return PHYS_TO_VIRT(pa); +} + +/* * Allocate a buffer suitable for Direct Memory * Access * |