Fix horrible stack and CPSR problems

This commit is contained in:
marcan 2009-01-16 08:47:49 +01:00 committed by bushing
parent f0edf39096
commit 9fb59af098
2 changed files with 8 additions and 13 deletions

View File

@ -11,16 +11,13 @@
irq_setup_stack: irq_setup_stack:
@ Switch to IRQ mode @ Switch to IRQ mode
mrs r0, cpsr mrs r0, cpsr
bic r1, r0, #0x1f msr cpsr_c, #0xd2
orr r1, #0x12
msr cpsr, r1
@ Setup interrupt stack @ Setup interrupt stack
ldr sp, =__stack_addr ldr sp, =__irqstack_addr
add sp, r4
@ Restore mode @ Restore mode
msr cpsr, r0 msr cpsr_c, r0
bx lr bx lr
v_irq: v_irq:
@ -35,12 +32,12 @@ irq_kill:
mrs r1, cpsr mrs r1, cpsr
and r0, r1, #(CPSR_IRQDIS|CPSR_FIQDIS) and r0, r1, #(CPSR_IRQDIS|CPSR_FIQDIS)
orr r1, r1, #(CPSR_IRQDIS|CPSR_FIQDIS) orr r1, r1, #(CPSR_IRQDIS|CPSR_FIQDIS)
msr cpsr, r1 msr cpsr_c, r1
bx lr bx lr
irq_restore: irq_restore:
mrs r1, cpsr mrs r1, cpsr
bic r1, r1, #(CPSR_IRQDIS|CPSR_FIQDIS) bic r1, r1, #(CPSR_IRQDIS|CPSR_FIQDIS)
orr r1, r1, r0 orr r1, r1, r0
msr cpsr, r1 msr cpsr_c, r1
bx lr bx lr

View File

@ -29,6 +29,9 @@ _start:
.pool .pool
v_reset: v_reset:
@ Switch to System mode
msr cpsr_c, #0xdf
@ Get loader base from ELF loader @ Get loader base from ELF loader
mov r4, r0 mov r4, r0
@ -38,13 +41,10 @@ v_reset:
@ Set up a stack @ Set up a stack
ldr sp, =__stack_addr ldr sp, =__stack_addr
add sp, r4
@ clear BSS @ clear BSS
ldr r1, =__bss_start ldr r1, =__bss_start
add r1, r4
ldr r2, =__bss_end ldr r2, =__bss_end
add r2, r4
mov r3, #0 mov r3, #0
bss_loop: bss_loop:
@ check for the end @ check for the end
@ -58,9 +58,7 @@ bss_loop:
done_bss: done_bss:
@ clear BSS2 @ clear BSS2
ldr r1, =__bss2_start ldr r1, =__bss2_start
add r1, r4
ldr r2, =__bss2_end ldr r2, =__bss2_end
add r2, r4
mov r3, #0 mov r3, #0
bss2_loop: bss2_loop:
@ check for the end @ check for the end