|
1 | 1 | // SPDX-License-Identifier: MIT OR Apache-2.0
|
2 | 2 |
|
3 | | -//! This module implements Rust's global allocator interface using UEFI's memory allocation functions. |
| 3 | +//! This module exports [`Allocator`]. |
4 | 4 | //!
|
5 | | -//! If the `global_allocator` feature is enabled, the [`Allocator`] will be used |
6 | | -//! as the global Rust allocator. |
| 5 | +//! The allocator can be used as global Rust allocator using the |
| 6 | +//! `global_allocator` crate feature. See [`helpers`] for more info. |
7 | 7 | //!
|
8 | | -//! This allocator can only be used while boot services are active. If boot |
9 | | -//! services are not active, `alloc` will return a null pointer, and `dealloc` |
10 | | -//! will panic. |
| 8 | +//! [`helpers`]: uefi::helpers |
11 | 9 |
|
12 | 10 | use crate::boot;
|
13 | 11 | use crate::mem::memory_map::MemoryType;
|
@@ -42,9 +40,13 @@ fn get_memory_type() -> MemoryType {
|
42 | 40 | }
|
43 | 41 | }
|
44 | 42 |
|
45 | | -/// Allocator which uses the UEFI pool allocation functions. |
| 43 | +/// Allocator using UEFI boot services. |
46 | 44 | ///
|
47 | | -/// Only valid for as long as the UEFI boot services are available. |
| 45 | +/// This type implements [`GlobalAlloc`] and can be marked with the |
| 46 | +/// `#[global_allocator]` attribute to be used as global Rust allocator. |
| 47 | +/// |
| 48 | +/// Note that if boot services are not active (anymore), [`Allocator::alloc`] |
| 49 | +/// will return a null pointer and [`Allocator::dealloc`] will panic. |
48 | 50 | #[derive(Debug)]
|
49 | 51 | pub struct Allocator;
|
50 | 52 |
|
|
0 commit comments