X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Farm.git;a=blobdiff_plain;f=betty%2Fstartup.s;h=fb42ac7deecf00f97af2e2bf7053221bb53675b6;hp=7cf1e107b3c222dc9faf006a31bf28d801b62dc4;hb=fc297929bc25cb94ebe79ccd34f26e4ca97b0753;hpb=026d6884ee8185fe08296b31d4bb570662cf2add diff --git a/betty/startup.s b/betty/startup.s index 7cf1e10..fb42ac7 100644 --- a/betty/startup.s +++ b/betty/startup.s @@ -50,18 +50,26 @@ # exception handling must go to the very beginning - b handler_reset - b interrupt_handler_undef_instruction - b interrupt_handler_soft_ir - b interrupt_handler_prefetch_abort - b interrupt_handler_data_abort + ldr pc, handler_reset + ldr pc, handler_undef_instruction + ldr pc, handler_soft_ir + ldr pc, handler_prefetch_abort + ldr pc, handler_data_abort nop - b interrupt_handler_irq - b interrupt_handler_fiq + ldr pc, handler_irq + ldr pc, handler_fiq + +handler_reset: .word handle_reset +handler_undef_instruction: .word interrupt_handler_undef_instruction +handler_soft_ir: .word interrupt_handler_soft_ir +handler_prefetch_abort: .word interrupt_handler_prefetch_abort +handler_data_abort: .word interrupt_handler_data_abort +handler_irq: .word interrupt_handler_irq +handler_fiq: .word interrupt_handler_fiq # reset handling goes here -handler_reset: +handle_reset: # init stack pointer for each mode + set stack limit @@ -94,12 +102,15 @@ handler_reset: ldr r0, =stack_limit mov sl, r0 - # copy data section + # copy data section (only if we are in flash <=> _etext != _data) ldr r1, =_etext ldr r2, =_data ldr r3, =_edata + cmp r1, r2 + beq start_of_c_code + copy_data_loop: cmp r2, r3 @@ -109,6 +120,8 @@ copy_data_loop: # jump to c code +start_of_c_code: + adr lr, loop_forever mov r0, #0 mov r1, #0