File tree Expand file tree Collapse file tree 3 files changed +45
-2
lines changed
uefi-test-runner/src/proto Expand file tree Collapse file tree 3 files changed +45
-2
lines changed Original file line number Diff line number Diff line change 1
1
use uefi:: prelude:: * ;
2
2
use uefi:: proto:: device_path:: text:: * ;
3
- use uefi:: proto:: device_path:: DevicePath ;
3
+ use uefi:: proto:: device_path:: { DevicePath , LoadedImageDevicePath } ;
4
4
use uefi:: proto:: loaded_image:: LoadedImage ;
5
5
use uefi:: table:: boot:: BootServices ;
6
6
@@ -48,4 +48,16 @@ pub fn test(image: Handle, bt: &BootServices) {
48
48
. expect ( "Failed to convert text to device path" ) ;
49
49
assert_eq ! ( path, convert) ;
50
50
}
51
+
52
+ // Get the `LoadedImageDevicePath`. Verify it start with the same nodes as
53
+ // `device_path`.
54
+ let loaded_image_device_path = bt
55
+ . open_protocol_exclusive :: < LoadedImageDevicePath > ( image)
56
+ . expect ( "Failed to open LoadedImageDevicePath protocol" ) ;
57
+ for ( n1, n2) in device_path
58
+ . node_iter ( )
59
+ . zip ( loaded_image_device_path. node_iter ( ) )
60
+ {
61
+ assert_eq ! ( n1, n2) ;
62
+ }
51
63
}
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ use crate::proto::{unsafe_protocol, ProtocolPointer};
85
85
use core:: ffi:: c_void;
86
86
use core:: fmt:: { self , Debug , Formatter } ;
87
87
use core:: mem;
88
+ use core:: ops:: Deref ;
88
89
use ptr_meta:: Pointee ;
89
90
90
91
opaque_type ! {
@@ -610,6 +611,35 @@ pub enum NodeConversionError {
610
611
UnsupportedType ,
611
612
}
612
613
614
+ /// Protocol for accessing the device path that was passed in to [`load_image`]
615
+ /// when loading a PE/COFF image.
616
+ ///
617
+ /// The layout of this type is the same as a [`DevicePath`].
618
+ ///
619
+ /// [`load_image`]: crate::table::boot::BootServices::load_image
620
+ #[ repr( transparent) ]
621
+ #[ unsafe_protocol( "bc62157e-3e33-4fec-9920-2d3b36d750df" ) ]
622
+ #[ derive( Pointee ) ]
623
+ pub struct LoadedImageDevicePath ( DevicePath ) ;
624
+
625
+ impl ProtocolPointer for LoadedImageDevicePath {
626
+ unsafe fn ptr_from_ffi ( ptr : * const c_void ) -> * const Self {
627
+ ptr_meta:: from_raw_parts ( ptr. cast ( ) , DevicePath :: size_in_bytes_from_ptr ( ptr) )
628
+ }
629
+
630
+ unsafe fn mut_ptr_from_ffi ( ptr : * mut c_void ) -> * mut Self {
631
+ ptr_meta:: from_raw_parts_mut ( ptr. cast ( ) , DevicePath :: size_in_bytes_from_ptr ( ptr) )
632
+ }
633
+ }
634
+
635
+ impl Deref for LoadedImageDevicePath {
636
+ type Target = DevicePath ;
637
+
638
+ fn deref ( & self ) -> & DevicePath {
639
+ & self . 0
640
+ }
641
+ }
642
+
613
643
#[ cfg( test) ]
614
644
mod tests {
615
645
use super :: * ;
Original file line number Diff line number Diff line change @@ -986,10 +986,11 @@ impl BootServices {
986
986
/// image.
987
987
///
988
988
/// If the image is successfully loaded, a [`Handle`] supporting the
989
- /// [`LoadedImage`] and `LoadedImageDevicePath` protocols is
989
+ /// [`LoadedImage`] and [ `LoadedImageDevicePath`] protocols is
990
990
/// returned. The image can be started with [`start_image`] or
991
991
/// unloaded with [`unload_image`].
992
992
///
993
+ /// [`LoadedImageDevicePath`]: crate::proto::device_path::LoadedImageDevicePath
993
994
/// [`start_image`]: BootServices::start_image
994
995
/// [`unload_image`]: BootServices::unload_image
995
996
///
You can’t perform that action at this time.
0 commit comments