|
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. |
7 |
| -//! |
8 |
| -//! A device path is made up of a packed list of variable-length nodes of |
9 |
| -//! various types. The entire device path is terminated with an |
10 |
| -//! [`END_ENTIRE`] node. A device path _may_ contain multiple device-path |
11 |
| -//! instances separated by [`END_INSTANCE`] nodes, but typical paths contain |
12 |
| -//! only a single instance (in which case no `END_INSTANCE` node is needed). |
13 |
| -//! |
14 |
| -//! Example of what a device path containing two instances (each comprised of |
15 |
| -//! three nodes) might look like: |
16 |
| -//! |
17 |
| -//! ```text |
18 |
| -//! ┌──────┬─────┬──────────────╥───────┬──────────┬────────────┐ |
19 |
| -//! │ ACPI │ PCI │ END_INSTANCE ║ CDROM │ FILEPATH │ END_ENTIRE │ |
20 |
| -//! └──────┴─────┴──────────────╨───────┴──────────┴────────────┘ |
21 |
| -//! ↑ ↑ ↑ |
22 |
| -//! ├─── DevicePathInstance ────╨────── DevicePathInstance ─────┤ |
23 |
| -//! │ │ |
24 |
| -//! └─────────────────── Entire DevicePath ─────────────────────┘ |
25 |
| -//! ``` |
| 3 | +//! High-level wrappers for [UEFI device paths] and the UEFI device path |
| 4 | +//! [`Protocol`]. |
26 | 5 | //!
|
27 | 6 | //! # Types
|
28 | 7 | //!
|
|
74 | 53 | //! [`Protocol`]: crate::proto::Protocol
|
75 | 54 | //! [`device_type`]: DevicePathNode::device_type
|
76 | 55 | //! [`sub_type`]: DevicePathNode::sub_type
|
| 56 | +//! [UEFI device paths]: uefi_raw::protocol::device_path |
77 | 57 |
|
78 | 58 | pub mod build;
|
79 | 59 | pub mod text;
|
@@ -400,19 +380,43 @@ impl ToOwned for DevicePathInstance {
|
400 | 380 | }
|
401 | 381 | }
|
402 | 382 |
|
403 |
| -/// Device path protocol. |
404 |
| -/// |
405 |
| -/// Can be used on any device handle to obtain generic path/location information |
406 |
| -/// concerning the physical device or logical device. If the handle does not |
407 |
| -/// logically map to a physical device, the handle may not necessarily support |
408 |
| -/// the device path protocol. The device path describes the location of the |
409 |
| -/// device the handle is for. The size of the Device Path can be determined from |
410 |
| -/// the structures that make up the Device Path. |
| 383 | +/// High-level representation of the UEFI [device path protocol](uefi_raw::protocol::device_path). |
411 | 384 | ///
|
412 | 385 | /// See the [module-level documentation] for more details.
|
413 | 386 | ///
|
| 387 | +/// # Usage |
| 388 | +/// This type implements [`DevicePathProtocol`] and therefore can be used on any |
| 389 | +/// device handle to obtain generic path/location information concerning the |
| 390 | +/// physical device or logical device. If the handle does not logically map to a |
| 391 | +/// physical device, the handle may not necessarily support the device path |
| 392 | +/// protocol. The device path describes the location of the device the handle is |
| 393 | +/// for. The size of the Device Path can be determined from the structures that |
| 394 | +/// make up the Device Path. |
| 395 | +/// |
| 396 | +/// # Example |
| 397 | +/// ```rust,no_run |
| 398 | +/// use uefi::Handle; |
| 399 | +/// use uefi::boot::{open_protocol_exclusive, ScopedProtocol}; |
| 400 | +/// use uefi::proto::device_path::DevicePath; |
| 401 | +/// use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly}; |
| 402 | +/// use uefi::proto::loaded_image::LoadedImage; |
| 403 | +/// |
| 404 | +/// fn open_device_path(image_handle: Handle) { |
| 405 | +/// let loaded_image = open_protocol_exclusive::<LoadedImage>(image_handle).unwrap(); |
| 406 | +/// let device_handle = loaded_image.device().unwrap(); |
| 407 | +/// let device_path: ScopedProtocol<DevicePath> |
| 408 | +/// = open_protocol_exclusive::<DevicePath>(device_handle).unwrap(); |
| 409 | +/// log::debug!( |
| 410 | +/// "Device path: {}", |
| 411 | +/// device_path.to_string(DisplayOnly(true), AllowShortcuts(true)).unwrap() |
| 412 | +/// ); |
| 413 | +/// } |
| 414 | +/// ``` |
| 415 | +/// |
414 | 416 | /// [module-level documentation]: crate::proto::device_path
|
415 | 417 | /// [`END_ENTIRE`]: DeviceSubType::END_ENTIRE
|
| 418 | +/// [`DevicePathProtocol`]: uefi_raw::protocol::device_path::DevicePathProtocol |
| 419 | +/// [`Protocol`]: uefi::proto::Protocol |
416 | 420 | #[repr(C, packed)]
|
417 | 421 | #[unsafe_protocol(uefi_raw::protocol::device_path::DevicePathProtocol::GUID)]
|
418 | 422 | #[derive(Eq, Pointee)]
|
|
0 commit comments