Skip to content

Commit 9b76cab

Browse files
committed
uefi: improve documentation of device paths
1 parent 16cf403 commit 9b76cab

File tree

1 file changed

+29
-6
lines changed
  • uefi/src/proto/device_path

1 file changed

+29
-6
lines changed

uefi/src/proto/device_path/mod.rs

+29-6
Original file line numberDiff line numberDiff line change
@@ -374,17 +374,40 @@ impl ToOwned for DevicePathInstance {
374374

375375
/// Device Path [`Protocol`].
376376
///
377-
/// Can be used on any device handle to obtain generic path/location information
378-
/// concerning the physical device or logical device. If the handle does not
379-
/// logically map to a physical device, the handle may not necessarily support
380-
/// the device path protocol. The device path describes the location of the
381-
/// device the handle is for. The size of the Device Path can be determined from
382-
/// the structures that make up the Device Path.
377+
/// A UEFI device path is a structured sequence of binary nodes that describe a
378+
/// route from the UEFI root to a particular device, controller, or file. Each
379+
/// node represents a step in the path: PCI device, partition, filesystem, file
380+
/// path, etc.
381+
///
382+
/// This type implements [`DevicePathProtocol`] and therefore can be used on any
383+
/// device handle to obtain generic path/location information concerning the
384+
/// physical device or logical device. If the handle does not logically map to a
385+
/// physical device, the handle may not necessarily support the device path
386+
/// protocol. The device path describes the location of the device the handle is
387+
/// for. The size of the Device Path can be determined from the structures that
388+
/// make up the Device Path.
383389
///
384390
/// See the [module-level documentation] for more details.
385391
///
392+
/// # Example
393+
/// ```rust,no_run
394+
/// use uefi::Handle;
395+
/// use uefi::boot::{open_protocol_exclusive, ScopedProtocol};
396+
/// use uefi::proto::device_path::DevicePath;
397+
/// use uefi::proto::loaded_image::LoadedImage;
398+
///
399+
/// fn open_device_path(image_handle: Handle) {
400+
/// let loaded_image = open_protocol_exclusive::<LoadedImage>(image_handle).unwrap();
401+
/// let device_handle = loaded_image.device().unwrap();
402+
/// // We use `DevicePath` as protocol and also as return type.
403+
/// let device_path: ScopedProtocol<DevicePath>
404+
/// = open_protocol_exclusive::<DevicePath>(device_handle).unwrap();
405+
/// }
406+
/// ```
407+
///
386408
/// [module-level documentation]: crate::proto::device_path
387409
/// [`END_ENTIRE`]: DeviceSubType::END_ENTIRE
410+
/// [`DevicePathProtocol`]: uefi_raw::protocol::device_path::DevicePathProtocol
388411
/// [`Protocol`]: uefi::proto::Protocol
389412
#[repr(C, packed)]
390413
#[unsafe_protocol(uefi_raw::protocol::device_path::DevicePathProtocol::GUID)]

0 commit comments

Comments
 (0)