diff options
Diffstat (limited to 'src/init.c')
-rw-r--r-- | src/init.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -5,7 +5,7 @@ void on_reset(void); -void __attribute__((weak, interrupt, __section__(".isr_vector"))) +void __attribute__((weak, interrupt, __section__(".isr_vector.routines"))) default_irq_handler(void) { return; @@ -13,7 +13,7 @@ default_irq_handler(void) #define WEAK_IRQ(irq) \ void __attribute__(( \ - weak, alias("default_irq_handler"), __section__(".isr_vector"))) \ + weak, alias("default_irq_handler"), __section__(".isr_vector.routines"))) \ irq(void) WEAK_IRQ(irq_on_reset); @@ -60,7 +60,9 @@ extern uint32_t BSS_STOP; static inline void set_mtvec(void* vector_table) { - asm volatile("csrw mtvec, %0" : : "r"(vector_table)); + uint32_t mtvec = (uint32_t) vector_table; + mtvec |= 1; // Set interrupt table mode to "VECTORED" + asm volatile("csrw mtvec, %0" : : "r"(mtvec)); } /* @@ -99,7 +101,7 @@ extern void main(void); /* Start function. Responsible for initializing the system and jumping to the * main function. */ -static void start(void) +static __attribute((__section__(".sinit.1"))) void start(void) { /* Initialize the data segments. */ init_data_segments(); @@ -113,7 +115,7 @@ static void start(void) * The reset callback.This has to be a naked function because the stack pointer * may not be initialized!!. */ -__attribute((naked, __section__(".isr_routines.on_reset"))) void on_reset(void) +__attribute((naked, __section__(".sinit"))) void _begin(void) { // Set up the stack pointer to point to the end of SRAM. asm volatile( |