SIGN IN SIGN UP

api: Add DMAPool.

The DMAPool class allocates and manages a pool of buffers that are DMA and cache
friendly, designed for applications that require frequent buffer exchanges between
the CPU and DMA (such as audio applications).
The DMAPool maintains a read and write queues of DMA buffers. DMA buffers' sizes
are rounded up to a multiple of the pool's alignment (which defaults to cache line
size on platforms with caches), and their memory is initialized from one contiguous
memory block.
A typical usage of DMAPool involves allocating a DMA buffer from the write queue
for writing by a producer, updating its contents, and then releasing it. When released,
the DMA buffer returns to the pool, which in turn places it back into the read queue
for later consumption by the consumer. For example:

```C++
// Writer/Producer side (For example, an IRQ handler).
DMABuffer<uint16_t> *buf = pool->alloc(DMA_BUFFER_WRITE);
for (size_t i=0; i<buf.size(); i++) {
    buf[i] = 0xFFFF;
}
buf->release();

// Reader/Consumer side (User/library).
DMABuffer<uint16_t> *buf = pool->alloc(DMA_BUFFER_READ);
for (size_t i=0; i<buf.size(); i++) {
    print(buf[i]);
}
buf->release();
```

Note that the DMAPool uses single-writer, single-reader lock-free queues to store
buffers, and as such, it can only be used by a single reader and a single writer.
Locks are avoided to allow the DMAPool to be used from an ISR producer/consumer,
with only the main thread, and without disabling IRQs.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
I
iabdalkader committed
4c7bc29d14adfca52a1fbfef29e8f02541609f26
Parent: 0c853c5