Skip to content

Commit 314219d

Browse files
uefi: BootServices: Make ProtocolSearchKey args compatible with uefi_raw
1 parent 7a3a10c commit 314219d

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

uefi/src/table/boot.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ struct BootServicesInternal {
120120
register_protocol_notify: unsafe extern "efiapi" fn(
121121
protocol: &Guid,
122122
event: uefi_raw::Event,
123-
registration: *mut Option<ProtocolSearchKey>,
123+
registration: *mut *const c_void,
124124
) -> Status,
125125
locate_handle: unsafe extern "efiapi" fn(
126126
search_ty: i32,
127-
proto: Option<&Guid>,
128-
key: Option<ProtocolSearchKey>,
129-
buf_sz: &mut usize,
127+
proto: *const Guid,
128+
key: *const c_void,
129+
buf_sz: *mut usize,
130130
buf: *mut uefi_raw::Handle,
131131
) -> Status,
132132
locate_device_path: unsafe extern "efiapi" fn(
@@ -209,9 +209,9 @@ struct BootServicesInternal {
209209
) -> Status,
210210
locate_handle_buffer: unsafe extern "efiapi" fn(
211211
search_ty: i32,
212-
proto: Option<&Guid>,
213-
key: Option<ProtocolSearchKey>,
214-
no_handles: &mut usize,
212+
proto: *const Guid,
213+
key: *const c_void,
214+
no_handles: *mut usize,
215215
buf: *mut *mut uefi_raw::Handle,
216216
) -> Status,
217217
#[deprecated = "open_protocol and open_protocol_exclusive are better alternatives and available since EFI 1.10 (2002)"]
@@ -869,15 +869,17 @@ impl BootServices {
869869
protocol: &Guid,
870870
event: Event,
871871
) -> Result<(Event, SearchType)> {
872-
let mut key = None;
872+
let mut key = ptr::null();
873873
// Safety: we clone `event` a couple times, but there will be only one left once we return.
874874
unsafe { (self.0.register_protocol_notify)(protocol, event.as_ptr(), &mut key) }
875875
// Safety: as long as this call is successful, `key` will be valid.
876876
.to_result_with_val(|| unsafe {
877877
(
878878
event.unsafe_clone(),
879879
// OK to unwrap: key is non-null for Status::SUCCESS.
880-
SearchType::ByRegisterNotify(key.unwrap()),
880+
SearchType::ByRegisterNotify(ProtocolSearchKey(
881+
NonNull::new(key.cast_mut()).unwrap(),
882+
)),
881883
)
882884
})
883885
}
@@ -912,9 +914,11 @@ impl BootServices {
912914

913915
// Obtain the needed data from the parameters.
914916
let (ty, guid, key) = match search_ty {
915-
SearchType::AllHandles => (0, None, None),
916-
SearchType::ByRegisterNotify(registration) => (1, None, Some(registration)),
917-
SearchType::ByProtocol(guid) => (2, Some(guid), None),
917+
SearchType::AllHandles => (0, ptr::null(), ptr::null()),
918+
SearchType::ByRegisterNotify(registration) => {
919+
(1, ptr::null(), registration.0.as_ptr().cast_const())
920+
}
921+
SearchType::ByProtocol(guid) => (2, guid as *const Guid, ptr::null()),
918922
};
919923

920924
let status =
@@ -1504,9 +1508,11 @@ impl BootServices {
15041508

15051509
// Obtain the needed data from the parameters.
15061510
let (ty, guid, key) = match search_ty {
1507-
SearchType::AllHandles => (0, None, None),
1508-
SearchType::ByRegisterNotify(registration) => (1, None, Some(registration)),
1509-
SearchType::ByProtocol(guid) => (2, Some(guid), None),
1511+
SearchType::AllHandles => (0, ptr::null(), ptr::null()),
1512+
SearchType::ByRegisterNotify(registration) => {
1513+
(1, ptr::null(), registration.0.as_ptr().cast_const())
1514+
}
1515+
SearchType::ByProtocol(guid) => (2, guid as *const _, ptr::null()),
15101516
};
15111517

15121518
unsafe { (self.0.locate_handle_buffer)(ty, guid, key, &mut num_handles, &mut buffer) }

0 commit comments

Comments
 (0)