kernel_api/allocator/
vmm.rs1use crate::memory::RawPage;
2use crate::allocator::AllocError;
3
4pub trait Vmm {
6 #[must_use = "memory will be leaked unless the page is explicitly deallocated"]
14 fn allocate_contiguous(&self, len: usize) -> Result<RawPage, AllocError>;
15
16 #[must_use = "memory will be leaked unless the page is explicitly deallocated"]
24 fn allocate_contiguous_at(&self, at: RawPage, len: usize) -> Result<RawPage, AllocError>;
25
26 fn deallocate_contiguous(&self, base: RawPage, len: usize);
29}
30
31#[doc(hidden)]
33impl Vmm for ! {
34 fn allocate_contiguous(&self, _len: usize) -> Result<RawPage, AllocError> {
35 *self
36 }
37
38 fn allocate_contiguous_at(&self, _at: RawPage, _len: usize) -> Result<RawPage, AllocError> {
39 *self
40 }
41
42 fn deallocate_contiguous(&self, _base: RawPage, _len: usize) {}
43}