Skip to content

Commit dfed4ae

Browse files
committed
doc/uefi: improve device path documentation
Make the role of the high-level DevicePath wrapper more clear.
1 parent a0a76eb commit dfed4ae

File tree

1 file changed

+34
-11
lines changed
  • uefi/src/proto/device_path

1 file changed

+34
-11
lines changed

uefi/src/proto/device_path/mod.rs

+34-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// SPDX-License-Identifier: MIT OR Apache-2.0
22

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`].
76
//!
87
//! A device path is made up of a packed list of variable-length nodes of
98
//! various types. The entire device path is terminated with an
@@ -346,19 +345,43 @@ impl ToOwned for DevicePathInstance {
346345
}
347346
}
348347

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.
350355
///
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.
357363
///
358364
/// See the [module-level documentation] for more details.
359365
///
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+
///
360382
/// [module-level documentation]: crate::proto::device_path
361383
/// [`END_ENTIRE`]: DeviceSubType::END_ENTIRE
384+
/// [`DevicePathProtocol`]: uefi_raw::protocol::device_path::DevicePathProtocol
362385
#[repr(C, packed)]
363386
#[unsafe_protocol(uefi_raw::protocol::device_path::DevicePathProtocol::GUID)]
364387
#[derive(Eq, Pointee)]

0 commit comments

Comments
 (0)