Initialise a frame to hold the KernelInfo struct
(
frame_allocator: &mut impl FrameAllocator<Size4KiB>,
physical_memory_offset: VirtAddr
)
| 28 | |
| 29 | /// Initialise a frame to hold the KernelInfo struct |
| 30 | pub fn init( |
| 31 | frame_allocator: &mut impl FrameAllocator<Size4KiB>, |
| 32 | physical_memory_offset: VirtAddr |
| 33 | ) -> Result<(), MapToError<Size4KiB>> { |
| 34 | |
| 35 | // Get one frame |
| 36 | let frame = frame_allocator |
| 37 | .allocate_frame() |
| 38 | .ok_or(MapToError::FrameAllocationFailed)?; |
| 39 | |
| 40 | // This frame is already mapped. Save its physical and virtual addresses |
| 41 | FRAME_PHYSADDR.store(frame.start_address().as_u64(), Ordering::Relaxed); |
| 42 | FRAME_VIRTADDR.store(physical_memory_offset.as_u64() + frame.start_address().as_u64(), |
| 43 | Ordering::Relaxed); |
| 44 | Ok(()) |
| 45 | } |
| 46 | |
| 47 | pub fn get_ref() -> &'static KernelInfo { |
| 48 | let ptr = FRAME_VIRTADDR.load(Ordering::Relaxed) as *const KernelInfo; |
nothing calls this directly
no test coverage detected