diff --git a/kernel/src/arch/riscv/layout.rs b/kernel/src/arch/riscv/layout.rs index a13656b..30eb44c 100644 --- a/kernel/src/arch/riscv/layout.rs +++ b/kernel/src/arch/riscv/layout.rs @@ -33,6 +33,7 @@ extern "C" { } pub const PAGE_SIZE: usize = 4 * KIB; +pub const PAGE_BITS: usize = PAGE_SIZE.ilog2() as usize; pub const PAGE_LAYOUT: Layout = unsafe { Layout::from_size_align_unchecked(PAGE_SIZE, PAGE_SIZE) }; #[inline(always)] diff --git a/kernel/src/root.rs b/kernel/src/root.rs index 279d52e..abef2e7 100644 --- a/kernel/src/root.rs +++ b/kernel/src/root.rs @@ -86,10 +86,11 @@ fn create_untyped_memory(cnode_obj: &mut CNodeObject) -> usize { } trace!( - "[root] creating untyped memory: {}: {:?} -> {:?}", + "[root] creating untyped memory: {}: {:?} -> {:?}, slot #{}", memory_idx, start, - start + (1 << bits) + start + (1 << bits), + memory_idx ); let cap = UntypedCap::mint(0, bits, false, start); @@ -132,10 +133,11 @@ fn create_untyped_device(cnode_obj: &mut CNodeObject, fdt: &Fdt, memory_idx: usi } trace!( - "[root] creating untyped device: {}: {:?} -> {:?}", + "[root] creating untyped device: {}: {:?} -> {:?}, slot #{}", device_idx, start, - start + (1 << bits) + start + (1 << bits), + device_idx ); let cap = UntypedCap::mint(0, bits, true, start); @@ -190,19 +192,17 @@ fn create_objects(cnode_obj: &mut CNodeObject, end_idx: usize) -> usize { // tcb { - trace!("[root] allocating tcb object"); let tcb_idx = CNodeSlot::TcbCap as usize; - alloc::(cnode_obj, end_idx, 0, tcb_idx..tcb_idx + 1); + trace!("[root] allocating tcb object at slot #{}", tcb_idx); + alloc_objects::(cnode_obj, end_idx, 0, tcb_idx..tcb_idx + 1); } // vspace { - trace!("[root] allocating vspace object"); - let pagetable_bits = PAGE_SIZE.ilog2() as usize; - // root let vspace_idx = CNodeSlot::VSpaceCap as usize; - alloc::(cnode_obj, end_idx, pagetable_bits, vspace_idx..vspace_idx + 1); + trace!("[root] allocating vspace object at slot #{}", vspace_idx); + alloc_objects::(cnode_obj, end_idx, PAGE_BITS, vspace_idx..vspace_idx + 1); // copy pagetable let root = &cnode_obj[vspace_idx];