|
7 | 7 | //! services are not active, `alloc` will return a null pointer, and `dealloc` |
8 | 8 | //! will panic. |
9 | 9 |
|
10 | | -use core::alloc::{GlobalAlloc, Layout}; |
11 | | -use core::ptr::{self, NonNull}; |
12 | | -use core::sync::atomic::{AtomicU32, Ordering}; |
13 | | - |
14 | 10 | use crate::boot; |
15 | 11 | use crate::mem::memory_map::MemoryType; |
16 | 12 | use crate::proto::loaded_image::LoadedImage; |
| 13 | +use core::alloc::{GlobalAlloc, Layout}; |
| 14 | +use core::ptr::{self, NonNull}; |
| 15 | +use core::sync::atomic::{AtomicU32, Ordering}; |
17 | 16 |
|
18 | 17 | /// Get the memory type to use for allocation. |
19 | 18 | /// |
@@ -48,9 +47,11 @@ fn get_memory_type() -> MemoryType { |
48 | 47 | pub struct Allocator; |
49 | 48 |
|
50 | 49 | unsafe impl GlobalAlloc for Allocator { |
51 | | - /// Allocate memory using [`boot::allocate_pool`]. The allocation is |
52 | | - /// of type [`MemoryType::LOADER_DATA`] for UEFI applications, [`MemoryType::BOOT_SERVICES_DATA`] |
53 | | - /// for UEFI boot drivers and [`MemoryType::RUNTIME_SERVICES_DATA`] for UEFI runtime drivers. |
| 50 | + /// Allocate memory using [`boot::allocate_pool`]. The allocation's [memory |
| 51 | + /// type] matches the current image's [data type]. |
| 52 | + /// |
| 53 | + /// [memory type]: MemoryType |
| 54 | + /// [data type]: LoadedImage::data_type |
54 | 55 | unsafe fn alloc(&self, layout: Layout) -> *mut u8 { |
55 | 56 | if !boot::are_boot_services_active() { |
56 | 57 | return ptr::null_mut(); |
|
0 commit comments