Skip to main content

KernelArgs

Struct KernelArgs 

Source
#[repr(C, packed(1))]
pub struct KernelArgs {
Show 25 fields pub magic: u32, pub abi_version: u32, pub kernel_base: u64, pub kernel_size: u64, pub acpi_rsdp_base: u64, pub memory_map_base: u64, pub memory_map_size: u64, pub framebuffer_addr: u64, pub hhdm_offset: u64, pub cmdline_ptr: u64, pub cmdline_len: u64, pub modules_base: u64, pub modules_size: u64, pub framebuffer_width: u32, pub framebuffer_height: u32, pub framebuffer_stride: u32, pub framebuffer_bpp: u16, pub framebuffer_red_mask_size: u8, pub framebuffer_red_mask_shift: u8, pub framebuffer_green_mask_size: u8, pub framebuffer_green_mask_shift: u8, pub framebuffer_blue_mask_size: u8, pub framebuffer_blue_mask_shift: u8, pub bss_virt_base: u64, pub bss_virt_size: u64,
}
Expand description

Bootloader-to-kernel handoff structure (ABI v2, 136 bytes).

Field layout is ordered to avoid internal padding:

  • u64 fields first (8-byte aligned)
  • u32 fields next
  • u16 field
  • u8 fields last

§Field groups

§Identity (8 bytes)

§Kernel memory (16 bytes)

  • kernel_base: physical address of the kernel ELF image
  • kernel_size: size of the kernel image in bytes

§ACPI (8 bytes)

  • acpi_rsdp_base: physical address of the RSDP

§Memory map (16 bytes)

  • memory_map_base: physical address of the MemoryRegion array
  • memory_map_size: total size of the memory map in bytes

§Framebuffer (8 bytes + masks)

  • framebuffer_addr: virtual address (0xFFFF_DEAD_0000_0000)

§HHDM (8 bytes)

  • hhdm_offset: Higher Half Direct Map offset

§Environment (16 bytes)

  • cmdline_ptr: physical address of key=value string
  • cmdline_len: length of the string in bytes

§Modules (16 bytes)

  • modules_base: physical address of the ModuleTable
  • modules_size: total size of the module table in bytes

Fields§

§magic: u32§abi_version: u32§kernel_base: u64§kernel_size: u64§acpi_rsdp_base: u64§memory_map_base: u64§memory_map_size: u64§framebuffer_addr: u64§hhdm_offset: u64§cmdline_ptr: u64§cmdline_len: u64§modules_base: u64§modules_size: u64§framebuffer_width: u32§framebuffer_height: u32§framebuffer_stride: u32§framebuffer_bpp: u16§framebuffer_red_mask_size: u8§framebuffer_red_mask_shift: u8§framebuffer_green_mask_size: u8§framebuffer_green_mask_shift: u8§framebuffer_blue_mask_size: u8§framebuffer_blue_mask_shift: u8§bss_virt_base: u64§bss_virt_size: u64

Implementations§

Source§

impl KernelArgs

Source

pub unsafe fn memory_regions(&self) -> Result<&[MemoryRegion], &'static str>

Read the memory map, rejecting malformed lengths instead of truncating.

§Safety

Any range that passes the numeric checks must be readable through the current identity mapping, initialized and immutable for the returned slice’s lifetime. These checks cannot establish physical memory ownership.

Source

pub fn cmdline_bytes(&self) -> &[u8]

Environment string as bytes (null-terminated key=value pairs).

Source

pub fn cmdline_str(&self) -> &str

Environment string as &str (without null terminator).

Source

pub fn env_get(&self, key: &str) -> Option<&str>

Get the value of an environment variable by key.

§Example
ⓘ
if let Some(baud) = args.env_get("console.baud") {
    // baud = "115200"
}
Source

pub unsafe fn modules(&self) -> Result<&[ModuleEntry], &'static str>

Read the fixed-capacity module table after checking its advertised extent.

§Safety

If the numeric extent checks succeed, the first MODULE_TABLE_SIZE bytes must be readable through the current identity mapping, initialized and immutable for the returned slice’s lifetime. Module payloads are not read.

Trait Implementations§

Source§

impl Debug for KernelArgs

Source§

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

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

impl FromBytes for KernelArgs
where u32: FromBytes, u64: FromBytes, u16: FromBytes, u8: FromBytes,

§

fn read_from_bytes(source: &[u8]) -> Result<Self, SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the given source. Read more
§

fn read_from_prefix( source: &[u8], ) -> Result<(Self, &[u8]), SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the prefix of the given source. Read more
§

fn read_from_suffix( source: &[u8], ) -> Result<(&[u8], Self), SizeError<&[u8], Self>>
where Self: Sized,

Reads a copy of Self from the suffix of the given source. Read more
Source§

impl FromZeros for KernelArgs
where u32: FromZeros, u64: FromZeros, u16: FromZeros, u8: FromZeros,

§

fn zero(&mut self)

Overwrites self with zeros. Read more
§

fn new_zeroed() -> Self
where Self: Sized,

Creates an instance of Self from zeroed bytes. Read more
Source§

impl IntoBytes for KernelArgs
where u32: IntoBytes, u64: IntoBytes, u16: IntoBytes, u8: IntoBytes,

§

fn as_mut_bytes(&mut self) -> &mut [u8] ⓘ
where Self: FromBytes,

Gets the bytes of this value mutably. Read more
Source§

impl TryFromBytes for KernelArgs
where u32: TryFromBytes, u64: TryFromBytes, u16: TryFromBytes, u8: TryFromBytes,

§

fn try_read_from_bytes( source: &[u8], ) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read the given source as a Self. Read more
§

fn try_read_from_prefix( source: &[u8], ) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read a Self from the prefix of the given source. Read more
§

fn try_read_from_suffix( source: &[u8], ) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: Sized,

Attempts to read a Self from the suffix of the given source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.