@@ -5,7 +5,7 @@ use void::{NotYetDef, CVoid};
5
5
use base:: { Event , Handle , Handles , MemoryType , Status } ;
6
6
use event:: { EventType , EventNotify , TimerDelay } ;
7
7
use task:: TPL ;
8
- use protocol:: Protocol ;
8
+ use protocol:: { DevicePathProtocol , Protocol } ;
9
9
use guid;
10
10
use table;
11
11
@@ -43,8 +43,8 @@ pub struct BootServices {
43
43
locate_handle : * const NotYetDef ,
44
44
locate_device_path : * const NotYetDef ,
45
45
install_configuration_table : * const NotYetDef ,
46
- load_image : * const NotYetDef ,
47
- start_image : * const NotYetDef ,
46
+ load_image : unsafe extern "win64" fn ( boot_policy : u8 , parent_image_handle : Handle , device_path : * const DevicePathProtocol , source_buffer : * const CVoid , source_size : usize , image_handle : * mut Handle ) -> Status ,
47
+ start_image : unsafe extern "win64" fn ( image_handle : Handle , exit_data_size : * mut usize , exit_data : * mut * const u16 ) -> Status ,
48
48
exit : * const NotYetDef ,
49
49
unload_image : * const NotYetDef ,
50
50
exit_boot_services : * const NotYetDef ,
@@ -148,6 +148,46 @@ impl BootServices {
148
148
return Ok ( Handles :: new ( handles as * mut Handle , nhandles) ) ;
149
149
}
150
150
151
+ /// Load an image by device path and return its handle.
152
+ pub fn load_image ( & self , boot_policy : bool , parent_image_handle : Handle , device_path : * const DevicePathProtocol ) -> Result < Handle , Status > {
153
+ self . load_image_buffer ( boot_policy, parent_image_handle, device_path, 0 as * const CVoid , 0 )
154
+ }
155
+
156
+ /// Load an image already loaded into memory at source_buffer and return its handle.
157
+ pub fn load_image_buffer ( & self , boot_policy : bool , parent_image_handle : Handle , device_path : * const DevicePathProtocol , source_buffer : * const CVoid , source_size : usize ) -> Result < Handle , Status > {
158
+ let mut handle: Handle = Default :: default ( ) ;
159
+
160
+ let result = unsafe { ( self . load_image ) ( boot_policy as u8 , parent_image_handle, device_path, source_buffer, source_size, & mut handle) } ;
161
+ if result != Status :: Success {
162
+ return Err ( result) ;
163
+ }
164
+
165
+ Ok ( handle)
166
+ }
167
+
168
+ /// Start a loaded image, and return its ExitData.
169
+ pub fn start_image_with_exitdata ( & self , image_handle : Handle ) -> Result < ( * const u16 , usize ) , Status > {
170
+ let mut exit_data_ptr: * const u16 = 0 as * const u16 ;
171
+ let mut exit_data_size: usize = 0 ;
172
+
173
+ let result = unsafe { ( self . start_image ) ( image_handle, & mut exit_data_size, & mut exit_data_ptr) } ;
174
+ if result != Status :: Success {
175
+ return Err ( result) ;
176
+ }
177
+
178
+ Ok ( ( exit_data_ptr, exit_data_size) )
179
+ }
180
+
181
+ /// Start a loaded image, but ignore its ExitData.
182
+ pub fn start_image ( & self , image_handle : Handle ) -> Result < ( ) , Status > {
183
+ let result = unsafe { ( self . start_image ) ( image_handle, 0 as * mut usize , 0 as * mut * const u16 ) } ;
184
+ if result != Status :: Success {
185
+ return Err ( result) ;
186
+ }
187
+
188
+ Ok ( ( ) )
189
+ }
190
+
151
191
/// Sleep for a number of microseconds.
152
192
pub fn stall ( & self , microseconds : usize ) {
153
193
unsafe {
0 commit comments