Skip to content

Commit 38b9783

Browse files
committed
fix: 判断 allow ipi
Signed-off-by: YdrMaster <[email protected]>
1 parent e14536f commit 38b9783

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

hsm-cell/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,18 @@ impl<T> RemoteHsmCell<'_, T> {
137137
/// 取出当前状态。
138138
#[inline]
139139
pub fn sbi_get_status(&self) -> usize {
140-
match self.0.status.load(Ordering::Acquire) {
140+
match self.0.status.load(Ordering::Relaxed) {
141141
HART_STATE_START_PENDING_EXT => HART_STATE_START_PENDING,
142142
normal => normal,
143143
}
144144
}
145+
146+
/// 判断这个 HART 能否接收 IPI。
147+
#[inline]
148+
pub fn allow_ipi(&self) -> bool {
149+
matches!(
150+
self.0.status.load(Ordering::Relaxed),
151+
HART_STATE_STARTED | HART_STATE_SUSPENDED
152+
)
153+
}
145154
}

rustsbi-qemu/src/clint.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![allow(unused)]
22

3+
use crate::trap_stack::remote_hsm;
34
use core::cell::UnsafeCell;
45
use rustsbi::{spec::binary::SbiRet, HartMask, Ipi, Timer};
56

@@ -8,10 +9,8 @@ pub(crate) struct Clint;
89
impl Ipi for Clint {
910
#[inline]
1011
fn send_ipi(&self, hart_mask: HartMask) -> SbiRet {
11-
// let hsm = crate::HSM.wait();
1212
for i in 0..crate::NUM_HART_MAX {
13-
if hart_mask.has_bit(i) {
14-
//&& hsm.is_ipi_allowed(i) {
13+
if hart_mask.has_bit(i) && remote_hsm(i).map_or(false, |hsm| hsm.allow_ipi()) {
1514
msip::send(i);
1615
}
1716
}

0 commit comments

Comments
 (0)