2018-10-14 17:12:01 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 Travis Geiselbrecht
|
|
|
|
|
*
|
2019-07-05 17:22:23 -07:00
|
|
|
* Use of this source code is governed by a MIT-style
|
|
|
|
|
* license that can be found in the LICENSE file or at
|
|
|
|
|
* https://opensource.org/licenses/MIT
|
2018-10-14 17:12:01 -07:00
|
|
|
*/
|
2019-06-17 18:28:51 -07:00
|
|
|
#include <lk/asm.h>
|
2018-10-14 17:12:01 -07:00
|
|
|
|
|
|
|
|
.section ".text.boot"
|
|
|
|
|
FUNCTION(_start)
|
2019-02-17 18:55:42 -08:00
|
|
|
.option push
|
|
|
|
|
.option norelax
|
|
|
|
|
# set the global pointer
|
|
|
|
|
la gp, __global_pointer$
|
|
|
|
|
.option pop
|
|
|
|
|
|
2018-10-14 17:12:01 -07:00
|
|
|
# set the default stack
|
|
|
|
|
la sp, default_stack_top
|
|
|
|
|
|
2019-11-02 17:21:13 -07:00
|
|
|
#if ARCH_RISCV_TWOSEGMENT
|
2018-10-14 17:12:01 -07:00
|
|
|
# copy preinitialized data from flash to memory
|
|
|
|
|
la t0, __data_start_rom
|
|
|
|
|
la t1, __data_start
|
|
|
|
|
la t2, __data_end
|
|
|
|
|
beq t0, t1, 1f
|
|
|
|
|
|
|
|
|
|
0:
|
|
|
|
|
lw t3, (t0)
|
|
|
|
|
sw t3, (t1)
|
|
|
|
|
add t0, t0, 4
|
|
|
|
|
add t1, t1, 4
|
|
|
|
|
bne t1, t2, 0b
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
# zero bss
|
|
|
|
|
1:
|
|
|
|
|
la t0, __bss_start
|
|
|
|
|
la t1, __bss_end
|
|
|
|
|
0:
|
|
|
|
|
sw x0, (t0)
|
|
|
|
|
add t0, t0, 4
|
|
|
|
|
bne t0, t1, 0b
|
|
|
|
|
|
|
|
|
|
# call main
|
|
|
|
|
jal lk_main
|
|
|
|
|
|
2019-02-17 20:20:16 -08:00
|
|
|
# should never return here
|
2018-10-14 17:12:01 -07:00
|
|
|
j .
|
|
|
|
|
|
|
|
|
|
.bss
|
|
|
|
|
.align 4
|
|
|
|
|
LOCAL_DATA(default_stack)
|
|
|
|
|
.skip 1024
|
|
|
|
|
LOCAL_DATA(default_stack_top)
|