strat9_kernel/acpi/
bgrt.rs1use super::sdt::Sdt;
9use zerocopy::FromBytes;
10
11pub const BGRT_SIGNATURE: &[u8; 4] = b"BGRT";
12
13pub const BGRT_STATUS_DISPLAYED: u8 = 1;
15
16pub const BGRT_FORMAT_BMP: u16 = 0;
18
19#[derive(Clone, Copy, Debug, FromBytes)]
21#[repr(C, packed)]
22pub struct Bgrt {
23 pub header: Sdt,
24 pub version: u16,
25 pub status: u8,
26 pub image_type: u8,
27 pub image_base: u64,
28 pub image_offset_x: u32,
29 pub image_offset_y: u32,
30}
31
32impl Bgrt {
33 pub fn get() -> Option<&'static Bgrt> {
35 unsafe { super::find_table(BGRT_SIGNATURE).map(|ptr| &*(ptr as *const Bgrt)) }
36 }
37
38 pub fn was_displayed(&self) -> bool {
40 (self.status & BGRT_STATUS_DISPLAYED) != 0
41 }
42
43 pub fn image_format(&self) -> u16 {
45 self.image_type.into()
46 }
47
48 pub fn image_base(&self) -> u64 {
50 self.image_base
51 }
52
53 pub fn image_offset_x(&self) -> u32 {
55 self.image_offset_x
56 }
57
58 pub fn image_offset_y(&self) -> u32 {
60 self.image_offset_y
61 }
62}