Skip to content

Commit 44a3bde

Browse files
committed
uefi-raw: Add raw AllocateType enum
1 parent 78e4342 commit 44a3bde

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

uefi-raw/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# uefi-raw - [Unreleased]
22

3+
## Added
4+
- Added `AllocateType`.
5+
36

47
# uefi-raw - 0.11.0 (2025-05-04)
58

uefi-raw/src/table/boot.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ use bitflags::bitflags;
99
use core::ffi::c_void;
1010
use core::ops::RangeInclusive;
1111

12+
newtype_enum! {
13+
pub enum AllocateType: u32 => {
14+
ANY_PAGES = 0,
15+
MAX_ADDRESS = 1,
16+
ADDRESS = 2,
17+
MAX_ALLOCATE_TYPE = 3,
18+
}
19+
}
20+
1221
/// Table of pointers to all the boot services.
1322
#[derive(Debug)]
1423
#[repr(C)]
@@ -21,7 +30,7 @@ pub struct BootServices {
2130

2231
// Memory allocation functions
2332
pub allocate_pages: unsafe extern "efiapi" fn(
24-
alloc_ty: u32,
33+
alloc_ty: AllocateType,
2534
mem_ty: MemoryType,
2635
count: usize,
2736
addr: *mut PhysicalAddress,

uefi/src/boot.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use core::ptr::{self, NonNull};
4545
use core::sync::atomic::{AtomicPtr, Ordering};
4646
use core::time::Duration;
4747
use core::{mem, slice};
48-
use uefi_raw::table::boot::{InterfaceType, TimerDelay};
48+
use uefi_raw::table::boot::{AllocateType as RawAllocateType, InterfaceType, TimerDelay};
4949
#[cfg(feature = "alloc")]
5050
use {alloc::vec::Vec, uefi::ResultExt};
5151

@@ -154,9 +154,9 @@ pub fn allocate_pages(
154154
let bt = unsafe { bt.as_ref() };
155155

156156
let (ty, initial_addr) = match allocation_type {
157-
AllocateType::AnyPages => (0, 0),
158-
AllocateType::MaxAddress(addr) => (1, addr),
159-
AllocateType::Address(addr) => (2, addr),
157+
AllocateType::AnyPages => (RawAllocateType::ANY_PAGES, 0),
158+
AllocateType::MaxAddress(addr) => (RawAllocateType::MAX_ADDRESS, addr),
159+
AllocateType::Address(addr) => (RawAllocateType::ADDRESS, addr),
160160
};
161161

162162
let mut addr1 = initial_addr;

0 commit comments

Comments
 (0)