Skip to content

Commit 0212d43

Browse files
authored
Merge pull request #1253 from nicholasbishop/bishop-memtype-constants
uefi-raw: Add more MemoryType constants
2 parents f92576d + 290780d commit 0212d43

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

uefi-raw/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# uefi-raw - [Unreleased]
22

3+
## Added
4+
- New `MemoryType` constants: `UNACCEPTED`, `MAX`, `RESERVED_FOR_OEM`, and
5+
`RESERVED_FOR_OS_LOADER`.
6+
37

48
# uefi-raw - 0.6.0 (2024-07-02)
59

uefi-raw/src/table/boot.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::table::Header;
55
use crate::{Char16, Event, Guid, Handle, PhysicalAddress, Status, VirtualAddress};
66
use bitflags::bitflags;
77
use core::ffi::c_void;
8+
use core::ops::RangeInclusive;
89

910
/// Table of pointers to all the boot services.
1011
#[derive(Debug)]
@@ -381,11 +382,11 @@ newtype_enum! {
381382
/// The type of a memory range.
382383
///
383384
/// UEFI allows firmwares and operating systems to introduce new memory types
384-
/// in the 0x70000000..0xFFFFFFFF range. Therefore, we don't know the full set
385+
/// in the `0x7000_0000..=0xFFFF_FFFF` range. Therefore, we don't know the full set
385386
/// of memory types at compile time, and it is _not_ safe to model this C enum
386387
/// as a Rust enum.
387388
pub enum MemoryType: u32 => {
388-
/// This enum variant is not used.
389+
/// Not usable.
389390
RESERVED = 0,
390391
/// The code portions of a loaded UEFI application.
391392
LOADER_CODE = 1,
@@ -421,10 +422,21 @@ pub enum MemoryType: u32 => {
421422
PAL_CODE = 13,
422423
/// Memory region which is usable and is also non-volatile.
423424
PERSISTENT_MEMORY = 14,
425+
/// Memory that must be accepted by the boot target before it can be used.
426+
UNACCEPTED = 15,
427+
/// End of the defined memory types. Higher values are possible though, see
428+
/// [`MemoryType::RESERVED_FOR_OEM`] and [`MemoryType::RESERVED_FOR_OS_LOADER`].
429+
MAX = 16,
424430
}}
425431

426432
impl MemoryType {
427-
/// Construct a custom `MemoryType`. Values in the range `0x80000000..=0xffffffff` are free for use if you are
433+
/// Range reserved for OEM use.
434+
pub const RESERVED_FOR_OEM: RangeInclusive<u32> = 0x7000_0000..=0x7fff_ffff;
435+
436+
/// Range reserved for OS loaders.
437+
pub const RESERVED_FOR_OS_LOADER: RangeInclusive<u32> = 0x8000_0000..=0xffff_ffff;
438+
439+
/// Construct a custom `MemoryType`. Values in the range `0x8000_0000..=0xffff_ffff` are free for use if you are
428440
/// an OS loader.
429441
#[must_use]
430442
pub const fn custom(value: u32) -> MemoryType {

0 commit comments

Comments
 (0)