|
1 | 1 | use uefi::prelude::*;
|
2 |
| -use uefi::proto::device_path::DevicePath; |
| 2 | +use uefi::proto::device_path::{text::*, DevicePath}; |
3 | 3 | use uefi::proto::loaded_image::LoadedImage;
|
4 | 4 | use uefi::table::boot::{BootServices, OpenProtocolAttributes, OpenProtocolParams};
|
5 | 5 |
|
@@ -30,12 +30,32 @@ pub fn test(image: Handle, bt: &BootServices) {
|
30 | 30 | .expect("Failed to open DevicePath protocol");
|
31 | 31 | let device_path = unsafe { &*device_path.interface.get() };
|
32 | 32 |
|
| 33 | + let device_path_to_text = bt |
| 34 | + .locate_protocol::<DevicePathToText>() |
| 35 | + .expect("Failed to open DevicePathToText protocol"); |
| 36 | + let device_path_to_text = unsafe { &*device_path_to_text.get() }; |
| 37 | + |
| 38 | + let device_path_from_text = bt |
| 39 | + .locate_protocol::<DevicePathFromText>() |
| 40 | + .expect("Failed to open DevicePathFromText protocol"); |
| 41 | + let device_path_from_text = unsafe { &*device_path_from_text.get() }; |
| 42 | + |
33 | 43 | for path in device_path.iter() {
|
34 | 44 | info!(
|
35 | 45 | "path: type={:?}, subtype={:?}, length={}",
|
36 | 46 | path.device_type(),
|
37 | 47 | path.sub_type(),
|
38 | 48 | path.length(),
|
39 | 49 | );
|
| 50 | + |
| 51 | + let text = device_path_to_text |
| 52 | + .convert_device_path_to_text(path, DisplayOnly(true), AllowShortcuts(false)) |
| 53 | + .expect("Failed to convert device path to text"); |
| 54 | + info!("path name: {text}"); |
| 55 | + |
| 56 | + let convert = device_path_from_text |
| 57 | + .convert_text_to_device_path(text) |
| 58 | + .expect("Failed to convert text to device path"); |
| 59 | + assert_eq!(path, convert); |
40 | 60 | }
|
41 | 61 | }
|
0 commit comments