Skip to content

Commit

Permalink
pass seL4_BootInfo as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
axel-h committed Jan 10, 2022
1 parent 79f140b commit 7b7d4a6
Show file tree
Hide file tree
Showing 5 changed files with 24 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
3 changes: 2 additions & 1 deletion src/arch/arm/kernel/boot.c
Original file line number Diff line number Diff line change
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
26 changes: 13 additions & 13 deletions src/kernel/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -780,24 +781,24 @@ 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);
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);
Expand All @@ -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);
Expand All @@ -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));
}
Expand Down

0 comments on commit 7b7d4a6

Please sign in to comment.