Struct bootloader::Config

source ·
pub struct Config {
    pub map_physical_memory: bool,
    pub physical_memory_offset: Option<u64>,
    pub map_page_table_recursively: bool,
    pub recursive_index: Option<u16>,
    pub kernel_stack_size: Option<u64>,
    pub kernel_stack_address: Option<u64>,
    pub boot_info_address: Option<u64>,
    pub map_framebuffer: bool,
    pub framebuffer_address: Option<u64>,
}
Expand description

Allows configuring the bootloader behavior.

To control these, use a [package.metadata.bootloader] table in the Cargo.toml of your kernel. The naming convention for all config fields is kebab-case, otherwise the config keys correspond to the field names of this struct (i.e. just replace _ with -). Unknown config keys lead to an error.

§Example

To map the complete physical memory starting at virtual address 0x0000_4000_0000_0000, add the following to your kernel’s Cargo.toml:

[package.metadata.bootloader]
map-physical-memory = true
physical-memory-offset = 0x0000_4000_0000_0000

§Memory Addresses

Memory addresses must be positive and page aligned. Since TOML does not support unsigned 64-bit integers, we also support string input to specify addresses larger than i64::MAX. For example:

physical-memory-offset = "0xf000_0000_0000_0000"

The above example would fail if the address was specified as integer instead (i.e. without the quotes).

All memory addresses are optional, even if their corresponding switch is enabled. If no address is specified, the bootloader will choose an unused entry of the level 4 page table at runtime.

Fields§

§map_physical_memory: bool

Whether to create a virtual mapping of the complete physical memory.

Defaults to false.

§physical_memory_offset: Option<u64>

Map the physical memory at a specified virtual address.

If not given, the bootloader searches for a free virtual address dynamically.

Only considered if map_physical_memory is true.

§map_page_table_recursively: bool

Whether to create a recursive entry in the level 4 page table.

Defaults to false.

§recursive_index: Option<u16>

Create the recursive mapping in at the given entry of the level 4 page table.

If not given, the bootloader searches for a free level 4 entry dynamically.

Only considered if map_page_table_recursively is true.

§kernel_stack_size: Option<u64>

Use the given stack size for the kernel.

Defaults to at least 80KiB if not given.

§kernel_stack_address: Option<u64>

Create the kernel stack at the given virtual address.

Looks for a free virtual memory region dynamically if not given.

§boot_info_address: Option<u64>

Create the boot information at the given virtual address.

Looks for a free virtual memory region dynamically if not given.

§map_framebuffer: bool

Whether to map the framebuffer to virtual memory.

Defaults to true.

§framebuffer_address: Option<u64>

Map the framebuffer memory at the specified virtual address.

If not given, the bootloader searches for a free virtual memory region dynamically.

Only considered if map_framebuffer is true.

Trait Implementations§

source§

impl Debug for Config

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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
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.

source§

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

§

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>,

§

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.