kernel: fix isr context handling

We were loading both the context and the banked context, which resulted
in an invalid context being selected.  This caused a cascading failure.

Load only the lower halfword in order to correctly enter the interrupt
context.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-03-24 15:24:19 +08:00
parent fb01359821
commit fa22d9bad8
6 changed files with 4 additions and 4 deletions

View file

@ -51,10 +51,10 @@ _start:
_start_trap:
csrw sscratch, sp
li sp, 0xff801000
STORE x1, 0*REGBYTES(sp)
LOAD x1, 1*REGBYTES(sp)
slli x1, x1, 7
add sp, sp, x1
STORE x1, 0*REGBYTES(sp) // Store x1 in the scratch field
lh x1, 1*REGBYTES(sp) // Load current context number
slli x1, x1, 7 // Multiply current context number by 32
add sp, sp, x1 // Set $sp to 0xff801000 + (current_context * 32)
STORE x1, 0*REGBYTES(sp)
// Skip SP for now