Skip to content

Commit e6163a5

Browse files
Merge pull request #907 from devsnek/smp-event
add event to smp
2 parents af3c38d + c3f2c1f commit e6163a5

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
members now have upper-case names.
1414
- `FileSystem::try_exists` now returns `FileSystemResult<bool>`.
1515
- `FileSystem::copy` is now more efficient for large files.
16+
- `MpService::startup_all_aps` and `MpService::startup_this_ap` now accept an
17+
optional `event` parameter to allow non-blocking operation.
1618

1719
## uefi-macros - [Unreleased]
1820

uefi-test-runner/src/proto/pi/mp.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn test_startup_all_aps(mps: &MpServices, bt: &BootServices) {
8484
// Ensure that APs start up
8585
let counter = AtomicUsize::new(0);
8686
let counter_ptr: *mut c_void = &counter as *const _ as *mut _;
87-
mps.startup_all_aps(false, proc_increment_atomic, counter_ptr, None)
87+
mps.startup_all_aps(false, proc_increment_atomic, counter_ptr, None, None)
8888
.unwrap();
8989
assert_eq!(counter.load(Ordering::Relaxed), NUM_CPUS - 1);
9090

@@ -94,6 +94,7 @@ fn test_startup_all_aps(mps: &MpServices, bt: &BootServices) {
9494
false,
9595
proc_wait_100ms,
9696
bt_ptr,
97+
None,
9798
Some(Duration::from_millis(50)),
9899
);
99100
assert_eq!(ret.map_err(|err| err.status()), Err(Status::TIMEOUT));
@@ -104,15 +105,21 @@ fn test_startup_this_ap(mps: &MpServices, bt: &BootServices) {
104105
let counter = AtomicUsize::new(0);
105106
let counter_ptr: *mut c_void = &counter as *const _ as *mut _;
106107
for i in 1..NUM_CPUS {
107-
mps.startup_this_ap(i, proc_increment_atomic, counter_ptr, None)
108+
mps.startup_this_ap(i, proc_increment_atomic, counter_ptr, None, None)
108109
.unwrap();
109110
}
110111
assert_eq!(counter.load(Ordering::Relaxed), NUM_CPUS - 1);
111112

112113
// Make sure that timeout works for each AP
113114
let bt_ptr: *mut c_void = bt as *const _ as *mut _;
114115
for i in 1..NUM_CPUS {
115-
let ret = mps.startup_this_ap(i, proc_wait_100ms, bt_ptr, Some(Duration::from_millis(50)));
116+
let ret = mps.startup_this_ap(
117+
i,
118+
proc_wait_100ms,
119+
bt_ptr,
120+
None,
121+
Some(Duration::from_millis(50)),
122+
);
116123
assert_eq!(ret.map_err(|err| err.status()), Err(Status::TIMEOUT));
117124
}
118125
}

uefi/src/proto/pi/mp.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//! * maintaining MP-related processor status
1313
1414
use crate::proto::unsafe_protocol;
15-
use crate::{Result, Status, StatusExt};
15+
use crate::{data_types::Event, Result, Status, StatusExt};
1616
use bitflags::bitflags;
1717
use core::ffi::c_void;
1818
use core::ptr;
@@ -153,24 +153,30 @@ impl MpServices {
153153
(self.get_processor_info)(self, processor_number, &mut pi).to_result_with_val(|| pi)
154154
}
155155

156-
/// Executes provided function on all APs in blocking mode.
156+
/// Executes provided function on all APs.
157157
pub fn startup_all_aps(
158158
&self,
159159
single_thread: bool,
160160
procedure: Procedure,
161161
procedure_argument: *mut c_void,
162+
event: Option<Event>,
162163
timeout: Option<Duration>,
163164
) -> Result {
164165
let timeout_arg = match timeout {
165166
Some(timeout) => timeout.as_micros().try_into().unwrap(),
166167
None => 0,
167168
};
168169

170+
let event_arg = match event {
171+
Some(event) => event.as_ptr(),
172+
None => ptr::null_mut(),
173+
};
174+
169175
(self.startup_all_aps)(
170176
self,
171177
procedure,
172178
single_thread,
173-
ptr::null_mut(),
179+
event_arg,
174180
timeout_arg,
175181
procedure_argument,
176182
ptr::null_mut(),
@@ -184,18 +190,24 @@ impl MpServices {
184190
processor_number: usize,
185191
procedure: Procedure,
186192
procedure_argument: *mut c_void,
193+
event: Option<Event>,
187194
timeout: Option<Duration>,
188195
) -> Result {
189196
let timeout_arg = match timeout {
190197
Some(timeout) => timeout.as_micros().try_into().unwrap(),
191198
None => 0,
192199
};
193200

201+
let event_arg = match event {
202+
Some(event) => event.as_ptr(),
203+
None => ptr::null_mut(),
204+
};
205+
194206
(self.startup_this_ap)(
195207
self,
196208
procedure,
197209
processor_number,
198-
ptr::null_mut(),
210+
event_arg,
199211
timeout_arg,
200212
procedure_argument,
201213
ptr::null_mut(),

0 commit comments

Comments
 (0)