Skip to content

Commit

Permalink
core: riscv: Update thread core local flags for native interrupts
Browse files Browse the repository at this point in the history
Record the type of stack and the type of interrupt into thread core
local flags before handling the native interrupts. Once we finish the
handling of the native interrupts, we clear the previous flags.

Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
  • Loading branch information
gagachang committed Sep 5, 2024
1 parent 5fc96f9 commit e137c38
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions core/arch/riscv/kernel/thread_rv.S
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,24 @@ foreign_interrupt_from_kernel:
tail thread_foreign_interrupt_handler

native_interrupt_from_kernel:
/* Update 32-bit core local flags */
lw a2, THREAD_CORE_LOCAL_FLAGS(tp)
slli a2, a2, THREAD_CLF_SAVED_SHIFT
ori a2, a2, (THREAD_CLF_TMP | THREAD_CLF_IRQ)
sw a2, THREAD_CORE_LOCAL_FLAGS(tp)

/*
* a0 = struct thread_ctx_regs *regs
* a1 = cause
* Call thread_native_interrupt_handler(regs, cause)
*/
call thread_native_interrupt_handler

/* Update 32-bit core local flags */
lw a2, THREAD_CORE_LOCAL_FLAGS(tp)
srli a2, a2, THREAD_CLF_SAVED_SHIFT
sw a2, THREAD_CORE_LOCAL_FLAGS(tp)

/* Get thread context as sp */
get_thread_ctx sp, t0
/* Restore XEPC */
Expand Down Expand Up @@ -351,13 +362,24 @@ foreign_interrupt_from_user:
tail thread_foreign_interrupt_handler

native_interrupt_from_user:
/* Update 32-bit core local flags */
lw a2, THREAD_CORE_LOCAL_FLAGS(tp)
slli a2, a2, THREAD_CLF_SAVED_SHIFT
ori a2, a2, (THREAD_CLF_TMP | THREAD_CLF_IRQ)
sw a2, THREAD_CORE_LOCAL_FLAGS(tp)

/*
* a0 = struct thread_ctx_regs *regs
* a1 = cause
* Call thread_native_interrupt_handler(regs, cause)
*/
call thread_native_interrupt_handler

/* Update 32-bit core local flags */
lw a2, THREAD_CORE_LOCAL_FLAGS(tp)
srli a2, a2, THREAD_CLF_SAVED_SHIFT
sw a2, THREAD_CORE_LOCAL_FLAGS(tp)

/* Get thread context as sp */
get_thread_ctx sp, t0
/* Restore XEPC */
Expand Down

0 comments on commit e137c38

Please sign in to comment.