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