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 the UEFI device path [`Protocol`], i.e.,
4
+ //! [UEFI device paths].
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;
@@ -92,7 +72,6 @@ use core::ffi::c_void;
92
72
use core:: fmt:: { self , Debug , Display , Formatter } ;
93
73
use core:: ops:: Deref ;
94
74
use ptr_meta:: Pointee ;
95
-
96
75
use uefi_raw:: protocol:: device_path:: DevicePathProtocol ;
97
76
#[ cfg( feature = "alloc" ) ]
98
77
use {
@@ -400,21 +379,49 @@ impl ToOwned for DevicePathInstance {
400
379
}
401
380
}
402
381
403
- /// Device path protocol.
382
+ /// High-level representation of the UEFI [device path protocol] .
404
383
///
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.
384
+ /// This type represents an entire device path, possibly consisting of multiple
385
+ /// [`DevicePathInstance`]s and [`DevicePathNode`]s.
411
386
///
412
387
/// See the [module-level documentation] for more details.
413
388
///
389
+ /// # Usage
390
+ /// This type implements [`Protocol`] and therefore can be used on any
391
+ /// device handle to obtain generic path/location information concerning the
392
+ /// physical device or logical device. If the handle does not logically map to a
393
+ /// physical device, the handle may not necessarily support the device path
394
+ /// protocol. The device path describes the location of the device the handle is
395
+ /// for. The size of the Device Path can be determined from the structures that
396
+ /// make up the Device Path.
397
+ ///
398
+ /// # Example
399
+ /// ```rust,no_run
400
+ /// use uefi::Handle;
401
+ /// use uefi::boot::{open_protocol_exclusive, ScopedProtocol};
402
+ /// use uefi::proto::device_path::DevicePath;
403
+ /// use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly};
404
+ /// use uefi::proto::loaded_image::LoadedImage;
405
+ ///
406
+ /// fn open_device_path(image_handle: Handle) {
407
+ /// let loaded_image = open_protocol_exclusive::<LoadedImage>(image_handle).unwrap();
408
+ /// let device_handle = loaded_image.device().unwrap();
409
+ /// let device_path: ScopedProtocol<DevicePath>
410
+ /// = open_protocol_exclusive::<DevicePath>(device_handle).unwrap();
411
+ /// log::debug!(
412
+ /// "Device path: {}",
413
+ /// device_path.to_string(DisplayOnly(true), AllowShortcuts(true)).unwrap()
414
+ /// );
415
+ /// }
416
+ /// ```
417
+ ///
414
418
/// [module-level documentation]: crate::proto::device_path
415
419
/// [`END_ENTIRE`]: DeviceSubType::END_ENTIRE
420
+ /// [`DevicePathProtocol`]: uefi_raw::protocol::device_path::DevicePathProtocol
421
+ /// [`Protocol`]: uefi::proto::Protocol
422
+ /// [device path protocol]: uefi_raw::protocol::device_path
416
423
#[ repr( C , packed) ]
417
- #[ unsafe_protocol( uefi_raw :: protocol :: device_path :: DevicePathProtocol :: GUID ) ]
424
+ #[ unsafe_protocol( DevicePathProtocol :: GUID ) ]
418
425
#[ derive( Eq , Pointee ) ]
419
426
pub struct DevicePath {
420
427
data : [ u8 ] ,
0 commit comments