From 8d241962b43b530ad9d10bdaf368e91a9881502f Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Sat, 13 Nov 2021 00:20:54 -0700 Subject: Move IRQ handler to own file --- src/boot.S | 41 +---------------------------------------- src/irq.S | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 40 deletions(-) diff --git a/src/boot.S b/src/boot.S index 89a99cc..0662f70 100644 --- a/src/boot.S +++ b/src/boot.S @@ -61,6 +61,7 @@ irq: fiq: push {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} + bl a_fiq_handler pop {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} subs pc, lr, #4 @@ -108,43 +109,3 @@ data_handler: .word io_halt unused_handler: .word io_halt irq_handler: .word irq fiq_handler: .word fiq - -.global a_irq_handler -a_irq_handler: - push {lr} - bl disable_irq - // r2 = CORE0_INTERRUPT_SOURCE - // if r2 & 0b100000000 - mov r2, #0x40000000 - ldr r3, [r2, #0x60] - tst r3, #256 - beq a_irq_handler.exit - // r2 = IRQ_PEND2 - // r2 & 1 << 25 - mov r2, #0xB208 - movt r2, #0x3F00 - ldr r3, [r2] - tst r3, #0x2000000 - beq a_irq_handler.exit - mov r2, #0x1040 - movt r2, #0x3F20 - ldr r3, [r2] - tst r3, #16 - beq a_irq_handler.exit - mov r2, #0x1000 - movt r2, #0x3F20 - ldrb r0, [r2] - push {r0} - bl enable_irq - pop {r0} - bl uart_char - ldr r0, =amsg - bl uart_string - pop {pc} -a_irq_handler.exit: - bl enable_irq - pop {pc} - -.section ".data" -amsg: - .asciz " a_irq_handler\n" diff --git a/src/irq.S b/src/irq.S index e69de29..dea37f4 100644 --- a/src/irq.S +++ b/src/irq.S @@ -0,0 +1,52 @@ +.globl a_irq_handler +a_irq_handler: + push {lr} + bl disable_irq + // r2 = CORE0_INTERRUPT_SOURCE + // if r2 & 0b100000000 + mov r2, #0x40000000 + ldr r3, [r2, #0x60] + tst r3, #256 + beq a_irq_handler.exit + // r2 = IRQ_PEND2 + // r2 & 1 << 25 + mov r2, #0xB208 + movt r2, #0x3F00 + ldr r3, [r2] + tst r3, #0x2000000 + beq a_irq_handler.exit + mov r2, #0x1040 + movt r2, #0x3F20 + ldr r3, [r2] + tst r3, #16 + beq a_irq_handler.exit + mov r2, #0x1000 + movt r2, #0x3F20 + ldrb r0, [r2] + push {r0} + bl enable_irq + pop {r0} + bl uart_char + ldr r0, =imsg + bl uart_string + pop {pc} +a_irq_handler.exit: + bl enable_irq + pop {pc} + +.globl a_fiq_handler +a_fiq_handler: + push {lr} + bl disable_fiq + ldr r0, =fmsg + bl uart_string + pop {pc} +a_fiq_handler.exit: + bl enable_fiq + pop {pc} + +.section ".data" +imsg: + .asciz " a_irq_handler\n" +fmsg: + .asciz " a_fiq_handler\n" -- cgit v1.2.1