struct DmaBuffer {
&unsigned char virt;
unsigned long phys;
unsigned long size;
int owner;
}Fields
virtual address (CPU view)
physical address (device view, 0 if identity-mapped)
buffer size in bytes
0 = CPU owns, 1 = device owns
Methods
Mark buffer as owned by device (flush CPU cache → DRAM before transfer).
Mark buffer as owned by CPU (invalidate cache after DMA completes).
Is the buffer currently safe to access from the CPU?
Return physical address of byte at offset.
Initialise a DmaBuffer wrapping an existing allocation (all of virt).
phys = 0 means physical == virtual (identity-mapped / non-MMU systems).