Skip to content

Commit 20f4ae9

Browse files
necauquanicholasbishop
authored andcommitted
Implement the ConnectController/DisconnectController methods
1 parent c8a8721 commit 20f4ae9

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
`LoadedImage::load_options_as_cstr16`.
1616
- Added `Align::offset_up_to_alignment`, `Align::round_up_to_alignment`,
1717
and `Align::align_buf`.
18+
- Added `BootServices::connect_controller` and
19+
`BootServices::disconnect_controller`.
1820

1921
### Changed
2022

src/table/boot.rs

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,17 @@ pub struct BootServices {
119119
) -> Status,
120120

121121
// Driver support services
122-
connect_controller: usize,
123-
disconnect_controller: usize,
122+
connect_controller: unsafe extern "efiapi" fn(
123+
controller: Handle,
124+
driver_image: Option<Handle>,
125+
remaining_device_path: *const DevicePath,
126+
recursive: bool,
127+
) -> Status,
128+
disconnect_controller: unsafe extern "efiapi" fn(
129+
controller: Handle,
130+
driver_image: Option<Handle>,
131+
child: Option<Handle>,
132+
) -> Status,
124133

125134
// Protocol open / close services
126135
open_protocol: extern "efiapi" fn(
@@ -694,6 +703,44 @@ impl BootServices {
694703
unsafe { (self.set_watchdog_timer)(timeout, watchdog_code, data_len, data) }.into()
695704
}
696705

706+
/// Connect one or more drivers to a controller.
707+
///
708+
/// Usually one disconnects and then reconnects certain drivers
709+
/// to make them rescan some state that changed, e.g. reconnecting
710+
/// a `BlockIO` handle after your app changed the partitions somehow.
711+
pub fn connect_controller(
712+
&self,
713+
controller: Handle,
714+
driver_image: Option<Handle>,
715+
remaining_device_path: Option<&DevicePath>,
716+
recursive: bool,
717+
) -> Result {
718+
unsafe {
719+
(self.connect_controller)(
720+
controller,
721+
driver_image,
722+
remaining_device_path
723+
.map(|dp| dp as _)
724+
.unwrap_or(ptr::null()),
725+
recursive,
726+
)
727+
}
728+
.into_with_err(|_| ())
729+
}
730+
731+
/// Disconnect one or more drivers from a controller.
732+
///
733+
/// See [`connect_controller`][Self::connect_controller].
734+
pub fn disconnect_controller(
735+
&self,
736+
controller: Handle,
737+
driver_image: Option<Handle>,
738+
child: Option<Handle>,
739+
) -> Result {
740+
unsafe { (self.disconnect_controller)(controller, driver_image, child) }
741+
.into_with_err(|_| ())
742+
}
743+
697744
/// Open a protocol interface for a handle.
698745
///
699746
/// This function attempts to get the protocol implementation of a

0 commit comments

Comments
 (0)