Skip to content

riscv: add generic way to detect if inside interrupt context - #1483

Open
bbawj wants to merge 1 commit into
FreeRTOS:mainfrom
bbawj:main
Open

riscv: add generic way to detect if inside interrupt context#1483
bbawj wants to merge 1 commit into
FreeRTOS:mainfrom
bbawj:main

Conversation

@bbawj

@bbawj bbawj commented Aug 27, 2026

Copy link
Copy Markdown

Description

There is currently no extension agnostic way to detect interrupt nesting in RISC-V. The RP2350 port contains a custom meicontext CSR register. There is also alternatively the CLIC extension which would expose the mintstatus CSR.

In the absence of those, this patch adds xInterruptNesting as a global variable. The old value is stored on the stack context before being incremented when executing the portSAVE_CONTEXT_INTERNAL macro. The old value is restored in the portRESTORE_CONTEXT macro

Test Steps

Compiled using riscv32-unknown-elf-gcc and ran kernel demos in qemu-system-riscv32 virt machine.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant