1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use addr::*;
pub trait FrameAllocatorFor<P: PhysicalAddress> {
fn alloc(&mut self) -> Option<FrameWith<P>>;
}
pub trait FrameDeallocatorFor<P: PhysicalAddress> {
fn dealloc(&mut self, frame: FrameWith<P>);
}
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
pub trait FrameAllocator {
fn alloc(&mut self) -> Option<Frame>;
}
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
pub trait FrameDeallocator {
fn dealloc(&mut self, frame: Frame);
}
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
impl<T: FrameAllocator> FrameAllocatorFor<PhysAddr> for T {
#[inline]
fn alloc(&mut self) -> Option<Frame> {
FrameAllocator::alloc(self)
}
}
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
impl<T: FrameDeallocator> FrameDeallocatorFor<PhysAddr> for T {
#[inline]
fn dealloc(&mut self, frame: Frame) {
FrameDeallocator::dealloc(self, frame)
}
}