1 use crate::{ 2 sdt::{SdtHeader, Signature}, 3 AcpiTable, 4 }; 5 use bit_field::BitField; 6 7 /// The BGRT table contains information about a boot graphic that was displayed 8 /// by firmware. 9 #[repr(C, packed)] 10 #[derive(Debug, Clone, Copy)] 11 pub 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 21 /// ### Safety: Implementation properly represents a valid BGRT. 22 unsafe impl AcpiTable for Bgrt { 23 const SIGNATURE: Signature = Signature::BGRT; 24 header(&self) -> &SdtHeader25 fn header(&self) -> &SdtHeader { 26 &self.header 27 } 28 } 29 30 impl Bgrt { image_type(&self) -> ImageType31 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 /// Gets the orientation offset of the image. 40 /// Degrees are clockwise from the images default orientation. orientation_offset(&self) -> u1641 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!(), // will never happen 49 } 50 } 51 was_displayed(&self) -> bool52 pub fn was_displayed(&self) -> bool { 53 let status = self.status; 54 status.get_bit(0) 55 } 56 image_offset(&self) -> (u32, u32)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)] 66 pub enum ImageType { 67 Bitmap, 68 Reserved, 69 } 70