X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Fcortex-m3%2Fhw%2Finit_lm3s.c;h=caac9d0905cfcf5608603942fab56ebb4e610ff1;hb=d9630fbb14997e3980bf0e4af4f0320a9bf69c12;hp=eaa05edfd6fe3db4235e1b9e437012a4842be28b;hpb=a61181f8614fe8257dc21bf1762a380165932348;p=bertos.git diff --git a/bertos/cpu/cortex-m3/hw/init_lm3s.c b/bertos/cpu/cortex-m3/hw/init_lm3s.c index eaa05edf..caac9d09 100644 --- a/bertos/cpu/cortex-m3/hw/init_lm3s.c +++ b/bertos/cpu/cortex-m3/hw/init_lm3s.c @@ -36,11 +36,16 @@ */ #include +#include /* CONFIG_KERN_PREEMPT */ +#include #include #include /* PAUSE */ -#include "drv/irq_lm3s.h" -#include "drv/clock_lm3s.h" -#include "io/lm3s.h" +#include /* IRQ_DISABLE */ +#include +#include +#include +#include +#include "switch_ctx_cm3.h" extern size_t __text_end, __data_start, __data_end, __bss_start, __bss_end; @@ -49,6 +54,11 @@ extern void __init2(void); /* Architecture's entry point */ void __init2(void) { + /* + * The main application expects IRQs disabled. + */ + IRQ_DISABLE; + /* * PLL may not function properly at default LDO setting. * @@ -75,4 +85,24 @@ void __init2(void) /* Initialize IRQ vector table in RAM */ sysirq_init(); + +#if CONFIG_KERN_PREEMPT + /* + * Voluntary context switch handler. + * + * This software interrupt can always be triggered and must be + * dispatched as soon as possible, thus we just disable IRQ priority + * for it. + */ + sysirq_setHandler(FAULT_SVCALL, svcall_handler); + sysirq_setPriority(FAULT_SVCALL, IRQ_PRIO_MAX); + /* + * Preemptible context switch handler + * + * The priority of this IRQ must be the lowest priority in the system + * in order to run last in the interrupt service routines' chain. + */ + sysirq_setHandler(FAULT_PENDSV, pendsv_handler); + sysirq_setPriority(FAULT_PENDSV, IRQ_PRIO_MIN); +#endif }