|
2 | 2 | //! |
3 | 3 | //! These functions will panic if called after exiting boot services. |
4 | 4 |
|
| 5 | +pub use crate::table::boot::{ |
| 6 | + AllocateType, EventNotifyFn, LoadImageSource, OpenProtocolAttributes, OpenProtocolParams, |
| 7 | + ProtocolSearchKey, SearchType, TimerTrigger, |
| 8 | +}; |
| 9 | +pub use uefi_raw::table::boot::{EventType, MemoryAttribute, MemoryDescriptor, MemoryType, Tpl}; |
| 10 | + |
5 | 11 | use crate::data_types::PhysicalAddress; |
6 | 12 | use crate::mem::memory_map::{MemoryMapBackingMemory, MemoryMapKey, MemoryMapMeta, MemoryMapOwned}; |
7 | 13 | use crate::polyfill::maybe_uninit_slice_assume_init_ref; |
8 | 14 | use crate::proto::device_path::DevicePath; |
| 15 | +#[cfg(doc)] |
| 16 | +use crate::proto::device_path::LoadedImageDevicePath; |
9 | 17 | use crate::proto::loaded_image::LoadedImage; |
10 | 18 | use crate::proto::media::fs::SimpleFileSystem; |
11 | 19 | use crate::proto::{Protocol, ProtocolPointer}; |
12 | 20 | use crate::runtime::{self, ResetType}; |
13 | 21 | use crate::table::Revision; |
14 | 22 | use crate::util::opt_nonnull_to_ptr; |
| 23 | +use crate::{table, Char16, Error, Event, Guid, Handle, Result, Status, StatusExt}; |
15 | 24 | use core::ffi::c_void; |
16 | 25 | use core::mem::MaybeUninit; |
17 | 26 | use core::ops::{Deref, DerefMut}; |
18 | 27 | use core::ptr::{self, NonNull}; |
19 | 28 | use core::sync::atomic::{AtomicPtr, Ordering}; |
20 | 29 | use core::{mem, slice}; |
21 | | -use uefi::{table, Char16, Error, Event, Guid, Handle, Result, Status, StatusExt}; |
22 | 30 | use uefi_raw::table::boot::InterfaceType; |
23 | | - |
24 | 31 | #[cfg(feature = "alloc")] |
25 | 32 | use {alloc::vec::Vec, uefi::ResultExt}; |
26 | 33 |
|
27 | | -#[cfg(doc)] |
28 | | -use crate::proto::device_path::LoadedImageDevicePath; |
29 | | - |
30 | | -pub use uefi::table::boot::{ |
31 | | - AllocateType, EventNotifyFn, LoadImageSource, OpenProtocolAttributes, OpenProtocolParams, |
32 | | - ProtocolSearchKey, SearchType, TimerTrigger, |
33 | | -}; |
34 | | -pub use uefi_raw::table::boot::{EventType, MemoryAttribute, MemoryDescriptor, MemoryType, Tpl}; |
35 | | - |
36 | 34 | /// Global image handle. This is only set by [`set_image_handle`], and it is |
37 | 35 | /// only read by [`image_handle`]. |
38 | 36 | static IMAGE_HANDLE: AtomicPtr<c_void> = AtomicPtr::new(ptr::null_mut()); |
@@ -995,34 +993,12 @@ pub fn load_image(parent_image_handle: Handle, source: LoadImageSource) -> Resul |
995 | 993 | let bt = boot_services_raw_panicking(); |
996 | 994 | let bt = unsafe { bt.as_ref() }; |
997 | 995 |
|
998 | | - let boot_policy; |
999 | | - let device_path; |
1000 | | - let source_buffer; |
1001 | | - let source_size; |
1002 | | - match source { |
1003 | | - LoadImageSource::FromBuffer { buffer, file_path } => { |
1004 | | - // Boot policy is ignored when loading from source buffer. |
1005 | | - boot_policy = 0; |
1006 | | - |
1007 | | - device_path = file_path.map(|p| p.as_ffi_ptr()).unwrap_or(ptr::null()); |
1008 | | - source_buffer = buffer.as_ptr(); |
1009 | | - source_size = buffer.len(); |
1010 | | - } |
1011 | | - LoadImageSource::FromDevicePath { |
1012 | | - device_path: file_path, |
1013 | | - from_boot_manager, |
1014 | | - } => { |
1015 | | - boot_policy = u8::from(from_boot_manager); |
1016 | | - device_path = file_path.as_ffi_ptr(); |
1017 | | - source_buffer = ptr::null(); |
1018 | | - source_size = 0; |
1019 | | - } |
1020 | | - }; |
| 996 | + let (boot_policy, device_path, source_buffer, source_size) = source.to_ffi_params(); |
1021 | 997 |
|
1022 | 998 | let mut image_handle = ptr::null_mut(); |
1023 | 999 | unsafe { |
1024 | 1000 | (bt.load_image)( |
1025 | | - boot_policy, |
| 1001 | + boot_policy.into(), |
1026 | 1002 | parent_image_handle.as_ptr(), |
1027 | 1003 | device_path.cast(), |
1028 | 1004 | source_buffer, |
|
0 commit comments