|
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 | + SearchType, TimerTrigger, |
| 8 | +}; |
| 9 | +pub use uefi_raw::table::boot::{EventType, MemoryType, Tpl}; |
| 10 | + |
5 | 11 | use crate::data_types::PhysicalAddress; |
6 | 12 | use crate::proto::device_path::DevicePath; |
7 | 13 | use crate::proto::{Protocol, ProtocolPointer}; |
8 | 14 | use crate::util::opt_nonnull_to_ptr; |
| 15 | +use crate::{table, Char16, Error, Event, Guid, Handle, Result, Status, StatusExt}; |
9 | 16 | use core::ffi::c_void; |
10 | 17 | use core::ops::{Deref, DerefMut}; |
11 | 18 | use core::ptr::{self, NonNull}; |
12 | 19 | use core::sync::atomic::{AtomicPtr, Ordering}; |
13 | 20 | use core::{mem, slice}; |
14 | | -use uefi::{table, Char16, Error, Event, Guid, Handle, Result, Status, StatusExt}; |
15 | 21 | use uefi_raw::table::boot::InterfaceType; |
16 | | - |
17 | | -use crate::proto::BootPolicy; |
18 | | -pub use crate::table::boot::{ |
19 | | - AllocateType, EventNotifyFn, LoadImageSource, OpenProtocolAttributes, OpenProtocolParams, |
20 | | - SearchType, TimerTrigger, |
21 | | -}; |
22 | | -pub use uefi_raw::table::boot::{EventType, MemoryType, Tpl}; |
23 | 22 | #[cfg(doc)] |
24 | 23 | use { |
25 | 24 | crate::proto::device_path::LoadedImageDevicePath, crate::proto::loaded_image::LoadedImage, |
@@ -674,29 +673,7 @@ pub fn load_image(parent_image_handle: Handle, source: LoadImageSource) -> Resul |
674 | 673 | let bt = boot_services_raw_panicking(); |
675 | 674 | let bt = unsafe { bt.as_ref() }; |
676 | 675 |
|
677 | | - let boot_policy; |
678 | | - let device_path; |
679 | | - let source_buffer; |
680 | | - let source_size; |
681 | | - match source { |
682 | | - LoadImageSource::FromBuffer { buffer, file_path } => { |
683 | | - // Boot policy is ignored when loading from source buffer. |
684 | | - boot_policy = BootPolicy::FALSE; |
685 | | - |
686 | | - device_path = file_path.map(|p| p.as_ffi_ptr()).unwrap_or(ptr::null()); |
687 | | - source_buffer = buffer.as_ptr(); |
688 | | - source_size = buffer.len(); |
689 | | - } |
690 | | - LoadImageSource::FromDevicePath { |
691 | | - device_path: file_path, |
692 | | - bool_policy, |
693 | | - } => { |
694 | | - boot_policy = bool_policy; |
695 | | - device_path = file_path.as_ffi_ptr(); |
696 | | - source_buffer = ptr::null(); |
697 | | - source_size = 0; |
698 | | - } |
699 | | - }; |
| 676 | + let (boot_policy, device_path, source_buffer, source_size) = source.to_ffi_params(); |
700 | 677 |
|
701 | 678 | let mut image_handle = ptr::null_mut(); |
702 | 679 | unsafe { |
|
0 commit comments