增加测试代码,让整个主站的代码工作在RV32E的编译选项下,仅中断代码工作在RV32I的编译选项下,可以优化中断的速度。代码仅做备份,中断部分执行不正常

This commit is contained in:
2025-02-03 07:51:54 +08:00
parent 1ae3a395d8
commit ab506a0e37
5 changed files with 219 additions and 56 deletions

View File

@@ -2,6 +2,13 @@
.extern main
.extern plic_handle
.extern mst_svr_code
.extern plic_claim
.extern flag_intTxEnd
.extern flag_intRxError
.extern flag_intRxStart
.extern flag_intRxEnd
.globl _prog_start
.section .text.init
@@ -22,6 +29,7 @@ _prog_start:
li x13, 0
li x14, 0
li x15, 0
#ifdef __RV32I_MARCH__
li x16, 0
li x17, 0
li x18, 0
@@ -38,15 +46,39 @@ _prog_start:
li x29, 0
li x30, 0
li x31, 0
#endif
li sp, 0x40011000
lui t0, %hi(plic_claim)
lw a0, %lo(plic_claim)(t0)
#la a0, plic_claim
lui t0, %hi(flag_intTxEnd)
lw a1, %lo(flag_intTxEnd)(t0)
#la a1, flag_intTxEnd
lui t0, %hi(flag_intRxError)
lw a2, %lo(flag_intRxError)(t0)
#la a2, flag_intRxError
lui t0, %hi(flag_intRxStart)
lw a3, %lo(flag_intRxStart)(t0)
#la a3, flag_intRxStart
lui t0, %hi(flag_intRxEnd)
lw a4, %lo(flag_intRxEnd)(t0)
#la a4, flag_intRxEnd
call mst_svr_code
mv t0, a0
#la t0, trap_entry
la t0, opt_trap_entry
#la t0, opt_trap_entry
csrw mtvec, t0
li t0, 1 << 11
csrw mie, t0
li sp, 0x40011000
csrr t0, mstatus
ori t0, t0, 1<<3
csrw mstatus, t0
@@ -56,7 +88,6 @@ _prog_start:
ecall
.balign 32
.section .trap_entry, "ax", %progbits
trap_entry:
@@ -77,6 +108,7 @@ trap_entry:
sw a3,52(sp)
sw a4,56(sp)
sw a5,60(sp)
#ifdef __RV32I_MARCH__
sw a6,64(sp)
sw a7,68(sp)
sw s2,72(sp)
@@ -93,6 +125,7 @@ trap_entry:
sw t4,116(sp)
sw t5,120(sp)
sw t6,124(sp)
#endif
csrr t0, mstatus # mstatus
andi t0, t0, ~(1 << 3) # MIE ()
@@ -119,6 +152,7 @@ trap_entry:
lw a3,52(sp)
lw a4,56(sp)
lw a5,60(sp)
#ifdef __RV32I_MARCH__
lw a6,64(sp)
lw a7,68(sp)
lw s2,72(sp)
@@ -135,10 +169,9 @@ trap_entry:
lw t4,116(sp)
lw t5,120(sp)
lw t6,124(sp)
#endif
addi sp,sp,136
mret
#.macro define_const name, value
@@ -147,13 +180,6 @@ trap_entry:
## 使
#define_const CDR_INT_TXEND, 14
.extern plic_claim
.extern flag_intTxEnd
.extern flag_intRxError
.extern flag_intRxStart
.extern flag_intRxEnd
opt_trap_entry:
addi sp,sp,-136
@@ -196,58 +222,47 @@ opt_trap_entry:
andi t0, t0, ~(1 << 3) # MIE ()
csrw mstatus, t0 # mstatus
# t0 = &plic_claim
lui t1, %hi(plic_claim)
lw t0, %lo(plic_claim)(t1)
# t1 = *plic_claim
lw t1, 0(t0)
lw t0, %lo(plic_claim)(t1) # t0 = &plic_claim
lw t1, 0(t0) # t1 = *plic_claim
sw t1, 0(t0) # *plic_claim = t1
li s0, CDR_INT_TXEND
#_if (t1 != s0) goto 1f
bne t1, s0, 1f
bne t1, s0, 1f #_if (t1 != s0) goto 1f
#_else
lui s0,%hi(flag_intTxEnd)
lui s0,%hi(flag_intTxEnd) #_else
li s1,1
sw s1,%lo(flag_intTxEnd)(s0)
j 4f
1:
li s0, CDR_INT_RXERROR
#_if (t1 != s0) goto 2f
bne t1, s0, 2f
bne t1, s0, 2f #_if (t1 != s0) goto 2f
#_else
lui s0,%hi(flag_intRxError)
lui s0,%hi(flag_intRxError) #_else
li s1,1
sw s1,%lo(flag_intRxError)(s0)
j 4f
2:
li s0, CDR_INT_RXSTART
#_if (t1 != s0) goto 3f
bne t1, s0, 3f
bne t1, s0, 3f #_if (t1 != s0) goto 3f
#_else
lui s0,%hi(flag_intRxStart)
lui s0,%hi(flag_intRxStart) #_else
li s1,1
sw s1,%lo(flag_intRxStart)(s0)
j 4f
3:
li s0, CDR_INT_RXEND
bne t1, s0, 4f #_if (t1 != s0) goto 4f
#_if (t1 != s0) goto 4f
beq t1, s0, 4f
#_else
lui s0,%hi(flag_intRxEnd)
lui s0,%hi(flag_intRxEnd) #_else
li s1,1
sw s1,%lo(flag_intRxEnd)(s0)
4:
sw t1, 0(t0)
csrr t0, mstatus
ori t0, t0, 1<<3
csrw mstatus, t0
@@ -292,4 +307,3 @@ opt_trap_entry: