Skip to content

Commit

Permalink
boot: pass seL4_BootInfo as parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
axel-h committed Sep 14, 2022
1 parent 2ff1ac4 commit dd71a03
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
8 changes: 5 additions & 3 deletions include/kernel/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions src/arch/arm/kernel/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/arch/riscv/kernel/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86/kernel/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
25 changes: 13 additions & 12 deletions src/kernel/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -797,27 +799,27 @@ 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.
* Store the information at which slot the untypeds start. This is also used
* 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);
Expand All @@ -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);
Expand All @@ -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));
}
Expand Down

0 comments on commit dd71a03

Please sign in to comment.