Nothing to see here, move along
1pub mod addr;
2pub mod frame;
3pub mod phys;
4pub mod refcount;
5pub mod typed_addr;
6pub mod virt;
7
8pub(crate) struct RawSlice<T> {
9 ptr: *mut T,
10 len: usize,
11}
12
13unsafe impl<T: Send> Send for RawSlice<T> {}
14
15impl<T> RawSlice<T> {
16 pub const fn empty() -> Self {
17 Self {
18 ptr: core::ptr::null_mut(),
19 len: 0,
20 }
21 }
22
23 pub fn init(&mut self, ptr: *mut T, len: usize) {
24 self.ptr = ptr;
25 self.len = len;
26 }
27
28 pub fn as_slice(&self) -> &[T] {
29 match self.len {
30 0 => &[],
31 _ => unsafe { core::slice::from_raw_parts(self.ptr, self.len) },
32 }
33 }
34
35 pub fn as_slice_mut(&mut self) -> &mut [T] {
36 match self.len {
37 0 => &mut [],
38 _ => unsafe { core::slice::from_raw_parts_mut(self.ptr, self.len) },
39 }
40 }
41
42 pub fn len(&self) -> usize {
43 self.len
44 }
45}
46
47pub fn init(memory_map: &[&limine::memory_map::Entry], hhdm_offset: u64) {
48 addr::set_hhdm_offset(hhdm_offset);
49 phys::BitmapFrameAllocator::init(memory_map);
50 refcount::init(memory_map);
51}