1use crate::{
2 sdt::{SdtHeader, Signature},
3 AcpiTable,
4};
5use bit_field::BitField;
6
7#[repr(C, packed)]
10#[derive(Debug, Clone, Copy)]
11pub struct Bgrt {
12 header: SdtHeader,
13 pub version: u16,
14 status: u8,
15 image_type: u8,
16 pub image_address: u64,
17 image_offset_x: u32,
18 image_offset_y: u32,
19}
20
21unsafe impl AcpiTable for Bgrt {
23 const SIGNATURE: Signature = Signature::BGRT;
24
25 fn header(&self) -> &SdtHeader {
26 &self.header
27 }
28}
29
30impl Bgrt {
31 pub fn image_type(&self) -> ImageType {
32 let img_type = self.image_type;
33 match img_type {
34 0 => ImageType::Bitmap,
35 _ => ImageType::Reserved,
36 }
37 }
38
39 pub fn orientation_offset(&self) -> u16 {
42 let status = self.status;
43 match status.get_bits(1..3) {
44 0 => 0,
45 1 => 90,
46 2 => 180,
47 3 => 270,
48 _ => unreachable!(), }
50 }
51
52 pub fn was_displayed(&self) -> bool {
53 let status = self.status;
54 status.get_bit(0)
55 }
56
57 pub fn image_offset(&self) -> (u32, u32) {
58 let x = self.image_offset_x;
59 let y = self.image_offset_y;
60 (x, y)
61 }
62}
63
64#[repr(u8)]
65#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
66pub enum ImageType {
67 Bitmap,
68 Reserved,
69}