* Make total stack size available as a symbol
* Implement SWI handler to enable/disable interrupts * Implement event system to deal with kicking non-interrupt code
This commit is contained in:
47
crt0.s
47
crt0.s
@@ -10,12 +10,24 @@
|
||||
.equ APB_DIVIDER, 4 /* 1, 2 or 4 */
|
||||
|
||||
.equ UND_STACK_SIZE, 0x0004
|
||||
.equ SVC_STACK_SIZE, 0x0004
|
||||
.equ SVC_STACK_SIZE, 0x0010
|
||||
.equ ABT_STACK_SIZE, 0x0004
|
||||
.equ FIQ_STACK_SIZE, 0x0004
|
||||
.equ IRQ_STACK_SIZE, 0x0080
|
||||
.equ USR_STACK_SIZE, 0x0400
|
||||
|
||||
|
||||
.global _stack_size
|
||||
|
||||
.equ _stack_size, 0
|
||||
.equ _stack_size, _stack_size + UND_STACK_SIZE
|
||||
.equ _stack_size, _stack_size + SVC_STACK_SIZE
|
||||
.equ _stack_size, _stack_size + ABT_STACK_SIZE
|
||||
.equ _stack_size, _stack_size + FIQ_STACK_SIZE
|
||||
.equ _stack_size, _stack_size + IRQ_STACK_SIZE
|
||||
.equ _stack_size, _stack_size + USR_STACK_SIZE
|
||||
|
||||
|
||||
# Processor definitions
|
||||
|
||||
.equ Mode_USR, 0x10
|
||||
@@ -174,7 +186,6 @@ lzi:
|
||||
|
||||
# Undefined handlers can just spin for now
|
||||
undefined_handler:
|
||||
swi_handler:
|
||||
prefetch_abort_handler:
|
||||
data_abort_handler:
|
||||
fiq_handler:
|
||||
@@ -182,5 +193,37 @@ fiq_handler:
|
||||
__back:
|
||||
b __back
|
||||
|
||||
|
||||
.equ SWI_MAX, 1
|
||||
|
||||
swi_handler:
|
||||
stmfd sp!, {ip, lr}
|
||||
ldr ip, [lr, #-4]
|
||||
bic ip, #0xff000000
|
||||
|
||||
cmp ip, #SWI_MAX
|
||||
ldmhifd sp!, {ip, pc}^
|
||||
|
||||
add ip, pc, ip, lsl #2
|
||||
ldr pc, [ip]
|
||||
|
||||
swi_branch_table:
|
||||
.word disable_interrupts
|
||||
.word enable_interrupts
|
||||
|
||||
|
||||
disable_interrupts:
|
||||
mrs ip, SPSR
|
||||
orr ip, ip, #I_Bit
|
||||
msr SPSR_c,ip
|
||||
ldmfd sp!, {ip, pc}^
|
||||
|
||||
enable_interrupts:
|
||||
mrs ip, SPSR
|
||||
bic ip, ip, #I_Bit
|
||||
msr SPSR_c,ip
|
||||
ldmfd sp!, {ip, pc}^
|
||||
|
||||
|
||||
.endfunc
|
||||
.end
|
||||
|
||||
Reference in New Issue
Block a user