From 3f998d80ebfc85c86cc28609f35ae1c7ca392a16 Mon Sep 17 00:00:00 2001 From: Ingo Albrecht Date: Sun, 11 Apr 2010 09:52:25 +0200 Subject: firmware: separated various pieces of interrupt handling apart --- src/target/firmware/Makefile | 6 +- src/target/firmware/Makefile.inc | 13 ++-- .../firmware/board/compal/exceptions_redirect.S | 18 +++++ .../firmware/board/compal/exceptions_redirected.S | 20 +++++ src/target/firmware/board/compal/handlers.S | 79 +++++++++++++++++++ src/target/firmware/board/compal/header.S | 11 +++ src/target/firmware/board/compal/start.S | 90 ---------------------- 7 files changed, 141 insertions(+), 96 deletions(-) create mode 100644 src/target/firmware/board/compal/exceptions_redirect.S create mode 100644 src/target/firmware/board/compal/exceptions_redirected.S create mode 100644 src/target/firmware/board/compal/handlers.S create mode 100644 src/target/firmware/board/compal/header.S (limited to 'src/target') diff --git a/src/target/firmware/Makefile b/src/target/firmware/Makefile index 56c08273..dfb37747 100644 --- a/src/target/firmware/Makefile +++ b/src/target/firmware/Makefile @@ -25,6 +25,7 @@ compal_COMMON_OBJS=board/compal/start.o $(calypso_COMMON_OBJS) board/compal/rffe compal_COMMON_ENVIRONMENTS=compalram compalram_LDS=board/compal/ram.lds +compalram_OBJS=board/compal/exceptions_redirected.o board/compal/handlers.o # Compal E88 @@ -32,7 +33,9 @@ compal_e88_OBJS=$(compal_COMMON_OBJS) board/compal_e88/init.o compal_e88_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS) e88loader e88loader_LDS=board/compal_e88/loader.lds -e88flash_LDS=board/compal_e88/flash.lds +e88loader_OBJS=board/compal/header.o board/compal/exceptions_redirect.o + +e88flash_LDS=board/compal_e88/flash.lds board/compal/exceptions_full.o # Compal E99 @@ -43,6 +46,7 @@ gta0x_OBJS=$(gta0x_COMMON_OBJS) board/gta0x/init.o compal_e99_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS) e99loader_LDS=board/compal_e99/loader.lds +e99loader_OBJS=board/compal/header.o e99flash_LDS=board/compal_e99/flash.lds diff --git a/src/target/firmware/Makefile.inc b/src/target/firmware/Makefile.inc index b3b64a63..52b58ee5 100644 --- a/src/target/firmware/Makefile.inc +++ b/src/target/firmware/Makefile.inc @@ -73,24 +73,27 @@ ALL_DEPS+=$(ANY_APP_OBJS:.o=.p) define APPLICATION_BOARD_ENVIRONMENT_template # define set of objects for this binary -$(1)_$(2)_$(3)_OBJS := apps/$(1)/main.o $(ANY_APP_OBJS) $(ANY_APP_LIBS) $$($(2)_OBJS) +$(1)_$(2)_$(3)_OBJS := apps/$(1)/main.o $(ANY_APP_OBJS) $$($(2)_OBJS) +$(1)_$(2)_$(3)_LIBS := $(ANY_APP_LIBS) # define manifest compilation board/$(2)/$(1).$(3).manifest.o: board/manifest.c - $(CROSS_COMPILE)$(CC) $(CFLAGS) -DAPPLICATION=\"$(3)\" -DBOARD=\"$(2)\" -DENVIRONMENT=\"$(3)\" -c -o $$@ $$< + $(CROSS_COMPILE)$(CC) $(CFLAGS) -DAPPLICATION=\"$(1)\" -DBOARD=\"$(2)\" -DENVIRONMENT=\"$(3)\" -c -o $$@ $$< # add manifest object to object list -$(1)_$(2)_$(3)_OBJS+=board/$(2)/$(1).$(3).manifest.o +$(1)_$(2)_$(3)_OBJS+=board/$(2)/$(1).$(3).manifest.o $$($(3)_OBJS) # define compilation, generating various extra files on the way -board/$(2)/$(1).$(3).elf board/$(2)/$(1).$(3).map board/$(2)/$(1).$(3).size: $$($(1)_$(2)_$(3)_OBJS) $$($(3)_LDS) +board/$(2)/$(1).$(3).elf board/$(2)/$(1).$(3).map board/$(2)/$(1).$(3).size: $$($(1)_$(2)_$(3)_OBJS) $$($(1)_$(2)_$(3)_LIBS) $$($(3)_LDS) $(CROSS_COMPILE)$(LD) $(LDFLAGS) -T $$($(3)_LDS) -Bstatic \ -Map board/$(2)/$(1).$(3).map -o board/$(2)/$(1).$(3).elf \ - --start-group $$($(1)_$(2)_$(3)_OBJS) --end-group + --start-group $$($(1)_$(2)_$(3)_OBJS) $$($(1)_$(2)_$(3)_LIBS) --end-group $(CROSS_COMPILE)$(SIZE) board/$(2)/$(1).$(3).elf | tee board/$(2)/$(1).$(3).size ALL_APPS+=board/$(2)/$(1).$(3).elf +ALL_OBJS+=$$($(1)_$(2)_$(3)_OBJS) + endef define BOARD_template diff --git a/src/target/firmware/board/compal/exceptions_redirect.S b/src/target/firmware/board/compal/exceptions_redirect.S new file mode 100644 index 00000000..d2d971b8 --- /dev/null +++ b/src/target/firmware/board/compal/exceptions_redirect.S @@ -0,0 +1,18 @@ + +/* XXX this should dispatch via 0x80001c */ + +.section .text.exceptions +_undef_instr: + b _undef_instr +_sw_interr: + b _sw_interr +_prefetch_abort: + b _prefetch_abort +_data_abort: + b _data_abort +_reserved: + b _reserved +_irq: + b _irq +_fiq: + b _fiq diff --git a/src/target/firmware/board/compal/exceptions_redirected.S b/src/target/firmware/board/compal/exceptions_redirected.S new file mode 100644 index 00000000..69083962 --- /dev/null +++ b/src/target/firmware/board/compal/exceptions_redirected.S @@ -0,0 +1,20 @@ + +/* Exception Vectors like they are needed for the exception vector + indirection of the internal boot ROM. The following section must be liked + to appear at 0x80001c */ +.section .text.exceptions +_undef_instr: + b handle_abort +_sw_interr: + b _sw_interr +_prefetch_abort: + b handle_abort +_data_abort: + b handle_abort +_reserved: + b _reserved +_irq: + b irq_entry +_fiq: + b fiq_entry + diff --git a/src/target/firmware/board/compal/handlers.S b/src/target/firmware/board/compal/handlers.S new file mode 100644 index 00000000..ef044e3f --- /dev/null +++ b/src/target/firmware/board/compal/handlers.S @@ -0,0 +1,79 @@ + + .EQU I_BIT, 0x80 + .EQU F_BIT, 0x40 + +.section .text + +/* handler for all kinds of aborts */ +.global handle_abort +handle_abort: + @ print the PC we would jump back to... + sub lr, lr, #4 @ we assume to be ARM32 + + mov r0, lr + mov r1, #8 + bl phex + + @ print abort message + mov r0, #'A' + bl putchar_asm + mov r0, #'B' + bl putchar_asm + mov r0, #'O' + bl putchar_asm + mov r0, #'R' + bl putchar_asm + mov r0, #'T' + bl putchar_asm + + @ disable IRQ and FIQ + msr CPSR_c, #I_BIT | F_BIT + +0: @ dead + b 0b + +/* entry point for IRQs */ +.global irq_entry +irq_entry: + /* Adjust and save LR_irq in IRQ stack */ + sub lr, lr, #4 + stmfd sp!, {lr} + + /* Save SPSR for nested interrupt */ + mrs r14, SPSR + stmfd sp!, {r14} + + /* Call the interrupt handler C function */ + stmfd sp!, {r0-r4, r12} + bl irq + ldmfd sp!, {r0-r4, r12} + + /* Restore SPSR_irq from IRQ stack */ + ldmia sp!, {r14} + msr SPSR_cxsf, r14 + + /* Restore adjusted LR_irq from IRQ stack directly in the PC */ + ldmia sp!, {pc}^ + +/* entry point for FIQs */ +.global fiq_entry +fiq_entry: + /* Adjust and save LR_irq in IRQ stack */ + sub lr, lr, #4 + stmfd sp!, {lr} + + /* Save SPSR for nested interrupt */ + mrs r14, SPSR + stmfd sp!, {r14} + + /* Call the interrupt handler C function */ + stmfd sp!, {r0-r4, r12} + bl fiq + ldmfd sp!, {r0-r4, r12} + + /* Restore SPSR_irq from IRQ stack */ + ldmia sp!, {r14} + msr SPSR_cxsf, r14 + + /* Restore adjusted LR_irq from IRQ stack directly in the PC */ + ldmia sp!, {pc}^ diff --git a/src/target/firmware/board/compal/header.S b/src/target/firmware/board/compal/header.S new file mode 100644 index 00000000..747f6806 --- /dev/null +++ b/src/target/firmware/board/compal/header.S @@ -0,0 +1,11 @@ +/* + * This is a textual header that is prepended to images where appropriate. + * + * It is meant to ease identification of our firmwares in dumps as well + * as filling some space that is used for the same purpose by the vendor. + * + */ +.section .compal.header +.ascii "OSMOCOM" +. = 0x20 +.ascii GIT_REVISION diff --git a/src/target/firmware/board/compal/start.S b/src/target/firmware/board/compal/start.S index 3036fec9..dcbe1e8f 100644 --- a/src/target/firmware/board/compal/start.S +++ b/src/target/firmware/board/compal/start.S @@ -72,93 +72,3 @@ _jump_main: .word main _ctor_list: .word __CTOR_LIST__ _ctor_end: .word __CTOR_END__ -/* handler for all kinds of aborts */ -handle_abort: - @ print the PC we would jump back to... - sub lr, lr, #4 @ we assume to be ARM32 - - mov r0, lr - mov r1, #8 - bl phex - - @ print abort message - mov r0, #'A' - bl putchar_asm - mov r0, #'B' - bl putchar_asm - mov r0, #'O' - bl putchar_asm - mov r0, #'R' - bl putchar_asm - mov r0, #'T' - bl putchar_asm - - @ disable IRQ and FIQ - msr CPSR_c, #I_BIT | F_BIT - -0: @ dead - b 0b - -/* entry point for IRQs */ -irq_entry: - /* Adjust and save LR_irq in IRQ stack */ - sub lr, lr, #4 - stmfd sp!, {lr} - - /* Save SPSR for nested interrupt */ - mrs r14, SPSR - stmfd sp!, {r14} - - /* Call the interrupt handler C function */ - stmfd sp!, {r0-r4, r12} - bl irq - ldmfd sp!, {r0-r4, r12} - - /* Restore SPSR_irq from IRQ stack */ - ldmia sp!, {r14} - msr SPSR_cxsf, r14 - - /* Restore adjusted LR_irq from IRQ stack directly in the PC */ - ldmia sp!, {pc}^ - -/* entry point for FIQs */ -fiq_entry: - /* Adjust and save LR_irq in IRQ stack */ - sub lr, lr, #4 - stmfd sp!, {lr} - - /* Save SPSR for nested interrupt */ - mrs r14, SPSR - stmfd sp!, {r14} - - /* Call the interrupt handler C function */ - stmfd sp!, {r0-r4, r12} - bl fiq - ldmfd sp!, {r0-r4, r12} - - /* Restore SPSR_irq from IRQ stack */ - ldmia sp!, {r14} - msr SPSR_cxsf, r14 - - /* Restore adjusted LR_irq from IRQ stack directly in the PC */ - ldmia sp!, {pc}^ - -/* Exception Vectors like they are needed for the exception vector - indirection of the internal boot ROM. The following section must be liked - to appear at 0x80'001c */ -.section .text.exceptions -_undef_instr: - b handle_abort -_sw_interr: - b _sw_interr -_prefetch_abort: - b handle_abort -_data_abort: - b handle_abort -_reserved: - b _reserved -_irq: - b irq_entry -_fiq: - b fiq_entry - -- cgit v1.2.3