1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- use crate::{HeaderTagFlag, HeaderTagType};
- use core::mem::size_of;
- /// Specifies the preferred graphics mode. If this tag
- /// is present the bootloader assumes that the payload
- /// has framebuffer support. Note: This is only a
- /// recommended mode. Only relevant on legacy BIOS.
- #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
- #[repr(C)]
- pub struct FramebufferHeaderTag {
- typ: HeaderTagType,
- flags: HeaderTagFlag,
- size: u32,
- width: u32,
- height: u32,
- depth: u32,
- }
- impl FramebufferHeaderTag {
- pub const fn new(flags: HeaderTagFlag, width: u32, height: u32, depth: u32) -> Self {
- FramebufferHeaderTag {
- typ: HeaderTagType::Framebuffer,
- flags,
- size: size_of::<Self>() as u32,
- width,
- height,
- depth,
- }
- }
- pub const fn typ(&self) -> HeaderTagType {
- self.typ
- }
- pub const fn flags(&self) -> HeaderTagFlag {
- self.flags
- }
- pub const fn size(&self) -> u32 {
- self.size
- }
- pub const fn width(&self) -> u32 {
- self.width
- }
- pub const fn height(&self) -> u32 {
- self.height
- }
- pub const fn depth(&self) -> u32 {
- self.depth
- }
- }
- #[cfg(test)]
- mod tests {
- use crate::FramebufferHeaderTag;
- #[test]
- fn test_assert_size() {
- assert_eq!(
- core::mem::size_of::<FramebufferHeaderTag>(),
- 2 + 2 + 4 + 4 + 4 + 4
- );
- }
- }
|