Skip to content

Commit 69d3da2

Browse files
Use const interface pointers in protocol management functions
A protocol's interface may mutate itself, but the void pointer passed to the `{install,reinstall,uninstall}_protocol_interface` functions is opaque to the firmware, so there's no need for it to be a mut pointer. Note that from a Rust safety perspective there's no difference here -- mut and const pointers are interchangeable. rust-osdev#970
1 parent 23a9f1b commit 69d3da2

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@
1616
`Logger::set_output` to enable it.
1717
- `uefi::allocator::init` now takes a `&mut SystemTable<Boot>` instead of
1818
`&BootServices`.
19+
- `BootServices::{install,reinstall,uninstall}_protocol_interface` now take
20+
`const` interface pointers.
1921

2022
## uefi-macros - [Unreleased]
2123

2224
## uefi-raw - [Unreleased]
2325

26+
### Changed
27+
- `{install,reinstall,uninstall}_protocol_interface` now take `const` interface pointers.
28+
2429
## uefi-services - [Unreleased]
2530

2631
### Changed

uefi-raw/src/table/boot.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ pub struct BootServices {
6161
handle: *mut Handle,
6262
guid: *const Guid,
6363
interface_type: InterfaceType,
64-
interface: *mut c_void,
64+
interface: *const c_void,
6565
) -> Status,
6666
pub reinstall_protocol_interface: unsafe extern "efiapi" fn(
6767
handle: Handle,
6868
protocol: *const Guid,
69-
old_interface: *mut c_void,
70-
new_interface: *mut c_void,
69+
old_interface: *const c_void,
70+
new_interface: *const c_void,
7171
) -> Status,
7272
pub uninstall_protocol_interface: unsafe extern "efiapi" fn(
7373
handle: Handle,
7474
protocol: *const Guid,
75-
interface: *mut c_void,
75+
interface: *const c_void,
7676
) -> Status,
7777
pub handle_protocol: unsafe extern "efiapi" fn(
7878
handle: Handle,

uefi/src/table/boot.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ impl BootServices {
559559
&self,
560560
handle: Option<Handle>,
561561
protocol: &Guid,
562-
interface: *mut c_void,
562+
interface: *const c_void,
563563
) -> Result<Handle> {
564564
let mut handle = Handle::opt_to_ptr(handle);
565565
((self.0.install_protocol_interface)(
@@ -594,8 +594,8 @@ impl BootServices {
594594
&self,
595595
handle: Handle,
596596
protocol: &Guid,
597-
old_interface: *mut c_void,
598-
new_interface: *mut c_void,
597+
old_interface: *const c_void,
598+
new_interface: *const c_void,
599599
) -> Result<()> {
600600
(self.0.reinstall_protocol_interface)(
601601
handle.as_ptr(),
@@ -629,7 +629,7 @@ impl BootServices {
629629
&self,
630630
handle: Handle,
631631
protocol: &Guid,
632-
interface: *mut c_void,
632+
interface: *const c_void,
633633
) -> Result<()> {
634634
(self.0.uninstall_protocol_interface)(handle.as_ptr(), protocol, interface).to_result()
635635
}

0 commit comments

Comments
 (0)