Skip to content

Commit 16cd39b

Browse files
committed
uefi: improve documentation of device paths
1 parent 73db0b9 commit 16cd39b

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
@@ -347,17 +347,40 @@ impl ToOwned for DevicePathInstance {
347347

348348
/// Device Path [`Protocol`].
349349
///
350-
/// Can be used on any device handle to obtain generic path/location information
351-
/// concerning the physical device or logical device. If the handle does not
352-
/// logically map to a physical device, the handle may not necessarily support
353-
/// the device path protocol. The device path describes the location of the
354-
/// device the handle is for. The size of the Device Path can be determined from
355-
/// the structures that make up the Device Path.
350+
/// A UEFI device path is a structured sequence of binary nodes that describe a
351+
/// route from the UEFI root to a particular device, controller, or file. Each
352+
/// node represents a step in the path: PCI device, partition, filesystem, file
353+
/// path, etc.
354+
///
355+
/// This type implements [`DevicePathProtocol`] and therefore can be used on any
356+
/// device handle to obtain generic path/location information concerning the
357+
/// physical device or logical device. If the handle does not logically map to a
358+
/// physical device, the handle may not necessarily support the device path
359+
/// protocol. The device path describes the location of the device the handle is
360+
/// for. The size of the Device Path can be determined from the structures that
361+
/// make up the Device Path.
356362
///
357363
/// See the [module-level documentation] for more details.
358364
///
365+
/// # Example
366+
/// ```rust,no_run
367+
/// use uefi::Handle;
368+
/// use uefi::boot::{open_protocol_exclusive, ScopedProtocol};
369+
/// use uefi::proto::device_path::DevicePath;
370+
/// use uefi::proto::loaded_image::LoadedImage;
371+
///
372+
/// fn open_device_path(image_handle: Handle) {
373+
/// let loaded_image = open_protocol_exclusive::<LoadedImage>(image_handle).unwrap();
374+
/// let device_handle = loaded_image.device().unwrap();
375+
/// // We use `DevicePath` as protocol and also as return type.
376+
/// let device_path: ScopedProtocol<DevicePath>
377+
/// = open_protocol_exclusive::<DevicePath>(device_handle).unwrap();
378+
/// }
379+
/// ```
380+
///
359381
/// [module-level documentation]: crate::proto::device_path
360382
/// [`END_ENTIRE`]: DeviceSubType::END_ENTIRE
383+
/// [`DevicePathProtocol`]: uefi_raw::protocol::device_path::DevicePathProtocol
361384
/// [`Protocol`]: uefi::proto::Protocol
362385
#[repr(C, packed)]
363386
#[unsafe_protocol(uefi_raw::protocol::device_path::DevicePathProtocol::GUID)]

0 commit comments

Comments
 (0)