Skip to main content

Type

Enum Type 

Source
#[repr(u64)]
pub enum Type {
Show 31 variants FreeRam = 1, Peripheral = 2, Reserved = 3, PoolBookkeeping = 4_294_967_296, PhysKernel = 4_294_967_297, PhysElf = 4_294_967_298, PhysLog = 4_294_967_299, Kernel = 4_294_967_300, KernelStorage = 4_294_967_301, DataZbi = 4_294_967_302, TemporaryPhysHandoff = 4_294_967_303, PermanentPhysHandoff = 4_294_967_304, Vdso = 4_294_967_305, Userboot = 4_294_967_306, BootMachineStack = 4_294_967_307, BootShadowCallStack = 4_294_967_308, BootUnsafeStack = 4_294_967_309, FixedAddressStagingKernel = 4_294_967_310, FixedAddressStagingDataZbi = 4_294_967_311, LegacyBootData = 4_294_967_312, TemporaryIdentityPageTables = 4_294_967_313, KernelPageTables = 4_294_967_314, PhysDebugdata = 4_294_967_315, DevicetreeBlob = 4_294_967_316, PhysScratch = 4_294_967_317, PoolTestPayload = 4_294_967_318, ZbiTestPayload = 4_294_967_319, TestRamReserve = 4_294_967_320, Nvram = 4_294_967_321, ReservedLow = 4_294_967_322, TruncatedRam = 4_294_967_323,
}
Expand description

A description of a physical memory range.

A few important sub-categories of the Type enum:

* Base types. These are the three types specified by the ZBI: `Type::FreeRam`,
`Type::Peripheral`, and `Type::Reserved`.

* Allocated types.  These are all of the types which are specific to Memalloc's use
case, and are not present in the ZBI spec.  For example, `Type::PoolBookkeeping`,
`Type::PhysKernel`, etc.  These types are all carved out from `Type::FreeRam`.

* Ram types.  This encompasses all of the allocated types plus `Type::FreeRam`

Type is represented by 64 bits.

The lower 2^32 values in the space are reserved for the base types; the upper values are allocated types.

The C++ definition of this enum serves as the source of truth for all of the discriminant values. We enforce this in Rust indirectly by assigning the variants of the enum to the C++ values, with bindgen. The [define_type_enum!] macro makes this assignment automatic.

Variants§

§

FreeRam = 1

§

Peripheral = 2

§

Reserved = 3

§

PoolBookkeeping = 4_294_967_296

Reserved for internal bookkeeping.

§

PhysKernel = 4_294_967_297

The phys ZBI kernel memory image.

§

PhysElf = 4_294_967_298

A phys ELF memory image.

§

PhysLog = 4_294_967_299

A phys log file.

§

Kernel = 4_294_967_300

The kernel memory image.

§

KernelStorage = 4_294_967_301

A (decompressed) STORAGE_KERNEL ZBI payload.

§

DataZbi = 4_294_967_302

The data ZBI, as placed by the bootloader.

§

TemporaryPhysHandoff = 4_294_967_303

Memory intended to remain allocated until the end of the phys hand-off phase.

§

PermanentPhysHandoff = 4_294_967_304

Memory intended to remain allocated for the lifetime of the kernel.

§

Vdso = 4_294_967_305

A vDSO memory image.

§

Userboot = 4_294_967_306

A userboot memory image.

§

BootMachineStack = 4_294_967_307

The kernel’s boot machine stack.

§

BootShadowCallStack = 4_294_967_308

The kernel’s boot shadow call stack, if supported.

§

BootUnsafeStack = 4_294_967_309

The kernel’s boot unsafe stack, if safe stack is supported.

§

FixedAddressStagingKernel = 4_294_967_310

The intermediate kernel memory image used to trampoline into the same image loaded at a fixed address (i.e., as used by FixedAddressBootZbi).

§

FixedAddressStagingDataZbi = 4_294_967_311

The intermediate data ZBI used to trampoline into the same image loaded at a fixed address (i.e., as used by FixedAddressBootZbi).

§

LegacyBootData = 4_294_967_312

Data structures related to legacy boot protocols.

§

TemporaryIdentityPageTables = 4_294_967_313

Identity-mapping page tables intended only for the lifetime of the phys program in execution.

§

KernelPageTables = 4_294_967_314

Page tables that describe mappings intended to exist into the kernel’s proper lifetime.

§

PhysDebugdata = 4_294_967_315

A debug data blob of phys origin (e.g., related to instrumentation).

§

DevicetreeBlob = 4_294_967_316

A firmware-provided devicetree blob.

§

PhysScratch = 4_294_967_317

General scratch space used by the phys kernel, but that which is free for the next kernel as of hand-off.

§

PoolTestPayload = 4_294_967_318

A generic allocated type for Pool tests.

§

ZbiTestPayload = 4_294_967_319

A generic allocated type for ZBI tests.

§

TestRamReserve = 4_294_967_320

Memory carved out for the kernel.test.ram.reserve boot option.

§

Nvram = 4_294_967_321

Memory carved out for the ZBI_TYPE_NVRAM region.

§

ReservedLow = 4_294_967_322

Low memory, in an architecture-specific context, that is deemed to be unsafe for general-purpose allocation and use (e.g., BIOS-related bits below 1MiB in the case of PCs).

§

TruncatedRam = 4_294_967_323

RAM ‘discarded’ from a truncation of the physical address space when simulating booting contexts with less physical memory available.

Implementations§

Source§

impl Type

Source

pub const MIN_ALLOCATED_VALUE: u64 = bindings::memalloc_kMinAllocatedTypeValue

Memalloc reserves the discriminant values above 2^32 to enumerate its own types.

Source

pub const fn as_str(&self) -> &'static str

Convert a Type to a string slice.

Source

pub const fn is_allocated(&self) -> bool

Determine if a Type is an allocated type.

Source

pub const fn is_ram(&self) -> bool

Determine if a Type is a ram type.

Trait Implementations§

Source§

impl Clone for Type

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable)§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Type

Source§

impl Debug for Type

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Type

Source§

impl PartialEq for Type

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable)§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Type

Auto Trait Implementations§

§

impl Freeze for Type

§

impl RefUnwindSafe for Type

§

impl Send for Type

§

impl Sync for Type

§

impl Unpin for Type

§

impl UnsafeUnpin for Type

§

impl UnwindSafe for Type

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToMutPtr for T
where T: ?Sized,

Source§

type Target = T

The target type of the pointer.
Source§

fn to_mut_ptr(&self) -> *mut T

Casts the reference to a mutable raw pointer.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.