Skip to content

Commit

Permalink
Co Pro RISC-V: Add seperate system stack, primarily for UncaughtExcep…
Browse files Browse the repository at this point in the history
…tionHandler

Change-Id: I5beab8b55e4549fd321212f758617855dae8ced7
  • Loading branch information
hoglet67 committed Sep 21, 2023
1 parent 6381b54 commit 7b7b3ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/riscv/tuberom.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
unsigned char tuberom_riscv_bin[] = {
0x6f, 0x00, 0x40, 0x00, 0x37, 0x01, 0xf8, 0x00, 0x13, 0x01, 0x01, 0xff,
0x6f, 0x00, 0x40, 0x00, 0x37, 0x01, 0xfc, 0x00, 0x13, 0x01, 0x01, 0xdf,
0x17, 0x03, 0x00, 0x00, 0x13, 0x03, 0x83, 0x19, 0xb7, 0x03, 0xfc, 0x00,
0x93, 0x83, 0x03, 0xe8, 0x13, 0x0e, 0xe0, 0x00, 0x83, 0x22, 0x03, 0x00,
0x23, 0xa0, 0x53, 0x00, 0x13, 0x03, 0x43, 0x00, 0x93, 0x83, 0x43, 0x00,
Expand Down Expand Up @@ -38,8 +38,8 @@ unsigned char tuberom_riscv_bin[] = {
0x00, 0xfe, 0xfb, 0x00, 0xdc, 0x01, 0xfc, 0x00, 0x80, 0xff, 0xfb, 0x00,
0x20, 0x02, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x02, 0xfc, 0x00,
0x00, 0x00, 0x00, 0x00, 0x8c, 0x0c, 0xfc, 0x00, 0x40, 0xfe, 0xfb, 0x00,
0x8c, 0x0c, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x01, 0xf8, 0x00,
0x13, 0x01, 0x01, 0xff, 0xb7, 0x08, 0xac, 0x00, 0x93, 0x88, 0x58, 0x00,
0x8c, 0x0c, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x01, 0xfc, 0x00,
0x13, 0x01, 0x01, 0xdf, 0xb7, 0x08, 0xac, 0x00, 0x93, 0x88, 0x58, 0x00,
0x73, 0x00, 0x00, 0x00, 0x13, 0x05, 0x45, 0x00, 0xef, 0x10, 0x80, 0x20,
0xb7, 0x08, 0xac, 0x00, 0x93, 0x88, 0x58, 0x00, 0x73, 0x00, 0x00, 0x00,
0x6f, 0xf0, 0x9f, 0xed, 0x33, 0x05, 0xa5, 0x00, 0xb7, 0x02, 0xfc, 0x00,
Expand Down Expand Up @@ -267,7 +267,7 @@ unsigned char tuberom_riscv_bin[] = {
0x23, 0x26, 0x11, 0x00, 0xb7, 0x00, 0xfc, 0x00, 0x93, 0x80, 0x00, 0xeb,
0x83, 0xa0, 0x00, 0x00, 0xe7, 0x80, 0x00, 0x00, 0x83, 0x20, 0xc1, 0x00,
0x13, 0x01, 0x01, 0x01, 0x73, 0x00, 0x20, 0x30, 0x73, 0x10, 0x01, 0x34,
0x37, 0x01, 0xf8, 0x00, 0x13, 0x01, 0x01, 0xff, 0x13, 0x01, 0x01, 0xf8,
0x37, 0x01, 0xfc, 0x00, 0x13, 0x01, 0x01, 0xdf, 0x13, 0x01, 0x01, 0xf8,
0x23, 0x20, 0x01, 0x00, 0x23, 0x22, 0x11, 0x00, 0xf3, 0x20, 0x00, 0x34,
0x23, 0x24, 0x11, 0x00, 0x23, 0x26, 0x31, 0x00, 0x23, 0x28, 0x41, 0x00,
0x23, 0x2a, 0x51, 0x00, 0x23, 0x2c, 0x61, 0x00, 0x23, 0x2e, 0x71, 0x00,
Expand Down
14 changes: 7 additions & 7 deletions src/riscv/tuberom_riscv.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
.equ MEM_BOT, 0x00000000
.equ MEM_TOP, 0x00F80000
.equ ROM_BASE, 0x00FC0000
.equ STACK, MEM_TOP - 16 # 16 byte aligned
.equ WORKSPACE, ROM_BASE - 0x200
.equ SYS_STACK, WORKSPACE - 16 # 16 byte aligned
.equ USER_STACK, MEM_TOP - 16 # 16 byte aligned
.equ TUBE, 0x00FFFFE0

.equ R1STATUS, 0
Expand Down Expand Up @@ -42,8 +44,6 @@

# Workspace consumes 0x200 bytes immediately below the Client ROM

.equ WORKSPACE , ROM_BASE - 0x200

.equ BUFSIZE , 0x80 # size of the Error buffer and Input Buffer

.equ VARIABLES , WORKSPACE + 0x000
Expand Down Expand Up @@ -154,7 +154,7 @@ _start:
j ResetHandler

ResetHandler:
li sp, STACK # setup the stack
li sp, SYS_STACK # setup the stack

la t1, DefaultHandlerTable # copy the default handlers table
la t2, HANDLER_TABLE
Expand Down Expand Up @@ -211,7 +211,7 @@ DefaultExitHandler:
sw a1, (a0) # current program to be the cmdOsLoop

EnterCurrent:
li sp, STACK # reset the stack
li sp, USER_STACK # reset the stack
li t0, 1 << 3 # enable interrupts
csrrs zero, mstatus, t0

Expand Down Expand Up @@ -279,7 +279,7 @@ DefaultHandlerTable:
# a0 points to the error block

DefaultErrorHandler:
li sp, STACK # setup the stack
li sp, SYS_STACK # setup the stack
SYS OS_NEWL
addi a0, a0, 4
jal print_string
Expand Down Expand Up @@ -1456,7 +1456,7 @@ DefaultUncaughtExceptionHandler:
# Store all register state on stack

csrw mscratch, sp # store the original stack pointer in the mscratch CSR
li sp, STACK # setup a new stack
li sp, SYS_STACK # setup a new stack

addi sp, sp, -128
sw zero, 0(sp)
Expand Down

0 comments on commit 7b7b3ed

Please sign in to comment.