|
12 | 12 | //! Failure to do so will turn subsequent allocation into undefined behaviour.
|
13 | 13 |
|
14 | 14 | use core::alloc::{GlobalAlloc, Layout};
|
15 |
| -use core::ffi::c_void; |
16 | 15 | use core::ptr::{self, NonNull};
|
17 |
| -use core::sync::atomic::{AtomicPtr, AtomicU32, Ordering}; |
| 16 | +use core::sync::atomic::{AtomicU32, Ordering}; |
18 | 17 |
|
19 | 18 | use crate::boot;
|
20 | 19 | use crate::mem::memory_map::MemoryType;
|
21 | 20 | use crate::proto::loaded_image::LoadedImage;
|
22 | 21 | use crate::table::{Boot, SystemTable};
|
23 | 22 |
|
24 |
| -/// Reference to the system table, used to call the boot services pool memory |
25 |
| -/// allocation functions. |
26 |
| -/// |
27 |
| -/// The pointer is only safe to dereference if UEFI boot services have not been |
28 |
| -/// exited by the host application yet. |
29 |
| -static SYSTEM_TABLE: AtomicPtr<c_void> = AtomicPtr::new(ptr::null_mut()); |
30 |
| - |
31 |
| -/// The memory type used for pool memory allocations. |
32 |
| -static MEMORY_TYPE: AtomicU32 = AtomicU32::new(MemoryType::LOADER_DATA.0); |
33 |
| - |
34 | 23 | /// Initializes the allocator.
|
35 | 24 | ///
|
36 | 25 | /// # Safety
|
37 | 26 | ///
|
38 | 27 | /// This function is unsafe because you _must_ make sure that exit_boot_services
|
39 | 28 | /// will be called when UEFI boot services will be exited.
|
40 |
| -pub unsafe fn init(system_table: &mut SystemTable<Boot>) { |
41 |
| - SYSTEM_TABLE.store(system_table.as_ptr().cast_mut(), Ordering::Release); |
42 |
| - |
43 |
| - let boot_services = system_table.boot_services(); |
44 |
| - if let Ok(loaded_image) = |
45 |
| - boot::open_protocol_exclusive::<LoadedImage>(boot_services.image_handle()) |
46 |
| - { |
47 |
| - MEMORY_TYPE.store(loaded_image.data_type().0, Ordering::Release); |
48 |
| - } |
49 |
| -} |
| 29 | +#[allow(unused_unsafe)] |
| 30 | +pub unsafe fn init(_: &mut SystemTable<Boot>) {} |
50 | 31 |
|
51 | 32 | /// Notify the allocator library that boot services are not safe to call anymore
|
52 | 33 | ///
|
53 | 34 | /// You must arrange for this function to be called on exit from UEFI boot services
|
54 |
| -pub fn exit_boot_services() { |
55 |
| - SYSTEM_TABLE.store(ptr::null_mut(), Ordering::Release); |
56 |
| -} |
| 35 | +#[allow(clippy::missing_const_for_fn)] |
| 36 | +pub fn exit_boot_services() {} |
57 | 37 |
|
58 | 38 | /// Get the memory type to use for allocation.
|
59 | 39 | ///
|
|
0 commit comments