diff options
Diffstat (limited to 'src/sys/include/io/dma')
-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 * |