diff --git a/include/kernel/boot.h b/include/kernel/boot.h index bb5b07fbc4..ddde44b54e 100644 --- a/include/kernel/boot.h +++ b/include/kernel/boot.h @@ -48,8 +48,9 @@ bool_t provide_cap(cap_t root_cnode_cap, cap_t cap, cap_t create_it_asid_pool(cap_t root_cnode_cap); void write_it_pd_pts(cap_t root_cnode_cap, cap_t it_pd_cap); bool_t create_idle_thread(void); -bool_t create_untypeds(cap_t root_cnode_cap, region_t boot_mem_reuse_reg); -void bi_finalise(void); +bool_t create_untypeds(cap_t root_cnode_cap, seL4_BootInfo *bi, + region_t boot_mem_reuse_reg); +void bi_finalise(seL4_BootInfo *bi); void create_domain_cap(cap_t root_cnode_cap); cap_t create_ipcbuf_frame_cap(cap_t root_cnode_cap, cap_t pd_cap, vptr_t vptr); @@ -59,7 +60,8 @@ seL4_BootInfo *populate_bi_frame(node_id_t node_id, word_t num_nodes, void create_bi_frame_cap(cap_t root_cnode_cap, cap_t pd_cap, vptr_t vptr); #ifdef CONFIG_KERNEL_MCS -bool_t init_sched_control(cap_t root_cnode_cap, word_t num_nodes); +bool_t init_sched_control(cap_t root_cnode_cap, seL4_BootInfo *bi, + word_t num_nodes); #endif typedef struct create_frames_of_region_ret { diff --git a/src/arch/arm/kernel/boot.c b/src/arch/arm/kernel/boot.c index a35fd63690..84a52610f1 100644 --- a/src/arch/arm/kernel/boot.c +++ b/src/arch/arm/kernel/boot.c @@ -495,7 +495,7 @@ static BOOT_CODE bool_t try_init_kernel( } #ifdef CONFIG_KERNEL_MCS - init_sched_control(root_cnode_cap, CONFIG_MAX_NUM_NODES); + init_sched_control(root_cnode_cap, bi, CONFIG_MAX_NUM_NODES); #endif /* create the initial thread's IPC buffer */ @@ -557,6 +557,7 @@ static BOOT_CODE bool_t try_init_kernel( /* create all of the untypeds. Both devices and kernel window memory */ if (!create_untypeds( root_cnode_cap, + bi, (region_t) { KERNEL_ELF_BASE, (pptr_t)ki_boot_end } /* reusable boot code/data */ @@ -569,7 +570,7 @@ static BOOT_CODE bool_t try_init_kernel( bi->sharedFrames = S_REG_EMPTY; /* finalise the bootinfo frame */ - bi_finalise(); + bi_finalise(bi); /* Flushing the L1 cache and invalidating the TLB is good enough here to * make sure everything written by the kernel is visible to userland. There diff --git a/src/arch/riscv/kernel/boot.c b/src/arch/riscv/kernel/boot.c index ee555522af..d3833dabd9 100644 --- a/src/arch/riscv/kernel/boot.c +++ b/src/arch/riscv/kernel/boot.c @@ -409,6 +409,7 @@ static BOOT_CODE bool_t try_init_kernel( /* convert the remaining free memory into UT objects and provide the caps */ if (!create_untypeds( root_cnode_cap, + bi, boot_mem_reuse_reg)) { printf("ERROR: could not create untypteds for kernel image boot memory\n"); return false; @@ -418,7 +419,7 @@ static BOOT_CODE bool_t try_init_kernel( bi->sharedFrames = S_REG_EMPTY; /* finalise the bootinfo frame */ - bi_finalise(); + bi_finalise(bi); ksNumCPUs = 1; diff --git a/src/arch/x86/kernel/boot.c b/src/arch/x86/kernel/boot.c index e40c713a9b..c273a76a39 100644 --- a/src/arch/x86/kernel/boot.c +++ b/src/arch/x86/kernel/boot.c @@ -320,12 +320,12 @@ BOOT_CODE bool_t init_sys_state( #endif /* create all of the untypeds. Both devices and kernel window memory */ - if (!create_untypeds(root_cnode_cap, boot_mem_reuse_reg)) { + if (!create_untypeds(root_cnode_cap, bi, boot_mem_reuse_reg)) { return false; } /* finalise the bootinfo frame */ - bi_finalise(); + bi_finalise(bi); return true; } diff --git a/src/kernel/boot.c b/src/kernel/boot.c index c9ca0d5395..3a3d3c87f3 100644 --- a/src/kernel/boot.c +++ b/src/kernel/boot.c @@ -428,10 +428,9 @@ BOOT_CODE static bool_t configure_sched_context(tcb_t *tcb, sched_context_t *sc_ return true; } -BOOT_CODE bool_t init_sched_control(cap_t root_cnode_cap, word_t num_nodes) +BOOT_CODE bool_t init_sched_control(cap_t root_cnode_cap, seL4_BootInfo *bi, + word_t num_nodes) { - seL4_BootInfo *bi = BI_PTR(rootserver.boot_info); - /* create a sched control cap for each core */ for (unsigned int i = 0; i < num_nodes; i++) { @@ -583,13 +582,14 @@ BOOT_CODE void init_core_state(tcb_t *scheduler_action) BOOT_CODE static bool_t provide_untyped_cap( cap_t root_cnode_cap, + seL4_BootInfo *bi, bool_t is_device_memory, pptr_t pptr, word_t size_bits, seL4_SlotRegion *slot_region ) { - seL4_BootInfo *bi = BI_PTR(rootserver.boot_info); + assert(bi); word_t i = 0; /* Sanity check, that the whole untyped creation for a specific slot region @@ -628,6 +628,7 @@ BOOT_CODE static bool_t provide_untyped_cap( BOOT_CODE static bool_t create_untypeds_for_region( cap_t root_cnode_cap, + seL4_BootInfo *bi, bool_t is_device_memory, region_t reg, seL4_SlotRegion *slot_region) @@ -667,7 +668,7 @@ BOOT_CODE static bool_t create_untypeds_for_region( * be used anyway. */ if (size_bits >= seL4_MinUntypedBits) { - int ret = provide_untyped_cap(root_cnode_cap, is_device_memory, + int ret = provide_untyped_cap(root_cnode_cap, bi, is_device_memory, reg.start, size_bits, slot_region); if (0 != ret) { if (-2 == ret) { @@ -695,6 +696,7 @@ BOOT_CODE static bool_t create_untypeds_for_region( } BOOT_CODE static bool_t create_device_untypeds(cap_t root_cnode_cap, + seL4_BootInfo *bi, seL4_SlotRegion *slot_region) { /* Device memory cap are created for all physical memory from 0 to @@ -785,7 +787,7 @@ BOOT_CODE static bool_t create_device_untypeds(cap_t root_cnode_cap, reg_device.end - reg.end, reg_device.end, reg.end); } - if (!create_untypeds_for_region(root_cnode_cap, true, reg, slot_region)) { + if (!create_untypeds_for_region(root_cnode_cap, bi, true, reg, slot_region)) { printf("ERROR: creation of untypeds for device region" " [%"SEL4_PRIx_word"..%"SEL4_PRIx_word"] failed\n", reg_device.start, reg_device.end); @@ -797,6 +799,7 @@ BOOT_CODE static bool_t create_device_untypeds(cap_t root_cnode_cap, } BOOT_CODE bool_t create_untypeds(cap_t root_cnode_cap, + seL4_BootInfo *bi, region_t boot_mem_reuse_reg) { /* The boot info stores information about the caps that exist in the system. @@ -804,20 +807,19 @@ BOOT_CODE bool_t create_untypeds(cap_t root_cnode_cap, * during the following untyped creation to ensure the number does not * exceed CONFIG_MAX_NUM_BOOTINFO_UNTYPED_CAPS. */ - seL4_BootInfo *bi = BI_PTR(rootserver.boot_info); seL4_SlotRegion *bi_slot_region = &(bi->untyped); assert(0 == bi_slot_region->start); assert(0 == bi_slot_region->end); /* Create the device untypeds. */ - if (!create_device_untypeds(root_cnode_cap, bi_slot_region)) { + if (!create_device_untypeds(root_cnode_cap, bi, bi_slot_region)) { printf("ERROR: creation of device untypeds failed\n"); return false; } /* if boot_mem_reuse_reg is not empty, we can create UT objs from boot code/data frames */ - if (!create_untypeds_for_region(root_cnode_cap, false, boot_mem_reuse_reg, bi_slot_region)) { + if (!create_untypeds_for_region(root_cnode_cap, bi, false, boot_mem_reuse_reg, bi_slot_region)) { printf("ERROR: creation of untypeds for recycled boot memory" " [%"SEL4_PRIx_word"..%"SEL4_PRIx_word"] failed\n", boot_mem_reuse_reg.start, boot_mem_reuse_reg.end); @@ -828,7 +830,7 @@ BOOT_CODE bool_t create_untypeds(cap_t root_cnode_cap, for (word_t i = 0; i < ARRAY_SIZE(ndks_boot.freemem); i++) { region_t reg = ndks_boot.freemem[i]; ndks_boot.freemem[i] = REG_EMPTY; - if (!create_untypeds_for_region(root_cnode_cap, false, reg, bi_slot_region)) { + if (!create_untypeds_for_region(root_cnode_cap, bi, false, reg, bi_slot_region)) { printf("ERROR: creation of untypeds for free memory region #%u at" " [%"SEL4_PRIx_word"..%"SEL4_PRIx_word"] failed\n", (unsigned int)i, reg.start, reg.end); @@ -843,9 +845,8 @@ BOOT_CODE bool_t create_untypeds(cap_t root_cnode_cap, return true; } -BOOT_CODE void bi_finalise(void) +BOOT_CODE void bi_finalise(seL4_BootInfo *bi) { - seL4_BootInfo *bi = BI_PTR(rootserver.boot_info); assert(bi->empty.start <= BIT(CONFIG_ROOT_CNODE_SIZE_BITS)); assert(bi->empty.end == BIT(CONFIG_ROOT_CNODE_SIZE_BITS)); }