Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
`LoadedImage::load_options_as_cstr16`.
- Added `Align::offset_up_to_alignment`, `Align::round_up_to_alignment`,
and `Align::align_buf`.
- Added `BootServices::connect_controller` and
`BootServices::disconnect_controller`.

### Changed

Expand Down
51 changes: 49 additions & 2 deletions src/table/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,17 @@ pub struct BootServices {
) -> Status,

// Driver support services
connect_controller: usize,
disconnect_controller: usize,
connect_controller: unsafe extern "efiapi" fn(
controller: Handle,
driver_image: Option<Handle>,
remaining_device_path: *const DevicePath,
recursive: bool,
) -> Status,
disconnect_controller: unsafe extern "efiapi" fn(
controller: Handle,
driver_image: Option<Handle>,
child: Option<Handle>,
) -> Status,

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

/// Connect one or more drivers to a controller.
///
/// Usually one disconnects and then reconnects certain drivers
/// to make them rescan some state that changed, e.g. reconnecting
/// a `BlockIO` handle after your app changed the partitions somehow.
pub fn connect_controller(
&self,
controller: Handle,
driver_image: Option<Handle>,
remaining_device_path: Option<&DevicePath>,
recursive: bool,
) -> Result {
unsafe {
(self.connect_controller)(
controller,
driver_image,
remaining_device_path
.map(|dp| dp as _)
.unwrap_or(ptr::null()),
recursive,
)
}
.into_with_err(|_| ())
}

/// Disconnect one or more drivers from a controller.
///
/// See [`connect_controller`][Self::connect_controller].
pub fn disconnect_controller(
&self,
controller: Handle,
driver_image: Option<Handle>,
child: Option<Handle>,
) -> Result {
unsafe { (self.disconnect_controller)(controller, driver_image, child) }
.into_with_err(|_| ())
}

/// Open a protocol interface for a handle.
///
/// This function attempts to get the protocol implementation of a
Expand Down