From 7b7d4a60432300936e0144f556dc5d36bd1e2a96 Mon Sep 17 00:00:00 2001 From: Axel Heider Date: Mon, 27 Dec 2021 13:49:06 +0100 Subject: [PATCH] pass seL4_BootInfo as parameter --- include/kernel/boot.h | 8 +++++--- src/arch/arm/kernel/boot.c | 3 ++- src/arch/riscv/kernel/boot.c | 3 ++- src/arch/x86/kernel/boot.c | 4 ++-- src/kernel/boot.c | 26 +++++++++++++------------- 5 files changed, 24 insertions(+), 20 deletions(-) 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 c2e220aa29..74a35aabd8 100644 --- a/src/arch/arm/kernel/boot.c +++ b/src/arch/arm/kernel/boot.c @@ -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 33b51fdaa2..565cd2f578 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 c9604d2c91..e31a74ea8c 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 4b35893cfa..d372b05937 100644 --- a/src/kernel/boot.c +++ b/src/kernel/boot.c @@ -426,10 +426,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++) { @@ -581,11 +580,11 @@ BOOT_CODE void init_core_state(tcb_t *scheduler_action) BOOT_CODE static int provide_untyped_cap( cap_t root_cnode_cap, + seL4_BootInfo *bi, bool_t is_device_memory, pptr_t pptr, word_t size_bits) { - seL4_BootInfo *bi = BI_PTR(rootserver.boot_info); assert(bi->untyped.start <= bi->empty.start); word_t i = bi->empty.start - bi->untyped.start; if (i >= ARRAY_SIZE(bi->untypedList)) { @@ -613,6 +612,7 @@ BOOT_CODE static int 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) { @@ -651,7 +651,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); if (0 != ret) { if (-2 == ret) { @@ -678,7 +678,8 @@ BOOT_CODE static bool_t create_untypeds_for_region( return true; } -BOOT_CODE static bool_t create_device_untypeds(cap_t root_cnode_cap) +BOOT_CODE static bool_t create_device_untypeds(cap_t root_cnode_cap, + seL4_BootInfo *bi) { /* Device memory cap are created for all physical memory from 0 to * CONFIG_PADDR_USER_DEVICE_TOP that is not marked as reserved. Such @@ -768,7 +769,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)) { + if (!create_untypeds_for_region(root_cnode_cap, bi, true, reg)) { printf("ERROR: creation of untypeds for device region" " [%"SEL4_PRIx_word"..%"SEL4_PRIx_word"] failed\n", reg_device.start, reg_device.end); @@ -780,6 +781,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. @@ -787,17 +789,16 @@ 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); bi->untyped.start = bi->empty.start; /* Create the device untypeds. */ - if (!create_device_untypeds(root_cnode_cap)) { + if (!create_device_untypeds(root_cnode_cap, bi)) { 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)) { + if (!create_untypeds_for_region(root_cnode_cap, bi, false, boot_mem_reuse_reg)) { 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); @@ -808,7 +809,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)) { + if (!create_untypeds_for_region(root_cnode_cap, bi, false, reg)) { 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); @@ -823,9 +824,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)); }