Add extra reserved region to RISC-V boot protocol

Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
This commit is contained in:
Ivan-Velickovic
2024-08-05 10:25:08 +10:00
parent 0cdbffec9c
commit 4cae30a6ef
3 changed files with 34 additions and 8 deletions

View File

@@ -19,8 +19,9 @@
* +1 for kernel
* +1 for device tree binary
* +1 for user image.
* +1 loader specified extra memory
*/
#define NUM_RESERVED_REGIONS 3
#define NUM_RESERVED_REGIONS 4
/* The maximum number of reserved regions is:
* +1 for each free memory region (MAX_NUM_FREEMEM_REG)

View File

@@ -20,7 +20,9 @@ void init_kernel(
sword_t pv_offset,
vptr_t v_entry,
paddr_t dtb_addr_p,
uint32_t dtb_size
uint64_t dtb_size,
paddr_t extra_device_addr_p,
uint64_t extra_device_size
#ifdef ENABLE_SMP_SUPPORT
,
word_t hart_id,

View File

@@ -59,6 +59,7 @@ BOOT_CODE cap_t create_mapped_it_frame_cap(cap_t pd_cap, pptr_t pptr, vptr_t vpt
BOOT_CODE static bool_t arch_init_freemem(region_t ui_reg,
p_region_t dtb_p_reg,
p_region_t extra_device_p_reg,
v_region_t it_v_reg,
word_t extra_bi_size_bits)
{
@@ -79,6 +80,11 @@ BOOT_CODE static bool_t arch_init_freemem(region_t ui_reg,
index += 1;
}
if (extra_device_p_reg.start) {
res_reg[index] = paddr_to_pptr_reg(extra_device_p_reg);
index++;
}
/* reserve the user image region */
if (index >= ARRAY_SIZE(res_reg)) {
printf("ERROR: no slot to add user image to reserved regions\n");
@@ -196,7 +202,9 @@ static BOOT_CODE bool_t try_init_kernel(
sword_t pv_offset,
vptr_t v_entry,
paddr_t dtb_phys_addr,
word_t dtb_size
word_t dtb_size,
paddr_t extra_device_addr_start,
word_t extra_device_size
)
{
cap_t root_cnode_cap;
@@ -206,6 +214,9 @@ static BOOT_CODE bool_t try_init_kernel(
region_t ui_reg = paddr_to_pptr_reg((p_region_t) {
ui_p_reg_start, ui_p_reg_end
});
p_region_t extra_device_p_reg = (p_region_t) {
extra_device_addr_start, extra_device_addr_start + extra_device_size
};
word_t extra_bi_size = 0;
pptr_t extra_bi_offset = 0;
vptr_t extra_bi_frame_vptr;
@@ -213,6 +224,7 @@ static BOOT_CODE bool_t try_init_kernel(
vptr_t ipcbuf_vptr;
create_frames_of_region_ret_t create_frames_ret;
create_frames_of_region_ret_t extra_bi_ret;
seL4_SlotPos first_untyped_slot;
/* convert from physical addresses to userland vptrs */
v_region_t ui_v_reg = {
@@ -290,7 +302,7 @@ static BOOT_CODE bool_t try_init_kernel(
}
/* make the free memory available to alloc_region() */
if (!arch_init_freemem(ui_reg, dtb_p_reg, it_v_reg, extra_bi_size_bits)) {
if (!arch_init_freemem(ui_reg, dtb_p_reg, extra_device_p_reg, it_v_reg, extra_bi_size_bits)) {
printf("ERROR: free memory management initialization failed\n");
return false;
}
@@ -425,10 +437,15 @@ static BOOT_CODE bool_t try_init_kernel(
init_core_state(initial);
first_untyped_slot = ndks_boot.slot_pos_cur;
if (extra_device_addr_start) {
create_untypeds_for_region(root_cnode_cap, true, paddr_to_pptr_reg(extra_device_p_reg), first_untyped_slot);
}
/* convert the remaining free memory into UT objects and provide the caps */
if (!create_untypeds(
root_cnode_cap,
ndks_boot.slot_pos_cur)) {
first_untyped_slot)) {
printf("ERROR: could not create untypteds for kernel image boot memory\n");
return false;
}
@@ -461,7 +478,9 @@ BOOT_CODE VISIBLE void init_kernel(
sword_t pv_offset,
vptr_t v_entry,
paddr_t dtb_addr_p,
uint32_t dtb_size
uint64_t dtb_size,
paddr_t extra_device_addr_p,
uint64_t extra_device_size
#ifdef ENABLE_SMP_SUPPORT
,
word_t hart_id,
@@ -479,7 +498,9 @@ BOOT_CODE VISIBLE void init_kernel(
pv_offset,
v_entry,
dtb_addr_p,
dtb_size);
dtb_size,
extra_device_addr_p,
extra_device_size);
} else {
result = try_init_kernel_secondary_core(hart_id, core_id);
}
@@ -489,7 +510,9 @@ BOOT_CODE VISIBLE void init_kernel(
pv_offset,
v_entry,
dtb_addr_p,
dtb_size);
dtb_size,
extra_device_addr_p,
extra_device_size);
#endif
if (!result) {
fail("ERROR: kernel init failed");