forked from Imagelibrary/seL4
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08871fea6f | ||
|
|
eb8f78ae06 | ||
|
|
8a2f5022c2 | ||
|
|
3aafe9e0b9 | ||
|
|
2aa12e5d8a | ||
|
|
4b97df4c7e | ||
|
|
968d8f6f97 | ||
|
|
49273c155b | ||
|
|
53100c623e | ||
|
|
9919e7db30 | ||
|
|
0383d0f468 | ||
|
|
29ee490ec4 | ||
|
|
4cae30a6ef | ||
|
|
0cdbffec9c | ||
|
|
57975d4853 | ||
|
|
7008430d44 | ||
|
|
92f0f3ab28 | ||
|
|
c8ef493d03 |
@@ -15,16 +15,18 @@
|
||||
* +1 for each MODE_RESERVED region, there might be none
|
||||
* +1 to allow the kernel to release its own boot data region
|
||||
* +1 for a possible gap between ELF images and rootserver objects
|
||||
* +1 loader specified extra memory
|
||||
*/
|
||||
#define MAX_NUM_FREEMEM_REG (ARRAY_SIZE(avail_p_regs) + MODE_RESERVED + 1 + 1)
|
||||
#define MAX_NUM_FREEMEM_REG (ARRAY_SIZE(avail_p_regs) + MODE_RESERVED + 1 + 1 + 1)
|
||||
|
||||
/* The regions reserved by the boot code are:
|
||||
* +1 for kernel
|
||||
* +1 for device tree binary
|
||||
* +1 for user image.
|
||||
* +1 loader specified extra memory
|
||||
* +1 for each the MODE_RESERVED region, there might be none
|
||||
*/
|
||||
#define NUM_RESERVED_REGIONS (3 + MODE_RESERVED)
|
||||
#define NUM_RESERVED_REGIONS (4 + MODE_RESERVED)
|
||||
|
||||
|
||||
/* The maximum number of reserved regions is:
|
||||
|
||||
@@ -18,6 +18,8 @@ void init_kernel(
|
||||
sword_t pv_offset,
|
||||
vptr_t v_entry,
|
||||
paddr_t dtb_addr_p,
|
||||
uint32_t dtb_size
|
||||
word_t dtb_size,
|
||||
paddr_t extra_device_addr_p,
|
||||
word_t extra_device_size
|
||||
);
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -20,7 +20,9 @@ void init_kernel(
|
||||
sword_t pv_offset,
|
||||
vptr_t v_entry,
|
||||
paddr_t dtb_addr_p,
|
||||
uint32_t dtb_size
|
||||
word_t dtb_size,
|
||||
paddr_t extra_device_addr_p,
|
||||
word_t extra_device_size
|
||||
#ifdef ENABLE_SMP_SUPPORT
|
||||
,
|
||||
word_t hart_id,
|
||||
|
||||
@@ -51,7 +51,8 @@ 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);
|
||||
void create_idle_thread(void);
|
||||
bool_t create_untypeds(cap_t root_cnode_cap);
|
||||
bool_t create_untypeds_for_region(cap_t root_cnode_cap, bool_t device_memory, region_t reg, seL4_SlotPos first_untyped_slot);
|
||||
bool_t create_untypeds(cap_t root_cnode_cap, seL4_SlotPos first_untyped_slot);
|
||||
void bi_finalise(void);
|
||||
void create_domain_cap(cap_t root_cnode_cap);
|
||||
|
||||
|
||||
@@ -78,10 +78,11 @@
|
||||
.section .boot.text, "ax"
|
||||
BEGIN_FUNC(_start)
|
||||
/*
|
||||
* Get the dtb and dtb size from the elfloader stack. Do this first because
|
||||
* sp might change when we switch to supervisor mode.
|
||||
* Get the dtb, dtb size, extra device base and extra device size
|
||||
* from the elfloader stack. Do this first because sp might change
|
||||
* when we switch to supervisor mode.
|
||||
*/
|
||||
pop {r7, r8}
|
||||
pop {r7, r8, r9, r10}
|
||||
|
||||
/* Supervisor/hypervisor mode, interrupts disabled */
|
||||
ldr r5, =CPSR_KERNEL
|
||||
@@ -164,12 +165,12 @@ BEGIN_FUNC(_start)
|
||||
#endif
|
||||
|
||||
/* Attempt to workaround any known ARM errata. */
|
||||
push {r0-r3,r7-r8}
|
||||
push {r0-r3,r7-r10}
|
||||
blx arm_errata
|
||||
pop {r0-r3,r7-r8}
|
||||
pop {r0-r3,r7-r10}
|
||||
|
||||
/* Put the DTB address back on the new stack for init_kernel. */
|
||||
push {r7, r8}
|
||||
/* Put the DTB and dev region address back on the new stack for init_kernel. */
|
||||
push {r7, r8, r9, r10}
|
||||
|
||||
/* Call bootstrapping implemented in C with parameters:
|
||||
* r0: user image physical start address
|
||||
@@ -178,6 +179,8 @@ BEGIN_FUNC(_start)
|
||||
* r3: user image virtual entry address
|
||||
* sp[0]: DTB physical address (0 if there is none)
|
||||
* sp[1]: DTB size (0 if there is none)
|
||||
* sp[2]: extra device addr (0 if there is none)
|
||||
* sp[3]: extra device size (0 if there is none)
|
||||
*/
|
||||
blx init_kernel
|
||||
|
||||
|
||||
@@ -77,9 +77,11 @@
|
||||
|
||||
.section .boot.text, "ax"
|
||||
BEGIN_FUNC(_start)
|
||||
/* Save x4 and x5 so we don't clobber it */
|
||||
mov x7, x4
|
||||
mov x8, x5
|
||||
/* Save x4, x5, x6, x7 so we don't clobber it */
|
||||
mov x14, x4
|
||||
mov x15, x5
|
||||
mov x16, x6
|
||||
mov x17, x7
|
||||
|
||||
/* Make sure interrupts are disabled */
|
||||
msr daifset, #DAIFSET_MASK
|
||||
@@ -118,8 +120,10 @@ BEGIN_FUNC(_start)
|
||||
/* Attempt to workaround any known ARM errata. */
|
||||
stp x0, x1, [sp, #-16]!
|
||||
stp x2, x3, [sp, #-16]!
|
||||
stp x7, x8, [sp, #-16]!
|
||||
stp x14, x15, [sp, #-16]!
|
||||
stp x16, x17, [sp, #-16]!
|
||||
bl arm_errata
|
||||
ldp x6, x7, [sp], #16
|
||||
ldp x4, x5, [sp], #16
|
||||
ldp x2, x3, [sp], #16
|
||||
ldp x0, x1, [sp], #16
|
||||
@@ -131,6 +135,8 @@ BEGIN_FUNC(_start)
|
||||
* x3: user image virtual entry address
|
||||
* x4: DTB physical address (0 if there is none)
|
||||
* x5: DTB size (0 if there is none)
|
||||
* x6: extra device memory region (0 if there is none)
|
||||
* x7: extra device size (0 if there is none)
|
||||
*/
|
||||
bl init_kernel
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ BOOT_BSS static region_t reserved[NUM_RESERVED_REGIONS];
|
||||
|
||||
BOOT_CODE static bool_t arch_init_freemem(p_region_t ui_p_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)
|
||||
{
|
||||
@@ -60,6 +61,13 @@ BOOT_CODE static bool_t arch_init_freemem(p_region_t ui_p_reg,
|
||||
index++;
|
||||
}
|
||||
|
||||
if (extra_device_p_reg.start) {
|
||||
/* the dtb region could be empty */
|
||||
reserved[index].start = (pptr_t) paddr_to_pptr(extra_device_p_reg.start);
|
||||
reserved[index].end = (pptr_t) paddr_to_pptr(extra_device_p_reg.end);
|
||||
index++;
|
||||
}
|
||||
|
||||
/* Reserve the user image region and the mode-reserved regions. For now,
|
||||
* only one mode-reserved region is supported, because this is all that is
|
||||
* needed.
|
||||
@@ -337,7 +345,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;
|
||||
@@ -347,6 +357,9 @@ static BOOT_CODE bool_t try_init_kernel(
|
||||
p_region_t ui_p_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
|
||||
};
|
||||
region_t ui_reg = paddr_to_pptr_reg(ui_p_reg);
|
||||
word_t extra_bi_size = 0;
|
||||
pptr_t extra_bi_offset = 0;
|
||||
@@ -355,6 +368,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 = {
|
||||
@@ -429,7 +443,7 @@ static BOOT_CODE bool_t try_init_kernel(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!arch_init_freemem(ui_p_reg, dtb_p_reg, it_v_reg, extra_bi_size_bits)) {
|
||||
if (!arch_init_freemem(ui_p_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;
|
||||
}
|
||||
@@ -588,8 +602,13 @@ 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);
|
||||
}
|
||||
|
||||
/* create all of the untypeds. Both devices and kernel window memory */
|
||||
if (!create_untypeds(root_cnode_cap)) {
|
||||
if (!create_untypeds(root_cnode_cap, first_untyped_slot)) {
|
||||
printf("ERROR: could not create untypteds for kernel image boot memory\n");
|
||||
return false;
|
||||
}
|
||||
@@ -637,7 +656,9 @@ BOOT_CODE VISIBLE void init_kernel(
|
||||
sword_t pv_offset,
|
||||
vptr_t v_entry,
|
||||
paddr_t dtb_addr_p,
|
||||
uint32_t dtb_size
|
||||
word_t dtb_size,
|
||||
paddr_t extra_device_addr_p,
|
||||
word_t extra_device_size
|
||||
)
|
||||
{
|
||||
bool_t result;
|
||||
@@ -649,7 +670,9 @@ BOOT_CODE VISIBLE void init_kernel(
|
||||
ui_p_reg_end,
|
||||
pv_offset,
|
||||
v_entry,
|
||||
dtb_addr_p, dtb_size);
|
||||
dtb_addr_p, dtb_size,
|
||||
extra_device_addr_p, extra_device_size
|
||||
);
|
||||
} else {
|
||||
result = try_init_kernel_secondary_core();
|
||||
}
|
||||
@@ -659,7 +682,9 @@ BOOT_CODE VISIBLE void init_kernel(
|
||||
ui_p_reg_end,
|
||||
pv_offset,
|
||||
v_entry,
|
||||
dtb_addr_p, dtb_size);
|
||||
dtb_addr_p, dtb_size,
|
||||
extra_device_addr_p, extra_device_size
|
||||
);
|
||||
|
||||
#endif /* ENABLE_SMP_SUPPORT */
|
||||
|
||||
|
||||
@@ -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,8 +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)) {
|
||||
if (!create_untypeds(
|
||||
root_cnode_cap,
|
||||
first_untyped_slot)) {
|
||||
printf("ERROR: could not create untypteds for kernel image boot memory\n");
|
||||
return false;
|
||||
}
|
||||
@@ -459,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
|
||||
word_t dtb_size,
|
||||
paddr_t extra_device_addr_p,
|
||||
word_t extra_device_size
|
||||
#ifdef ENABLE_SMP_SUPPORT
|
||||
,
|
||||
word_t hart_id,
|
||||
@@ -477,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);
|
||||
}
|
||||
@@ -487,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");
|
||||
|
||||
@@ -327,7 +327,7 @@ 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)) {
|
||||
if (!create_untypeds(root_cnode_cap, ndks_boot.slot_pos_cur)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -718,7 +718,7 @@ BOOT_CODE static bool_t provide_untyped_cap(
|
||||
* @param first_untyped_slot First available untyped boot info slot.
|
||||
* @return true on success, false on failure.
|
||||
*/
|
||||
BOOT_CODE static bool_t create_untypeds_for_region(
|
||||
BOOT_CODE bool_t create_untypeds_for_region(
|
||||
cap_t root_cnode_cap,
|
||||
bool_t device_memory,
|
||||
region_t reg,
|
||||
@@ -764,10 +764,10 @@ BOOT_CODE static bool_t create_untypeds_for_region(
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOT_CODE bool_t create_untypeds(cap_t root_cnode_cap)
|
||||
BOOT_CODE bool_t create_untypeds(cap_t root_cnode_cap,
|
||||
seL4_SlotPos first_untyped_slot
|
||||
)
|
||||
{
|
||||
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) {
|
||||
|
||||
@@ -44,7 +44,6 @@ import os
|
||||
|
||||
StringTypes = (str, bytes)
|
||||
|
||||
|
||||
def func_code(f):
|
||||
return f.__code__
|
||||
|
||||
|
||||
Reference in New Issue
Block a user