2 # startup.s - starup code for the lpc2220
4 # author: hackbard@hackdaworld.org
13 .equ sram_size, (64*1024)
14 .equ sram_addr, 0x40000000
15 .equ sram_top, (sram_addr+sram_size-4)
19 .equ stack_size, (4*1024)
20 .equ stack_top, sram_top
21 .equ stack_limit, (sram_top-stack_size)
23 .equ stack_size_fiq, 64
24 .equ stack_size_irq, 256
25 .equ stack_size_supervisor, 64
26 .equ stack_size_abort, 64
27 .equ stack_size_undefined, 64
28 .equ stack_size_system, 1024
30 # arm modes - control bits of the program status register
31 # ref: chapter 2.8, arm7tdmi-s technical reference manual
36 .equ mode_supervisor, 0x13
38 .equ mode_undefined, 0x1b
39 .equ mode_system, 0x1f
41 .equ fiq_disable, 0x40
42 .equ irq_disable, 0x80
51 # exception handling must go to the very beginning
54 # - the ldr is at 0x18
55 # - pc will be 0x18 + 8 at the moment of ldr (pipeline)
56 # - substract 0xff0 => 0xfffff030
57 # - that's the vectored address register
58 # - the vic put in there the address of our service routine
61 ldr pc, handler_undef_instruction
62 ldr pc, handler_soft_ir
63 ldr pc, handler_prefetch_abort
64 ldr pc, handler_data_abort
69 handler_reset: .word handle_reset
70 handler_undef_instruction: .word interrupt_handler_undef_instruction
71 handler_soft_ir: .word interrupt_handler_soft_ir
72 handler_prefetch_abort: .word interrupt_handler_prefetch_abort
73 handler_data_abort: .word interrupt_handler_data_abort
74 handler_fiq: .word interrupt_handler_fiq
76 # reset handling goes here
80 # init stack pointer for each mode + set stack limit
84 msr cpsr_c, #mode_undefined|irq_disable|fiq_disable
86 sub r0, r0, #stack_size_undefined
88 msr cpsr_c, #mode_abort|irq_disable|fiq_disable
90 sub r0, r0, #stack_size_abort
92 msr cpsr_c, #mode_fiq|irq_disable|fiq_disable
94 sub r0, r0, #stack_size_fiq
96 msr cpsr_c, #mode_irq|irq_disable|fiq_disable
98 sub r0, r0, #stack_size_irq
100 msr cpsr_c, #mode_supervisor|irq_disable|fiq_disable
102 sub r0, r0, #stack_size_supervisor
104 msr cpsr_c, #mode_system|irq_disable|fiq_disable
106 sub r0, r0, #stack_size_system
111 # copy data section (only if we are in flash <=> _etext != _data)