d_align and d_roundup
The d_align service (provided in libsys.a) returns the alignment value required for starting a buffer on a processor cache line boundary. The d_roundup service (also provided in libsys.a) can be used to round the desired DMA buffer length up to a value that is an integer number of cache lines.
These two services use buffers for DMA alignment on a cache line
boundary. The buffers are also used to allocate DMA in whole multiples
of the cache line size so that the buffer is not split across processor
cache lines. This reduces the possibility of consistency problems
because of DMA and also minimizes the number of cache lines that must
be flushed or invalidated when used for DMA. For example, these services
can be used to provide alignment as follows:
align = d_align();
buffer_length = d_roundup(required_length);
buf_ptr = xmalloc(buffer_length, align, kernel_heap);