File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -137,9 +137,18 @@ impl<T> RemoteHsmCell<'_, T> {
137
137
/// 取出当前状态。
138
138
#[ inline]
139
139
pub fn sbi_get_status ( & self ) -> usize {
140
- match self . 0 . status . load ( Ordering :: Acquire ) {
140
+ match self . 0 . status . load ( Ordering :: Relaxed ) {
141
141
HART_STATE_START_PENDING_EXT => HART_STATE_START_PENDING ,
142
142
normal => normal,
143
143
}
144
144
}
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
+ }
145
154
}
Original file line number Diff line number Diff line change 1
1
#![ allow( unused) ]
2
2
3
+ use crate :: trap_stack:: remote_hsm;
3
4
use core:: cell:: UnsafeCell ;
4
5
use rustsbi:: { spec:: binary:: SbiRet , HartMask , Ipi , Timer } ;
5
6
@@ -8,10 +9,8 @@ pub(crate) struct Clint;
8
9
impl Ipi for Clint {
9
10
#[ inline]
10
11
fn send_ipi ( & self , hart_mask : HartMask ) -> SbiRet {
11
- // let hsm = crate::HSM.wait();
12
12
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 ( ) ) {
15
14
msip:: send ( i) ;
16
15
}
17
16
}
You can’t perform that action at this time.
0 commit comments