2022-08-06 02:41:07 +00:00
|
|
|
/*
|
2022-08-07 03:35:45 +00:00
|
|
|
* This section is read by bootloader,
|
|
|
|
* then the application will be copied according to the contents.
|
|
|
|
* !!DO NOT REMOVE!!
|
|
|
|
* See SPL project README for details.
|
2022-08-06 02:41:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
.section .text.vtors, "ax"
|
|
|
|
_vtors:
|
2022-09-07 15:48:27 +00:00
|
|
|
.long _stext
|
2022-08-06 02:41:07 +00:00
|
|
|
.long _eidata
|
|
|
|
.long _start
|
|
|
|
|
2022-08-07 03:35:45 +00:00
|
|
|
/*
|
|
|
|
* Startup code (CRT0)
|
2022-06-24 01:27:26 +00:00
|
|
|
*/
|
2022-08-07 03:35:45 +00:00
|
|
|
.section .text.init, "ax"
|
2022-06-25 03:57:25 +00:00
|
|
|
.global _start
|
2022-06-21 01:28:16 +00:00
|
|
|
|
2022-06-25 03:57:25 +00:00
|
|
|
_start:
|
|
|
|
mov.l _stack_k, sp /* Setup R15(SP) */
|
2022-06-21 15:16:14 +00:00
|
|
|
|
2022-06-25 03:57:25 +00:00
|
|
|
_copy_data:
|
|
|
|
mov.l _sidata_k, r0
|
|
|
|
mov.l _sdata_k, r1
|
|
|
|
mov.l _edata_k, r2
|
|
|
|
|
|
|
|
_loop_copy_data:
|
2022-06-21 15:16:14 +00:00
|
|
|
mov.l @r0+, r3 /* Load a word to r3 from [sidata], with post-increment of 4 */
|
2022-06-25 03:57:25 +00:00
|
|
|
mov.l r3, @r1 /* Store the word in r3 to [sdata] */
|
|
|
|
add #4, r1 /* Increment sdata pointer */
|
2022-06-26 16:18:19 +00:00
|
|
|
cmp/gt r1, r2 /* r2 greater or equal than r1? */
|
2022-06-25 03:57:25 +00:00
|
|
|
bt _loop_copy_data
|
2022-06-24 01:27:26 +00:00
|
|
|
|
2022-06-25 03:57:25 +00:00
|
|
|
_zero_bss:
|
|
|
|
mov.l _edata_k, r0
|
|
|
|
mov.l _end_k, r1
|
2022-06-21 15:16:14 +00:00
|
|
|
mov #0, r2
|
|
|
|
|
2022-06-25 03:57:25 +00:00
|
|
|
_loop_zero_bss:
|
2022-06-21 15:16:14 +00:00
|
|
|
mov.l r2, @r0
|
|
|
|
add #4, r0
|
2022-06-26 16:18:19 +00:00
|
|
|
cmp/gt r0, r1
|
2022-06-25 03:57:25 +00:00
|
|
|
bt _loop_zero_bss
|
2022-06-21 15:16:14 +00:00
|
|
|
|
2022-06-25 03:57:25 +00:00
|
|
|
_setup_fpu:
|
|
|
|
mov.l _set_fpscr_k, r1
|
2022-06-21 15:16:14 +00:00
|
|
|
jsr @r1
|
|
|
|
mov #0, r4
|
|
|
|
lds r3, fpscr
|
|
|
|
|
2022-08-07 03:35:45 +00:00
|
|
|
_setup_irq:
|
|
|
|
mov.l _exc_base_k, r0
|
|
|
|
ldc r0, vbr
|
|
|
|
|
|
|
|
stc sr, r0 /* Store SR into R0 */
|
|
|
|
mov.l _exc_imask_k, r1
|
|
|
|
and r1, r0
|
|
|
|
ldc r0, sr
|
|
|
|
|
2022-06-27 01:35:00 +00:00
|
|
|
.align 2
|
2022-06-25 08:29:45 +00:00
|
|
|
_main_entry:
|
2022-06-25 03:57:25 +00:00
|
|
|
mov.l _main_k, r0
|
2022-06-21 15:16:14 +00:00
|
|
|
jsr @r0
|
|
|
|
or r0, r0
|
|
|
|
|
2022-08-09 17:21:53 +00:00
|
|
|
mov.l _exit_loop_k, r0
|
|
|
|
_exit_loop:
|
|
|
|
sleep
|
|
|
|
jmp @r0
|
|
|
|
nop
|
2022-06-21 15:16:14 +00:00
|
|
|
|
2022-08-06 02:41:07 +00:00
|
|
|
.balign 4
|
2022-06-25 03:57:25 +00:00
|
|
|
/* libc FPU routine */
|
|
|
|
_set_fpscr_k:
|
2022-06-21 15:16:14 +00:00
|
|
|
.long ___set_fpscr
|
2022-06-25 03:57:25 +00:00
|
|
|
|
|
|
|
/* C library consts */
|
|
|
|
_stack_k:
|
2022-06-21 15:16:14 +00:00
|
|
|
.long _stack
|
2022-06-25 03:57:25 +00:00
|
|
|
_sidata_k:
|
2022-06-21 15:16:14 +00:00
|
|
|
.long _sidata
|
2022-06-25 03:57:25 +00:00
|
|
|
_sdata_k:
|
2022-06-21 15:16:14 +00:00
|
|
|
.long _sdata
|
2022-06-25 03:57:25 +00:00
|
|
|
_edata_k:
|
2022-06-21 15:16:14 +00:00
|
|
|
.long _edata
|
2022-06-25 03:57:25 +00:00
|
|
|
_end_k:
|
2022-06-21 15:16:14 +00:00
|
|
|
.long _end
|
2022-06-25 03:57:25 +00:00
|
|
|
|
|
|
|
/* Function pointers */
|
|
|
|
_main_k:
|
2022-06-21 15:16:14 +00:00
|
|
|
.long _main /* Same address as main */
|
2022-08-09 17:21:53 +00:00
|
|
|
_exit_loop_k:
|
|
|
|
.long _exit_loop
|
2022-06-26 16:18:19 +00:00
|
|
|
_exc_base_k:
|
|
|
|
.long _exc_base
|
2022-08-07 03:35:45 +00:00
|
|
|
_exc_imask_k:
|
2022-08-08 01:12:06 +00:00
|
|
|
.long 0xEFFFFF0F /* Clear IMASK (SR[7:4]) to 0 and BL bit, enable all exception levels */
|
2022-06-26 16:18:19 +00:00
|
|
|
|
2022-08-07 03:35:45 +00:00
|
|
|
/*
|
|
|
|
* Exception handlers
|
|
|
|
* These handlers are placed at VBR related addresses
|
|
|
|
*/
|
2022-06-26 16:18:19 +00:00
|
|
|
|
|
|
|
.section .text.exc, "ax"
|
|
|
|
.align 4
|
|
|
|
_exc_base:
|
|
|
|
.org 0x100, 0x00
|
|
|
|
_exc_grnl_vector:
|
2022-08-07 03:35:45 +00:00
|
|
|
mov.l _exc_grnl_entry_k, r0
|
|
|
|
jmp @r0
|
|
|
|
nop
|
|
|
|
|
|
|
|
.align 4
|
|
|
|
_exc_grnl_entry_k:
|
|
|
|
.long _general_exc_handler
|
|
|
|
|
|
|
|
_int_base:
|
|
|
|
.org 0x600, 0x00
|
|
|
|
_int_grnl_vector:
|
|
|
|
mov.l _int_grnl_entry_k, r0
|
2022-06-26 16:18:19 +00:00
|
|
|
jmp @r0
|
|
|
|
nop
|
|
|
|
|
|
|
|
.align 4
|
2022-08-07 03:35:45 +00:00
|
|
|
_int_grnl_entry_k:
|
|
|
|
.long _general_int_handler
|