Skip to content

Commit 1d4b48b

Browse files
nicholasbishopphip1611
authored andcommitted
uefi-raw: Fill in [un]install_multiple_protocol_interfaces pointers
The existing comment there said the unstable `c-variadic` feature was required, but that was incorrect. While defining c-variadic functions is unstable in Rust, c-variadic function pointers are stable (calling c-variadics is also stable). We still can't quite define these two function pointers correctly because they should be `extern "efiapi", which requires the unstable `extended_varargs_abi_support` feature. However, as long as your code is compiled for a UEFI target, `extern "C"` gives you the correct ABI. Since these function pointers are `unsafe` to call, we can expose them in the raw interface and leave it up to the caller to ensure they are used correctly.
1 parent 7cc0708 commit 1d4b48b

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

uefi-raw/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66

77
## Changed
88
- `{install,reinstall,uninstall}_protocol_interface` now take `const` interface pointers.
9+
- `{un}install_multiple_protocol_interfaces` are now defined as c-variadic
10+
function pointers. The ABI is `extern "C"` until such time as
11+
[`extended_varargs_abi_support`](https://github.com/rust-lang/rust/issues/100189)
12+
is stabilized.

uefi-raw/src/table/boot.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,28 @@ pub struct BootServices {
188188
out_proto: *mut *mut c_void,
189189
) -> Status,
190190

191-
// These two function pointers require the `c_variadic` feature, which is
192-
// not yet available in stable Rust:
193-
// https://github.com/rust-lang/rust/issues/44930
194-
pub install_multiple_protocol_interfaces: usize,
195-
pub uninstall_multiple_protocol_interfaces: usize,
191+
/// Warning: this function pointer is declared as `extern "C"` rather than
192+
/// `extern "efiapi". That means it will work correctly when called from a
193+
/// UEFI target (`*-unknown-uefi`), but will not work when called from a
194+
/// target with a different calling convention such as
195+
/// `x86_64-unknown-linux-gnu`.
196+
///
197+
/// Support for C-variadics with `efiapi` requires the unstable
198+
/// [`extended_varargs_abi_support`](https://github.com/rust-lang/rust/issues/100189)
199+
/// feature.
200+
pub install_multiple_protocol_interfaces:
201+
unsafe extern "C" fn(handle: *mut Handle, ...) -> Status,
202+
203+
/// Warning: this function pointer is declared as `extern "C"` rather than
204+
/// `extern "efiapi". That means it will work correctly when called from a
205+
/// UEFI target (`*-unknown-uefi`), but will not work when called from a
206+
/// target with a different calling convention such as
207+
/// `x86_64-unknown-linux-gnu`.
208+
///
209+
/// Support for C-variadics with `efiapi` requires the unstable
210+
/// [`extended_varargs_abi_support`](https://github.com/rust-lang/rust/issues/100189)
211+
/// feature.
212+
pub uninstall_multiple_protocol_interfaces: unsafe extern "C" fn(handle: Handle, ...) -> Status,
196213

197214
// CRC services
198215
pub calculate_crc32:

0 commit comments

Comments
 (0)