boot: allocate irq cnode statically

The memory used for the irq cnode is never available to the user. As a
result this memory can be allocated statically, simplifying the
bootcode.

- remove allocation of irq cnode
- add static init
- generate irq cnode size from cmake for arm
- add static constants for riscv, x86 as there is no variability at the
moment.
This commit is contained in:
Anna Lyons 2019-04-09 17:38:58 +10:00
parent 6a31a57ef8
commit a6b4cf739d
10 changed files with 20 additions and 36 deletions

View file

@ -58,7 +58,6 @@ bool_t create_untypeds_for_region(cap_t root_cnode_cap, bool_t device_memory, re
seL4_SlotPos first_untyped_slot); seL4_SlotPos first_untyped_slot);
bool_t create_kernel_untypeds(cap_t root_cnode_cap, region_t boot_mem_reuse_reg, seL4_SlotPos first_untyped_slot); bool_t create_kernel_untypeds(cap_t root_cnode_cap, region_t boot_mem_reuse_reg, seL4_SlotPos first_untyped_slot);
void bi_finalise(void); void bi_finalise(void);
bool_t create_irq_cnode(void);
void create_domain_cap(cap_t root_cnode_cap); void create_domain_cap(cap_t root_cnode_cap);
cap_t create_ipcbuf_frame(cap_t root_cnode_cap, cap_t pd_cap, vptr_t vptr); cap_t create_ipcbuf_frame(cap_t root_cnode_cap, cap_t pd_cap, vptr_t vptr);

View file

@ -17,6 +17,7 @@
/* interrupt vectors (corresponds to IDT entries) */ /* interrupt vectors (corresponds to IDT entries) */
#define IRQ_INT_OFFSET 0x20 #define IRQ_INT_OFFSET 0x20
#define IRQ_CNODE_SLOT_BITS 8
typedef enum _interrupt_t { typedef enum _interrupt_t {
int_invalid = -1, int_invalid = -1,

View file

@ -28,6 +28,7 @@ enum IRQConstants {
} platform_interrupt_t; } platform_interrupt_t;
#define KERNEL_TIMER_IRQ INTERRUPT_TIMER #define KERNEL_TIMER_IRQ INTERRUPT_TIMER
#define IRQ_CNODE_SLOT_BITS 3
enum irqNumbers { enum irqNumbers {
irqInvalid = 6 irqInvalid = 6

View file

@ -76,6 +76,18 @@ function(declare_default_headers)
"TIMER_FREQUENCY;MAX_IRQ;INTERRUPT_CONTROLLER;TIMER;SMMU" "TIMER_FREQUENCY;MAX_IRQ;INTERRUPT_CONTROLLER;TIMER;SMMU"
"" ""
) )
# calculate the irq cnode size based on MAX_IRQ
set(BITS "0")
set(MAX "${CONFIGURE_MAX_IRQ}")
while(MAX GREATER "0")
math(EXPR BITS "${BITS} + 1")
math(EXPR MAX "${MAX} >> 1")
endwhile()
math(EXPR SLOTS "1 << ${BITS}")
if("${SLOTS}" LESS "${CONFIGURE_MAX_IRQ}")
math(EXPR BITS "${BITS} + 1")
endif()
set(CONFIGURE_IRQ_SLOT_BITS "${BITS}")
# variables parsed by the above will be prepended with CONFIGURE_, so pipe them # variables parsed by the above will be prepended with CONFIGURE_, so pipe them
# straight to configure_file # straight to configure_file
configure_file( configure_file(

View file

@ -448,11 +448,6 @@ static BOOT_CODE bool_t try_init_kernel(
/* create the cap for managing thread domains */ /* create the cap for managing thread domains */
create_domain_cap(root_cnode_cap); create_domain_cap(root_cnode_cap);
/* create the IRQ CNode */
if (!create_irq_cnode()) {
return false;
}
/* initialise the IRQ states and provide the IRQ control cap */ /* initialise the IRQ states and provide the IRQ control cap */
init_irqs(root_cnode_cap); init_irqs(root_cnode_cap);

View file

@ -18,6 +18,7 @@ enum IRQConstants {
maxIRQ = @CONFIGURE_MAX_IRQ@ maxIRQ = @CONFIGURE_MAX_IRQ@
} platform_interrupt_t; } platform_interrupt_t;
#define IRQ_CNODE_SLOT_BITS (@CONFIGURE_IRQ_SLOT_BITS@)
#include <@CONFIGURE_INTERRUPT_CONTROLLER@> #include <@CONFIGURE_INTERRUPT_CONTROLLER@>
#include <@CONFIGURE_TIMER@> #include <@CONFIGURE_TIMER@>

View file

@ -258,11 +258,6 @@ static BOOT_CODE bool_t try_init_kernel(
/* create the cap for managing thread domains */ /* create the cap for managing thread domains */
create_domain_cap(root_cnode_cap); create_domain_cap(root_cnode_cap);
/* create the IRQ CNode */
if (!create_irq_cnode()) {
return false;
}
/* initialise the IRQ states and provide the IRQ control cap */ /* initialise the IRQ states and provide the IRQ control cap */
init_irqs(root_cnode_cap); init_irqs(root_cnode_cap);

View file

@ -313,11 +313,6 @@ BOOT_CODE bool_t init_sys_state(
/* create the cap for managing thread domains */ /* create the cap for managing thread domains */
create_domain_cap(root_cnode_cap); create_domain_cap(root_cnode_cap);
/* create the IRQ CNode */
if (!create_irq_cnode()) {
return false;
}
/* initialise the IRQ states and provide the IRQ control cap */ /* initialise the IRQ states and provide the IRQ control cap */
init_irqs(root_cnode_cap); init_irqs(root_cnode_cap);

View file

@ -22,8 +22,6 @@
#include <util.h> #include <util.h>
/* (node-local) state accessed only during bootstrapping */ /* (node-local) state accessed only during bootstrapping */
#define IRQ_CNODE_BITS (seL4_WordBits - clzl(maxIRQ * sizeof(cte_t)))
ndks_boot_t ndks_boot BOOT_DATA; ndks_boot_t ndks_boot BOOT_DATA;
BOOT_CODE bool_t insert_region(region_t reg) BOOT_CODE bool_t insert_region(region_t reg)
@ -160,22 +158,6 @@ create_root_cnode(void)
return cap; return cap;
} }
BOOT_CODE bool_t create_irq_cnode(void)
{
pptr_t pptr;
assert(BIT(IRQ_CNODE_BITS - seL4_SlotBits) > maxIRQ);
/* create an empty IRQ CNode */
pptr = alloc_region(IRQ_CNODE_BITS);
if (!pptr) {
printf("Kernel init failing: could not create irq cnode\n");
return false;
}
memzero((void *)pptr, 1 << IRQ_CNODE_BITS);
intStateIRQNode = (cte_t *)pptr;
return true;
}
/* Check domain scheduler assumptions. */ /* Check domain scheduler assumptions. */
compile_assert(num_domains_valid, compile_assert(num_domains_valid,
CONFIG_NUM_DOMAINS >= 1 && CONFIG_NUM_DOMAINS <= 256) CONFIG_NUM_DOMAINS >= 1 && CONFIG_NUM_DOMAINS <= 256)

View file

@ -56,9 +56,12 @@ UP_STATE_DEFINE(tcb_t *, ksDebugTCBs);
* pending interrupts */ * pending interrupts */
word_t ksWorkUnitsCompleted; word_t ksWorkUnitsCompleted;
/* CNode containing interrupt handler endpoints */
irq_state_t intStateIRQTable[maxIRQ + 1]; irq_state_t intStateIRQTable[maxIRQ + 1];
cte_t *intStateIRQNode; /* CNode containing interrupt handler endpoints - like all seL4 objects, this CNode needs to be
* of a size that is a power of 2 and aligned to its size. */
static cte_t intStateIRQObj[BIT(IRQ_CNODE_SLOT_BITS)] ALIGN(BIT(IRQ_CNODE_SLOT_BITS + seL4_SlotBits));
cte_t *intStateIRQNode = intStateIRQObj;
compile_assert(irqCNodeSize, sizeof(intStateIRQObj) >= (maxIRQ *sizeof(cte_t)));
/* Currently active domain */ /* Currently active domain */
dom_t ksCurDomain; dom_t ksCurDomain;