Skip to content

Commit a6956a7

Browse files
committed
uefi-raw: Add raw AllocateType enum
1 parent 87ab019 commit a6956a7

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

uefi-raw/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Added `UsbIoProtocol`.
1919
- Added `Usb2HostControllerProtocol`.
2020
- Added `DevicePathProtocol::length()` properly constructing the `u16` value
21+
- Added `AllocateType`.
2122

2223
## Changed
2324
- `DevicePathProtocol` now derives

uefi-raw/src/table/boot.rs

+10-1
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

+4-4
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

@@ -136,9 +136,9 @@ pub fn allocate_pages(ty: AllocateType, mem_ty: MemoryType, count: usize) -> Res
136136
let bt = unsafe { bt.as_ref() };
137137

138138
let (ty, initial_addr) = match ty {
139-
AllocateType::AnyPages => (0, 0),
140-
AllocateType::MaxAddress(addr) => (1, addr),
141-
AllocateType::Address(addr) => (2, addr),
139+
AllocateType::AnyPages => (RawAllocateType::ANY_PAGES, 0),
140+
AllocateType::MaxAddress(addr) => (RawAllocateType::MAX_ADDRESS, addr),
141+
AllocateType::Address(addr) => (RawAllocateType::ADDRESS, addr),
142142
};
143143

144144
let mut addr1 = initial_addr;

0 commit comments

Comments
 (0)