bootloader_x86_64_bios_common/
lib.rs

1#![no_std]
2
3pub mod racy_cell;
4
5#[cfg_attr(feature = "debug", derive(Debug))]
6#[repr(C)]
7pub struct BiosInfo {
8    pub stage_4: Region,
9    pub kernel: Region,
10    pub ramdisk: Region,
11    pub config_file: Region,
12    pub last_used_addr: u64,
13    pub framebuffer: BiosFramebufferInfo,
14    pub memory_map_addr: u32,
15    pub memory_map_len: u16,
16}
17
18#[cfg_attr(feature = "debug", derive(Debug))]
19#[derive(Clone, Copy)]
20#[repr(C)]
21pub struct BiosFramebufferInfo {
22    pub region: Region,
23    pub width: u16,
24    pub height: u16,
25    pub bytes_per_pixel: u8,
26    pub stride: u16,
27    pub pixel_format: PixelFormat,
28}
29
30#[cfg_attr(feature = "debug", derive(Debug))]
31#[derive(Clone, Copy)]
32#[repr(C)]
33pub struct Region {
34    pub start: u64,
35    pub len: u64,
36}
37
38#[cfg_attr(feature = "debug", derive(Debug))]
39#[derive(Clone, Copy)]
40#[repr(C)]
41pub enum PixelFormat {
42    Rgb,
43    Bgr,
44    Unknown {
45        red_position: u8,
46        green_position: u8,
47        blue_position: u8,
48    },
49}
50
51impl PixelFormat {
52    pub fn is_unknown(&self) -> bool {
53        match self {
54            PixelFormat::Rgb | PixelFormat::Bgr => false,
55            PixelFormat::Unknown { .. } => true,
56        }
57    }
58}
59
60#[derive(Debug, Clone, Copy, PartialEq, Eq)]
61#[repr(C)]
62pub struct E820MemoryRegion {
63    pub start_addr: u64,
64    pub len: u64,
65    pub region_type: u32,
66    pub acpi_extended_attributes: u32,
67}
68
69pub fn hlt() {
70    unsafe { core::arch::asm!("hlt") };
71}