boot: move create_untypeds() to generic code

Also merge create_device_untypeds() and create_kernel_untypeds() into
create_untypeds() to simplify the code.

Signed-off-by: Axel Heider <axelheider@gmx.de>
This commit is contained in:
Axel Heider 2021-07-01 19:07:59 +02:00 committed by Gerwin Klein
parent 379bf5abe3
commit 89a5b8fd31
5 changed files with 13 additions and 65 deletions

View file

@ -48,8 +48,7 @@ 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_device_untypeds(cap_t root_cnode_cap, seL4_SlotPos slot_pos_before);
bool_t create_kernel_untypeds(cap_t root_cnode_cap, region_t boot_mem_reuse_reg, seL4_SlotPos first_untyped_slot);
bool_t create_untypeds(cap_t root_cnode_cap, region_t boot_mem_reuse_reg);
void bi_finalise(void);
void create_domain_cap(cap_t root_cnode_cap);

View file

@ -136,23 +136,6 @@ BOOT_CODE static void init_smmu(cap_t root_cnode_cap)
#endif
BOOT_CODE static bool_t create_untypeds(cap_t root_cnode_cap, region_t boot_mem_reuse_reg)
{
seL4_SlotPos slot_pos_before;
seL4_SlotPos slot_pos_after;
slot_pos_before = ndks_boot.slot_pos_cur;
create_device_untypeds(root_cnode_cap, slot_pos_before);
create_kernel_untypeds(root_cnode_cap, boot_mem_reuse_reg, slot_pos_before);
slot_pos_after = ndks_boot.slot_pos_cur;
ndks_boot.bi_frame->untyped = (seL4_SlotRegion) {
slot_pos_before, slot_pos_after
};
return true;
}
/** This and only this function initialises the CPU.
*
* It does NOT initialise any kernel state.

View file

@ -26,23 +26,6 @@ BOOT_BSS static volatile word_t node_boot_lock;
#define MAX_RESERVED 3
BOOT_BSS static region_t res_reg[MAX_RESERVED];
BOOT_CODE static bool_t create_untypeds(cap_t root_cnode_cap, region_t boot_mem_reuse_reg)
{
seL4_SlotPos slot_pos_before;
seL4_SlotPos slot_pos_after;
slot_pos_before = ndks_boot.slot_pos_cur;
create_device_untypeds(root_cnode_cap, slot_pos_before);
bool_t res = create_kernel_untypeds(root_cnode_cap, boot_mem_reuse_reg, slot_pos_before);
slot_pos_after = ndks_boot.slot_pos_cur;
ndks_boot.bi_frame->untyped = (seL4_SlotRegion) {
slot_pos_before, slot_pos_after
};
return res;
}
BOOT_CODE cap_t create_mapped_it_frame_cap(cap_t pd_cap, pptr_t pptr, vptr_t vptr, asid_t asid, bool_t
use_large, bool_t executable)
{

View file

@ -67,24 +67,6 @@ BOOT_CODE static void init_irqs(cap_t root_cnode_cap)
write_slot(SLOT_PTR(pptr_of_cap(root_cnode_cap), seL4_CapIRQControl), cap_irq_control_cap_new());
}
BOOT_CODE static bool_t create_untypeds(
cap_t root_cnode_cap,
region_t boot_mem_reuse_reg)
{
seL4_SlotPos slot_pos_before;
seL4_SlotPos slot_pos_after;
slot_pos_before = ndks_boot.slot_pos_cur;
create_device_untypeds(root_cnode_cap, slot_pos_before);
create_kernel_untypeds(root_cnode_cap, boot_mem_reuse_reg, slot_pos_before);
slot_pos_after = ndks_boot.slot_pos_cur;
ndks_boot.bi_frame->untyped = (seL4_SlotRegion) {
slot_pos_before, slot_pos_after
};
return true;
}
BOOT_CODE static bool_t arch_init_freemem(p_region_t ui_p_reg, v_region_t v_reg,
mem_p_regs_t *mem_p_regs,
word_t extra_bi_size_bits)

View file

@ -616,15 +616,18 @@ BOOT_CODE static bool_t create_untypeds_for_region(
return true;
}
BOOT_CODE bool_t create_device_untypeds(cap_t root_cnode_cap, seL4_SlotPos slot_pos_before)
BOOT_CODE bool_t create_untypeds(cap_t root_cnode_cap,
region_t boot_mem_reuse_reg)
{
seL4_SlotPos first_untyped_slot = ndks_boot.slot_pos_cur;
paddr_t start = 0;
for (word_t i = 0; i < ndks_boot.resv_count; i++) {
if (start < ndks_boot.reserved[i].start) {
region_t reg = paddr_to_pptr_reg((p_region_t) {
start, ndks_boot.reserved[i].start
});
if (!create_untypeds_for_region(root_cnode_cap, true, reg, slot_pos_before)) {
if (!create_untypeds_for_region(root_cnode_cap, true, reg, first_untyped_slot)) {
return false;
}
}
@ -643,17 +646,10 @@ BOOT_CODE bool_t create_device_untypeds(cap_t root_cnode_cap, seL4_SlotPos slot_
if (reg.end > PPTR_TOP) {
reg.end = PPTR_TOP;
}
if (!create_untypeds_for_region(root_cnode_cap, true, reg, slot_pos_before)) {
if (!create_untypeds_for_region(root_cnode_cap, true, reg, first_untyped_slot)) {
return false;
}
}
return true;
}
BOOT_CODE bool_t create_kernel_untypeds(cap_t root_cnode_cap, region_t boot_mem_reuse_reg,
seL4_SlotPos first_untyped_slot)
{
region_t reg;
/* 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, first_untyped_slot)) {
@ -662,13 +658,18 @@ BOOT_CODE bool_t create_kernel_untypeds(cap_t root_cnode_cap, region_t boot_mem_
/* convert remaining freemem into UT objects and provide the caps */
for (word_t i = 0; i < MAX_NUM_FREEMEM_REG; i++) {
reg = 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, first_untyped_slot)) {
return false;
}
}
ndks_boot.bi_frame->untyped = (seL4_SlotRegion) {
.start = first_untyped_slot,
.end = ndks_boot.slot_pos_cur
};
return true;
}