2020-12-10 11:02:26 +08:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020-2020, BLUETRUM Development Team
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ab32vg1.h"
|
|
|
|
|
|
2021-05-14 11:59:30 +08:00
|
|
|
|
.set _memcpy, 0x84044
|
2020-12-10 11:02:26 +08:00
|
|
|
|
.global _start
|
|
|
|
|
.section .reset, "ax"
|
|
|
|
|
_start:
|
2021-05-13 10:22:09 +08:00
|
|
|
|
la tp, _tp
|
|
|
|
|
la gp, _gp
|
2020-12-15 23:43:04 +08:00
|
|
|
|
|
2020-12-10 11:02:26 +08:00
|
|
|
|
//load comm
|
|
|
|
|
la a0, __comm_vma
|
|
|
|
|
la a1, __comm_lma
|
|
|
|
|
la a2, __comm_size
|
2021-05-14 11:59:30 +08:00
|
|
|
|
call _memcpy
|
2020-12-10 11:02:26 +08:00
|
|
|
|
|
2020-12-15 23:43:04 +08:00
|
|
|
|
//load ram1
|
|
|
|
|
la a0, __ram1_vma
|
|
|
|
|
la a1, __ram1_lma
|
|
|
|
|
la a2, __ram1_size
|
2021-05-14 11:59:30 +08:00
|
|
|
|
call _memcpy
|
2020-12-10 11:02:26 +08:00
|
|
|
|
|
|
|
|
|
la a0, __irq_stack_start //Stack清成0x23
|
|
|
|
|
li a1, 0x23
|
|
|
|
|
la a2, __irq_stack_size
|
2021-05-14 11:59:30 +08:00
|
|
|
|
call rt_memset
|
2020-12-10 11:02:26 +08:00
|
|
|
|
la ra, __irq_stack
|
|
|
|
|
lui a5, 0x1
|
|
|
|
|
sw zero, -1920(a5)
|
|
|
|
|
sw zero, -1916(a5)
|
|
|
|
|
|
|
|
|
|
//clear bss
|
|
|
|
|
la a0, __bss_start
|
|
|
|
|
li a1, 0
|
|
|
|
|
la a2, __bss_size
|
2021-05-14 11:59:30 +08:00
|
|
|
|
call rt_memset
|
2020-12-10 11:02:26 +08:00
|
|
|
|
|
2021-04-09 17:35:26 +08:00
|
|
|
|
call cache_init
|
|
|
|
|
|
2020-12-10 11:02:26 +08:00
|
|
|
|
la a0, __comm_vma
|
|
|
|
|
sw a0, PICADR(zero)
|
|
|
|
|
|
|
|
|
|
call entry
|
2021-04-09 17:35:26 +08:00
|
|
|
|
la ra, __exception
|
|
|
|
|
jr ra
|
2020-12-10 11:02:26 +08:00
|
|
|
|
|
|
|
|
|
.section .vector, "ax"
|
2021-04-09 17:35:26 +08:00
|
|
|
|
.org 0x10
|
|
|
|
|
__exception:
|
|
|
|
|
li sp, 0x10600 //出错后,不破坏错误点的堆栈数据
|
|
|
|
|
jal exception_isr
|
|
|
|
|
1: j 1b
|
|
|
|
|
mret
|
2020-12-10 11:02:26 +08:00
|
|
|
|
|
|
|
|
|
.org 0x40
|
|
|
|
|
jal x0, low_prio_irq
|
|
|
|
|
|
2020-12-19 10:45:03 +08:00
|
|
|
|
.org 0x80
|
|
|
|
|
#define METHOD 1
|
|
|
|
|
#if METHOD == 1
|
|
|
|
|
addi sp, sp, -6*4
|
2021-05-13 10:22:09 +08:00
|
|
|
|
# lw a0, PICEN(zero)
|
2020-12-19 10:45:03 +08:00
|
|
|
|
lw a1, EPC(zero)
|
|
|
|
|
lw a2, EPICCON(zero)
|
2021-05-13 10:22:09 +08:00
|
|
|
|
# sw a0, 3*4(sp)
|
2020-12-19 10:45:03 +08:00
|
|
|
|
sw a1, 4*4(sp)
|
|
|
|
|
sw a2, 5*4(sp)
|
2021-05-13 10:22:09 +08:00
|
|
|
|
# andi a0, a0, 1
|
|
|
|
|
# sw a0, PICEN(zero)
|
|
|
|
|
li a2, 0
|
|
|
|
|
sw a2, EPICCON(zero)
|
2020-12-19 10:45:03 +08:00
|
|
|
|
la a0, 0f
|
|
|
|
|
sw a0, EPC(zero)
|
2021-05-13 10:22:09 +08:00
|
|
|
|
j isr_cache
|
2020-12-19 10:45:03 +08:00
|
|
|
|
0:
|
|
|
|
|
sw a0, 0(sp)
|
|
|
|
|
sw a1, 4(sp)
|
|
|
|
|
sw a2, 8(sp)
|
|
|
|
|
|
2021-05-13 10:22:09 +08:00
|
|
|
|
# lw a0, 3*4(sp)
|
2020-12-19 10:45:03 +08:00
|
|
|
|
lw a1, 4*4(sp)
|
|
|
|
|
lw a2, 5*4(sp)
|
2021-05-13 10:22:09 +08:00
|
|
|
|
# sw a0, PICEN(zero)
|
2020-12-19 10:45:03 +08:00
|
|
|
|
sw a1, EPC(zero)
|
|
|
|
|
sw a2, EPICCON(zero)
|
|
|
|
|
|
|
|
|
|
lw a0, 0(sp)
|
|
|
|
|
lw a1, 4(sp)
|
|
|
|
|
lw a2, 8(sp)
|
|
|
|
|
addi sp, sp, 6*4
|
|
|
|
|
mret
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-11-05 17:16:44 +08:00
|
|
|
|
.org 0x1e0
|
|
|
|
|
1: j 1b
|
|
|
|
|
nop
|
|
|
|
|
mret
|
|
|
|
|
|
2020-12-10 11:02:26 +08:00
|
|
|
|
.global cpu_irq_comm
|
|
|
|
|
cpu_irq_comm:
|
|
|
|
|
la a5, __irq_stack
|
|
|
|
|
mv sp, a5
|
|
|
|
|
j cpu_irq_comm_do
|
|
|
|
|
|
|
|
|
|
ret
|
2021-05-13 10:22:09 +08:00
|
|
|
|
|
|
|
|
|
.global _tp
|
|
|
|
|
.set _tp, 0x84800
|