Skip to content

Commit b66076f

Browse files
uefi: BootServices: Make some handle args compatible with uefi_raw
These are simple cases that just need an `as_ptr()` call to make the types line up.
1 parent c70bce2 commit b66076f

File tree

1 file changed

+44
-32
lines changed

1 file changed

+44
-32
lines changed

uefi/src/table/boot.rs

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,19 @@ struct BootServicesInternal {
100100
interface: *mut c_void,
101101
) -> Status,
102102
reinstall_protocol_interface: unsafe extern "efiapi" fn(
103-
handle: Handle,
103+
handle: uefi_raw::Handle,
104104
protocol: &Guid,
105105
old_interface: *mut c_void,
106106
new_interface: *mut c_void,
107107
) -> Status,
108108
uninstall_protocol_interface: unsafe extern "efiapi" fn(
109-
handle: Handle,
109+
handle: uefi_raw::Handle,
110110
protocol: &Guid,
111111
interface: *mut c_void,
112112
) -> Status,
113113
#[deprecated = "open_protocol and open_protocol_exclusive are better alternatives and available since EFI 1.10 (2002)"]
114114
handle_protocol: unsafe extern "efiapi" fn(
115-
handle: Handle,
115+
handle: uefi_raw::Handle,
116116
proto: &Guid,
117117
out_proto: &mut *mut c_void,
118118
) -> Status,
@@ -140,25 +140,26 @@ struct BootServicesInternal {
140140
// Image services
141141
load_image: unsafe extern "efiapi" fn(
142142
boot_policy: u8,
143-
parent_image_handle: Handle,
143+
parent_image_handle: uefi_raw::Handle,
144144
device_path: *const uefi_raw::protocol::device_path::DevicePathProtocol,
145145
source_buffer: *const u8,
146146
source_size: usize,
147147
image_handle: &mut Option<Handle>,
148148
) -> Status,
149149
start_image: unsafe extern "efiapi" fn(
150-
image_handle: Handle,
150+
image_handle: uefi_raw::Handle,
151151
exit_data_size: *mut usize,
152152
exit_data: &mut *mut Char16,
153153
) -> Status,
154154
exit: unsafe extern "efiapi" fn(
155-
image_handle: Handle,
155+
image_handle: uefi_raw::Handle,
156156
exit_status: Status,
157157
exit_data_size: usize,
158158
exit_data: *mut Char16,
159159
) -> !,
160-
unload_image: unsafe extern "efiapi" fn(image_handle: Handle) -> Status,
161-
exit_boot_services: unsafe extern "efiapi" fn(image_handle: Handle, map_key: usize) -> Status,
160+
unload_image: unsafe extern "efiapi" fn(image_handle: uefi_raw::Handle) -> Status,
161+
exit_boot_services:
162+
unsafe extern "efiapi" fn(image_handle: uefi_raw::Handle, map_key: usize) -> Status,
162163

163164
// Misc services
164165
get_next_monotonic_count: usize,
@@ -172,37 +173,37 @@ struct BootServicesInternal {
172173

173174
// Driver support services
174175
connect_controller: unsafe extern "efiapi" fn(
175-
controller: Handle,
176+
controller: uefi_raw::Handle,
176177
driver_image: Option<Handle>,
177178
remaining_device_path: *const uefi_raw::protocol::device_path::DevicePathProtocol,
178179
recursive: bool,
179180
) -> Status,
180181
disconnect_controller: unsafe extern "efiapi" fn(
181-
controller: Handle,
182+
controller: uefi_raw::Handle,
182183
driver_image: Option<Handle>,
183184
child: Option<Handle>,
184185
) -> Status,
185186

186187
// Protocol open / close services
187188
open_protocol: unsafe extern "efiapi" fn(
188-
handle: Handle,
189+
handle: uefi_raw::Handle,
189190
protocol: &Guid,
190191
interface: &mut *mut c_void,
191-
agent_handle: Handle,
192+
agent_handle: uefi_raw::Handle,
192193
controller_handle: Option<Handle>,
193194
attributes: u32,
194195
) -> Status,
195196
close_protocol: unsafe extern "efiapi" fn(
196-
handle: Handle,
197+
handle: uefi_raw::Handle,
197198
protocol: &Guid,
198-
agent_handle: Handle,
199+
agent_handle: uefi_raw::Handle,
199200
controller_handle: Option<Handle>,
200201
) -> Status,
201202
open_protocol_information: usize,
202203

203204
// Library services
204205
protocols_per_handle: unsafe extern "efiapi" fn(
205-
handle: Handle,
206+
handle: uefi_raw::Handle,
206207
protocol_buffer: *mut *mut *const Guid,
207208
protocol_buffer_count: *mut usize,
208209
) -> Status,
@@ -796,8 +797,13 @@ impl BootServices {
796797
old_interface: *mut c_void,
797798
new_interface: *mut c_void,
798799
) -> Result<()> {
799-
(self.0.reinstall_protocol_interface)(handle, protocol, old_interface, new_interface)
800-
.to_result()
800+
(self.0.reinstall_protocol_interface)(
801+
handle.as_ptr(),
802+
protocol,
803+
old_interface,
804+
new_interface,
805+
)
806+
.to_result()
801807
}
802808

803809
/// Removes a protocol interface from a device handle.
@@ -825,7 +831,7 @@ impl BootServices {
825831
protocol: &Guid,
826832
interface: *mut c_void,
827833
) -> Result<()> {
828-
(self.0.uninstall_protocol_interface)(handle, protocol, interface).to_result()
834+
(self.0.uninstall_protocol_interface)(handle.as_ptr(), protocol, interface).to_result()
829835
}
830836

831837
/// Registers `event` to be signalled whenever a protocol interface is registered for
@@ -1054,7 +1060,7 @@ impl BootServices {
10541060
unsafe {
10551061
(self.0.load_image)(
10561062
boot_policy,
1057-
parent_image_handle,
1063+
parent_image_handle.as_ptr(),
10581064
device_path.cast(),
10591065
source_buffer,
10601066
source_size,
@@ -1081,7 +1087,7 @@ impl BootServices {
10811087
/// * [`uefi::Status::UNSUPPORTED`]
10821088
/// * [`uefi::Status::INVALID_PARAMETER`]
10831089
pub fn unload_image(&self, image_handle: Handle) -> Result {
1084-
unsafe { (self.0.unload_image)(image_handle) }.to_result()
1090+
unsafe { (self.0.unload_image)(image_handle.as_ptr()) }.to_result()
10851091
}
10861092

10871093
/// Transfer control to a loaded image's entry point.
@@ -1101,7 +1107,8 @@ impl BootServices {
11011107
// TODO: implement returning exit data to the caller.
11021108
let mut exit_data_size: usize = 0;
11031109
let mut exit_data: *mut Char16 = ptr::null_mut();
1104-
(self.0.start_image)(image_handle, &mut exit_data_size, &mut exit_data).to_result()
1110+
(self.0.start_image)(image_handle.as_ptr(), &mut exit_data_size, &mut exit_data)
1111+
.to_result()
11051112
}
11061113
}
11071114

@@ -1121,7 +1128,12 @@ impl BootServices {
11211128
exit_data_size: usize,
11221129
exit_data: *mut Char16,
11231130
) -> ! {
1124-
(self.0.exit)(image_handle, exit_status, exit_data_size, exit_data)
1131+
(self.0.exit)(
1132+
image_handle.as_ptr(),
1133+
exit_status,
1134+
exit_data_size,
1135+
exit_data,
1136+
)
11251137
}
11261138

11271139
/// Exits the UEFI boot services
@@ -1145,7 +1157,7 @@ impl BootServices {
11451157
image: Handle,
11461158
mmap_key: MemoryMapKey,
11471159
) -> Result {
1148-
(self.0.exit_boot_services)(image, mmap_key.0).to_result()
1160+
(self.0.exit_boot_services)(image.as_ptr(), mmap_key.0).to_result()
11491161
}
11501162

11511163
/// Stalls the processor for an amount of time.
@@ -1255,7 +1267,7 @@ impl BootServices {
12551267
) -> Result {
12561268
unsafe {
12571269
(self.0.connect_controller)(
1258-
controller,
1270+
controller.as_ptr(),
12591271
driver_image,
12601272
remaining_device_path
12611273
.map(|dp| dp.as_ffi_ptr())
@@ -1284,7 +1296,7 @@ impl BootServices {
12841296
driver_image: Option<Handle>,
12851297
child: Option<Handle>,
12861298
) -> Result {
1287-
unsafe { (self.0.disconnect_controller)(controller, driver_image, child) }
1299+
unsafe { (self.0.disconnect_controller)(controller.as_ptr(), driver_image, child) }
12881300
.to_result_with_err(|_| ())
12891301
}
12901302

@@ -1337,10 +1349,10 @@ impl BootServices {
13371349
) -> Result<ScopedProtocol<P>> {
13381350
let mut interface = ptr::null_mut();
13391351
(self.0.open_protocol)(
1340-
params.handle,
1352+
params.handle.as_ptr(),
13411353
&P::GUID,
13421354
&mut interface,
1343-
params.agent,
1355+
params.agent.as_ptr(),
13441356
params.controller,
13451357
attributes as u32,
13461358
)
@@ -1408,10 +1420,10 @@ impl BootServices {
14081420
let mut interface = ptr::null_mut();
14091421
unsafe {
14101422
(self.0.open_protocol)(
1411-
params.handle,
1423+
params.handle.as_ptr(),
14121424
&P::GUID,
14131425
&mut interface,
1414-
params.agent,
1426+
params.agent.as_ptr(),
14151427
params.controller,
14161428
TEST_PROTOCOL,
14171429
)
@@ -1433,7 +1445,7 @@ impl BootServices {
14331445
let mut count = 0;
14341446

14351447
let mut status =
1436-
unsafe { (self.0.protocols_per_handle)(handle, &mut protocols, &mut count) };
1448+
unsafe { (self.0.protocols_per_handle)(handle.as_ptr(), &mut protocols, &mut count) };
14371449

14381450
if !status.is_error() {
14391451
// Ensure that protocols isn't null, and that none of the GUIDs
@@ -1857,9 +1869,9 @@ impl<'a, P: Protocol + ?Sized> Drop for ScopedProtocol<'a, P> {
18571869
fn drop(&mut self) {
18581870
let status = unsafe {
18591871
(self.boot_services.0.close_protocol)(
1860-
self.open_params.handle,
1872+
self.open_params.handle.as_ptr(),
18611873
&P::GUID,
1862-
self.open_params.agent,
1874+
self.open_params.agent.as_ptr(),
18631875
self.open_params.controller,
18641876
)
18651877
};

0 commit comments

Comments
 (0)