From 9d587f9f750253461314757f2f861c5214563120 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Thu, 26 Dec 2019 18:48:38 +0100 Subject: improve linking of interrupts --- demo_functionality.c | 10 +++++----- interrupt_vector.S | 4 +++- interrupts.c | 9 ++++++--- linker.ld | 18 +++++++++--------- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/demo_functionality.c b/demo_functionality.c index aedab08..c6f7e5c 100644 --- a/demo_functionality.c +++ b/demo_functionality.c @@ -164,9 +164,9 @@ void demo_go_unprivileged(void) } extern char - __interrupt_vectors_start, - __interrupt_vectors_end, - __interrupt_vectors_size; + __interrupts_start, + __interrupts_end, + __interrupts_size; extern void (*volatile system_reentry_point)(void); @@ -180,7 +180,7 @@ void demo_setup_interrupts(void) { system_reentry_point = system_reentry; - for (size_t i = 0; i < (size_t) &__interrupt_vectors_size; i++) + for (size_t i = 0; i < (size_t) &__interrupts_size; i++) ((volatile char*) 0)[i] = - (&__interrupt_vectors_start)[i]; + (&__interrupts_start)[i]; } diff --git a/interrupt_vector.S b/interrupt_vector.S index f71330b..d20bf6d 100644 --- a/interrupt_vector.S +++ b/interrupt_vector.S @@ -1,4 +1,4 @@ -.section ".interrupt_vectors.text" +.section ".interrupts.vector" .global abort_handler .local generic_handler @@ -12,6 +12,8 @@ _interrupt_vectors: b generic_handler b generic_handler +.section ".interrupts.text" + generic_handler: b generic_handler abort_handler_caller: diff --git a/interrupts.c b/interrupts.c index 191ce40..6952f89 100644 --- a/interrupts.c +++ b/interrupts.c @@ -5,7 +5,10 @@ If an undefined instruction is encountered, the CPU will start executing this function. Just trap here as a debug solution. */ -void __attribute__((interrupt("UNDEF"))) undefined_instruction_vector(void) +void +__attribute__((interrupt("UNDEF"))) +__attribute__((section(".interrupts.text"))) +undefined_instruction_vector(void) { uart_puts("Undefined instruction occured"); while( 1 ) @@ -14,12 +17,12 @@ void __attribute__((interrupt("UNDEF"))) undefined_instruction_vector(void) } } -void __attribute__((section(".interrupt_vectors.data"))) +void __attribute__((section(".interrupts.data"))) (*system_reentry_point) (void); void __attribute__((interrupt("ABORT"))) -__attribute__((section(".interrupt_vectors.text"))) +__attribute__((section(".interrupts.text"))) abort_handler(void) { system_reentry_point(); diff --git a/linker.ld b/linker.ld index ed40054..5bdbfd2 100644 --- a/linker.ld +++ b/linker.ld @@ -42,17 +42,17 @@ SECTIONS __libkernel_size = __libkernel_end - __libkernel_start; - . = ALIGN(4096); /* align to page size */ - __interrupt_vectors_start = .; - .interrupt_vectors : + + .interrupts : { - interrupt_vectors = .; - *(.interrupt_vectors.text) - *(.interrupt_vectors.data) + __interrupts_start = .; + KEEP(*(.interrupts.vector)) + interrupt_vector.o + interrupts.o + __interrupts_end = .; } - . = ALIGN(4096); /* align to page size */ - __interrupt_vectors_end = .; - __interrupt_vectors_size = __interrupt_vectors_end - __interrupt_vectors_start; + + __interrupts_size = __interrupts_end - __interrupts_start; __end = .; } -- cgit v1.2.3