2008-12-28 14:35:37 +01:00
|
|
|
.arm
|
|
|
|
|
|
|
|
.extern _main
|
|
|
|
.extern __got_start
|
|
|
|
.extern __got_end
|
|
|
|
.extern __bss_start
|
|
|
|
.extern __bss_end
|
2009-01-08 23:27:22 +01:00
|
|
|
.extern __bss2_start
|
|
|
|
.extern __bss2_end
|
2008-12-28 14:35:37 +01:00
|
|
|
.extern __stack_addr
|
|
|
|
.globl _start
|
|
|
|
.globl debug_output
|
2009-01-08 23:27:22 +01:00
|
|
|
|
|
|
|
.extern v_irq
|
2008-12-28 14:35:37 +01:00
|
|
|
|
|
|
|
.section .init
|
|
|
|
|
2009-01-06 00:13:39 +01:00
|
|
|
_vectors:
|
2008-12-28 14:35:37 +01:00
|
|
|
_start:
|
2009-01-06 00:13:39 +01:00
|
|
|
ldr pc, =v_reset
|
|
|
|
ldr pc, =v_undf
|
|
|
|
ldr pc, =v_swi
|
|
|
|
ldr pc, =v_instr_abrt
|
|
|
|
ldr pc, =v_data_abrt
|
|
|
|
ldr pc, =v_reserved
|
|
|
|
ldr pc, =v_irq
|
|
|
|
ldr pc, =v_fiq
|
|
|
|
|
|
|
|
.pool
|
|
|
|
|
|
|
|
v_reset:
|
2009-01-16 08:47:49 +01:00
|
|
|
@ Switch to System mode
|
|
|
|
msr cpsr_c, #0xdf
|
|
|
|
|
2009-01-06 00:13:39 +01:00
|
|
|
@ Get loader base from ELF loader
|
|
|
|
mov r4, r0
|
|
|
|
|
2008-12-28 14:35:37 +01:00
|
|
|
@ Output 0x42 to the debug port
|
|
|
|
mov r0, #0x42
|
|
|
|
bl debug_output
|
|
|
|
|
|
|
|
@ Set up a stack
|
|
|
|
ldr sp, =__stack_addr
|
|
|
|
|
|
|
|
@ clear BSS
|
|
|
|
ldr r1, =__bss_start
|
|
|
|
ldr r2, =__bss_end
|
|
|
|
mov r3, #0
|
|
|
|
bss_loop:
|
|
|
|
@ check for the end
|
|
|
|
cmp r1, r2
|
|
|
|
beq done_bss
|
|
|
|
@ clear the word and move on
|
|
|
|
str r3, [r1]
|
|
|
|
add r1, r1, #4
|
|
|
|
b bss_loop
|
|
|
|
|
|
|
|
done_bss:
|
2009-01-08 23:27:22 +01:00
|
|
|
@ clear BSS2
|
|
|
|
ldr r1, =__bss2_start
|
|
|
|
ldr r2, =__bss2_end
|
|
|
|
mov r3, #0
|
|
|
|
bss2_loop:
|
|
|
|
@ check for the end
|
|
|
|
cmp r1, r2
|
|
|
|
beq done_bss2
|
|
|
|
@ clear the word and move on
|
|
|
|
str r3, [r1]
|
|
|
|
add r1, r1, #4
|
|
|
|
b bss2_loop
|
|
|
|
|
|
|
|
done_bss2:
|
2009-01-06 00:13:39 +01:00
|
|
|
mov r0, #0x84
|
2008-12-28 14:35:37 +01:00
|
|
|
bl debug_output
|
|
|
|
@ take the plunge
|
|
|
|
mov r0, r4
|
|
|
|
bl _main
|
|
|
|
@ _main returned! Go to whatever address it returned...
|
|
|
|
mov pc, r0
|
|
|
|
|
|
|
|
.pool
|
|
|
|
|
2009-01-06 00:13:39 +01:00
|
|
|
v_undf:
|
|
|
|
b v_undf
|
|
|
|
|
|
|
|
v_swi:
|
|
|
|
b v_swi
|
|
|
|
|
|
|
|
v_instr_abrt:
|
|
|
|
b v_instr_abrt
|
|
|
|
|
|
|
|
v_data_abrt:
|
|
|
|
b v_data_abrt
|
|
|
|
|
|
|
|
v_reserved:
|
|
|
|
b v_reserved
|
|
|
|
|
2009-01-08 23:27:22 +01:00
|
|
|
#v_irq:
|
|
|
|
# b v_irq
|
2009-01-06 00:13:39 +01:00
|
|
|
|
|
|
|
v_fiq:
|
|
|
|
b v_fiq
|
|
|
|
|
2008-12-28 14:35:37 +01:00
|
|
|
debug_output:
|
|
|
|
@ load address of port
|
|
|
|
mov r3, #0xd800000
|
|
|
|
@ load old value
|
|
|
|
ldr r2, [r3, #0xe0]
|
|
|
|
@ clear debug byte
|
|
|
|
bic r2, r2, #0xFF0000
|
|
|
|
@ insert new value
|
|
|
|
and r0, r0, #0xFF
|
|
|
|
orr r2, r2, r0, LSL #16
|
|
|
|
@ store back
|
|
|
|
str r2, [r3, #0xe0]
|
2009-01-08 23:27:22 +01:00
|
|
|
bx lr
|
2008-12-28 14:35:37 +01:00
|
|
|
|
2009-01-06 00:13:39 +01:00
|
|
|
.pool
|