|
1 | 1 | // SPDX-License-Identifier: MIT OR Apache-2.0
|
2 | 2 |
|
3 |
| -//! Device Path protocol |
4 |
| -//! |
5 |
| -//! A UEFI device path is a very flexible structure for encoding a |
6 |
| -//! programmatic path such as a hard drive or console. |
| 3 | +//! Helpers to work with UEFI Device Paths and the Device Path Protocol |
| 4 | +//! |
| 5 | +//! The main export of this module is [`DevicePath`]. |
7 | 6 | //!
|
8 | 7 | //! A device path is made up of a packed list of variable-length nodes of
|
9 | 8 | //! various types. The entire device path is terminated with an
|
@@ -346,19 +345,43 @@ impl ToOwned for DevicePathInstance {
|
346 | 345 | }
|
347 | 346 | }
|
348 | 347 |
|
349 |
| -/// Device path protocol. |
| 348 | +/// Type representing a UEFI device path and also implementing the UEFI |
| 349 | +/// protocol. |
| 350 | +/// |
| 351 | +/// A UEFI device path is a structured sequence of binary nodes that describe a |
| 352 | +/// route from the UEFI root to a particular device, controller, or file. Each |
| 353 | +/// node represents a step in the path: PCI device, partition, filesystem, file |
| 354 | +/// path, etc. |
350 | 355 | ///
|
351 |
| -/// Can be used on any device handle to obtain generic path/location information |
352 |
| -/// concerning the physical device or logical device. If the handle does not |
353 |
| -/// logically map to a physical device, the handle may not necessarily support |
354 |
| -/// the device path protocol. The device path describes the location of the |
355 |
| -/// device the handle is for. The size of the Device Path can be determined from |
356 |
| -/// the structures that make up the Device Path. |
| 356 | +/// This type implements [`DevicePathProtocol`] and therefore can be used on any |
| 357 | +/// device handle to obtain generic path/location information concerning the |
| 358 | +/// physical device or logical device. If the handle does not logically map to a |
| 359 | +/// physical device, the handle may not necessarily support the device path |
| 360 | +/// protocol. The device path describes the location of the device the handle is |
| 361 | +/// for. The size of the Device Path can be determined from the structures that |
| 362 | +/// make up the Device Path. |
357 | 363 | ///
|
358 | 364 | /// See the [module-level documentation] for more details.
|
359 | 365 | ///
|
| 366 | +/// # Example |
| 367 | +/// ```rust |
| 368 | +/// use uefi::Handle; |
| 369 | +/// use uefi::boot::{open_protocol_exclusive, ScopedProtocol}; |
| 370 | +/// use uefi::proto::device_path::DevicePath; |
| 371 | +/// use uefi::proto::loaded_image::LoadedImage; |
| 372 | +/// |
| 373 | +/// fn open_device_path(image_handle: Handle) { |
| 374 | +/// let loaded_image = open_protocol_exclusive::<LoadedImage>(image_handle).unwrap(); |
| 375 | +/// let device_handle = loaded_image .device().unwrap(); |
| 376 | +/// // We use `DevicePath` as protocol and also as return type. |
| 377 | +/// let device_path: ScopedProtocol<DevicePath> |
| 378 | +/// = open_protocol_exclusive::<DevicePath>(device_handle).unwrap(); |
| 379 | +/// } |
| 380 | +/// ``` |
| 381 | +/// |
360 | 382 | /// [module-level documentation]: crate::proto::device_path
|
361 | 383 | /// [`END_ENTIRE`]: DeviceSubType::END_ENTIRE
|
| 384 | +/// [`DevicePathProtocol`]: uefi_raw::protocol::device_path::DevicePathProtocol |
362 | 385 | #[repr(C, packed)]
|
363 | 386 | #[unsafe_protocol(uefi_raw::protocol::device_path::DevicePathProtocol::GUID)]
|
364 | 387 | #[derive(Eq, Pointee)]
|
|
0 commit comments