Skip to content

Commit fc70683

Browse files
committed
uefi-raw: Add raw AllocateType enum
1 parent 5055445 commit fc70683

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+
#[repr(u32)]
13+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14+
pub enum AllocateType {
15+
AnyPages = 0,
16+
MaxAddress = 1,
17+
Address = 2,
18+
MaxAllocateType = 3,
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
@@ -44,7 +44,7 @@ use core::ops::{Deref, DerefMut};
4444
use core::ptr::{self, NonNull};
4545
use core::sync::atomic::{AtomicPtr, Ordering};
4646
use core::{mem, slice};
47-
use uefi_raw::table::boot::{InterfaceType, TimerDelay};
47+
use uefi_raw::table::boot::{AllocateType as RawAllocateType, InterfaceType, TimerDelay};
4848
#[cfg(feature = "alloc")]
4949
use {alloc::vec::Vec, uefi::ResultExt};
5050

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

137137
let (ty, initial_addr) = match ty {
138-
AllocateType::AnyPages => (0, 0),
139-
AllocateType::MaxAddress(addr) => (1, addr),
140-
AllocateType::Address(addr) => (2, addr),
138+
AllocateType::AnyPages => (RawAllocateType::AnyPages, 0),
139+
AllocateType::MaxAddress(addr) => (RawAllocateType::MaxAddress, addr),
140+
AllocateType::Address(addr) => (RawAllocateType::Address, addr),
141141
};
142142

143143
let mut addr1 = initial_addr;

0 commit comments

Comments
 (0)