Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions platforms/axplat-riscv64-qemu-virt/src/irq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ use plic::{Mode, PLIC};
use riscv::register::sie;
use sbi_rt::HartMask;

static TISH_CPU_ID_FUNC: AtomicPtr<()> = AtomicPtr::new(core::ptr::null_mut());

pub fn register_this_cpu_id(func: fn() -> usize) {
TISH_CPU_ID_FUNC.store(func as *mut (), Ordering::Relaxed);
}

/// `Interrupt` bit in `scause`
pub(super) const INTC_IRQ_BASE: usize = 1 << (usize::BITS - 1);

Expand Down Expand Up @@ -189,8 +195,10 @@ impl IrqIf for IrqIfImpl {
}
},
@S_EXT => {
// TODO: hart
let irq = PLIC.claim(0, Mode::Supervisor);
let hart = unsafe {
core::mem::transmute::<*mut (), fn() -> usize>(TISH_CPU_ID_FUNC.load(Ordering::Relaxed))()
} as u32;
let irq = PLIC.claim(hart, Mode::Supervisor);
if !IRQ_HANDLER_TABLE.handle(irq as _) {
debug!("Unhandled IRQ {irq}");
}
Expand Down