MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / init

Function init

kernel/src/memory/kernel_info.rs:30–45  ·  view source on GitHub ↗

Initialise a frame to hold the KernelInfo struct

(
    frame_allocator: &mut impl FrameAllocator<Size4KiB>,
    physical_memory_offset: VirtAddr
)

Source from the content-addressed store, hash-verified

28
29/// Initialise a frame to hold the KernelInfo struct
30pub 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
47pub fn get_ref() -> &'static KernelInfo {
48 let ptr = FRAME_VIRTADDR.load(Ordering::Relaxed) as *const KernelInfo;

Callers

nothing calls this directly

Calls 2

allocate_frameMethod · 0.80
as_u64Method · 0.45

Tested by

no test coverage detected