Open sporniket opened 8 months ago
For now, two consumer MAY ask the same slot.
enum MemorySlotFlags {
dma = 1,
// that's all for now, but up to 32 values:1, 2, 4, 8,...
}
MemorySlotDescriptor {
index: uint32, //realistically, only a handfull, but you never know
key: string,
size: number, //may be greater than required (page size ?)
flags: uint32 //for now, only DMA capability.
}
class MemorySlot {
MemorySlotDescriptor *descriptor;
void *data;
}
class MemoryProvider {
public:
void setup(vector<MemorySlotDescriptor*>* descriptor); // can throw MemoryProviderError : AllocationError
MemorySlot* get(string *key) ; //can throw MemoryProviderError : UnknownSlot error
}
abstract class UserOfMemorySlot {
public:
void use(MemorySlot *slot);
}
A project-oriented allocator of memory engine :
The intent is that memory consumer modules are provided with such a buffer, with description (obviously the size, the start, the DMA-capability). The consumer MAY reject the buffer (undersized, not DMA-capable, whatever), but it MUST provides a way (documentation, error message, ...) to explain the reason why.
sample-ish code
Preparing and retrieving initialized buffers
The slot description