Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Bootinfo

The bootinfo structure is stored at a fixed address, which is passed to the init task via the first parameter using the system ABI. This structure describes the boot environment, resources available to the user, and the allocation of capabilities required to bootstrap the init task, as well as other architecture-specific information.

// Information passed to the init task about the boot environment.
export type bootinfo = struct {
	argv: str,

	// Capability ranges
	// Page capabilities for the bootinfo structure
	bootinfo: cap_range,
	// Memory capabilities
	memory: cap_range,
	// DeviceMemory capabilities
	devmem: cap_range,
	// Page capabilities for the user image
	userimage: cap_range,
	// Page capabilities for the user stack
	stack: cap_range,
	// Unallocated (Null) capabilities
	unused: cap_range,

	// Description of the Memory capabilities in the memory cap_range, in order
	memory_info: []memory_desc,
	// Description of the DeviceMemory capabilities in the devmem cap_range, in
	// order
	devmem_info: []memory_desc,
	// Information about the installed CPUs
	cpu_info: []cpu_desc,

	// Arch-specific details
	arch_bootinfo,
};

// Indicates a range of capabilities.
export type cap_range = struct {
	// Inclusive
	start: u32,
	// Exclusive
	end: u32,
};

// A description of a region of memory.
export type memory_desc = struct {
	phys: uintptr,
	pages: uint,
};

x86_64 bootinfo

// x86_64-specific boot information
export type arch_bootinfo = struct {
	// Page table capabilities used to load the user image
	pdpt: cap_range,
	pd: cap_range,
	pt: cap_range,

	// TSC rate in Hz
	tsc_rate: u64,

	// Framebuffer provisioned by bootloader, if applicable
	fb: bootfb,
};

// Details about a CPU core installed on the system.
export type cpu_desc = struct {
	id: u32,
};

// Framebuffer provided by bootloader.
export type bootfb = struct {
	// fb_base is set to zero if no framebuffer was prepared by the bootloader
	fb_base: uintptr,
	fb_size: size,
	fmt: pixel_format,
	width: u32,
	height: u32,
	stride: u32,
};

// Framebuffer pixel format.
export type pixel_format = enum uint {
	RGBX8,
	BGRX8,
};