uefi/graphics.rs
1use crate::prelude::*;
2
3#[derive(Copy, Clone, Debug)]
4#[repr(C)]
5pub struct GraphicsBltPixel {
6 pub Blue: u8,
7 pub Green: u8,
8 pub Red: u8,
9 pub Reserved: u8,
10}
11
12#[derive(Copy, Clone, Debug)]
13#[repr(C)]
14pub enum GraphicsBltOp {
15 // Write data from the first buffer pixel to every pixel of the display
16 VideoFill,
17 // Copy from the display to the buffer
18 VideoToBuffer,
19 // Copy from the buffer to the display
20 BufferToVideo,
21 // Copy from the display to the display
22 VideoToVideo,
23}
24
25#[derive(Copy, Clone, Debug)]
26#[repr(C)]
27pub enum GraphicsPixelFormat {
28 ///
29 /// A pixel is 32-bits and byte zero represents red, byte one represents green,
30 /// byte two represents blue, and byte three is reserved. This is the definition
31 /// for the physical frame buffer. The byte values for the red, green, and blue
32 /// components represent the color intensity. This color intensity value range
33 /// from a minimum intensity of 0 to maximum intensity of 255.
34 ///
35 PixelRedGreenBlueReserved8BitPerColor,
36 ///
37 /// A pixel is 32-bits and byte zero represents blue, byte one represents green,
38 /// byte two represents red, and byte three is reserved. This is the definition
39 /// for the physical frame buffer. The byte values for the red, green, and blue
40 /// components represent the color intensity. This color intensity value range
41 /// from a minimum intensity of 0 to maximum intensity of 255.
42 ///
43 PixelBlueGreenRedReserved8BitPerColor,
44 ///
45 /// The Pixel definition of the physical frame buffer.
46 ///
47 PixelBitMask,
48 ///
49 /// This mode does not support a physical frame buffer.
50 ///
51 PixelBltOnly,
52 ///
53 /// Valid EFI_GRAPHICS_PIXEL_FORMAT enum values are less than this value.
54 ///
55 PixelFormatMax,
56}
57
58#[derive(Copy, Clone, Debug)]
59#[repr(C)]
60pub struct GraphicsPixelBitmask {
61 pub RedMask: u32,
62 pub GreenMask: u32,
63 pub BlueMask: u32,
64 pub ReservedMask: u32,
65}
66
67#[derive(Copy, Clone, Debug)]
68#[repr(C)]
69pub struct GraphicsOutputModeInfo {
70 /// The version of this data structure. A value of zero represents the
71 /// EFI_GRAPHICS_OUTPUT_MODE_INFORMATION structure as defined in this specification.
72 pub Version: u32,
73 /// The size of video screen in pixels in the X dimension.
74 pub HorizontalResolution: u32,
75 /// The size of video screen in pixels in the Y dimension.
76 pub VerticalResolution: u32,
77 /// Enumeration that defines the physical format of the pixel. A value of PixelBltOnly
78 /// implies that a linear frame buffer is not available for this mode.
79 pub PixelFormat: GraphicsPixelFormat,
80 /// This bit-mask is only valid if PixelFormat is set to PixelPixelBitMask.
81 /// A bit being set defines what bits are used for what purpose such as Red, Green, Blue, or Reserved.
82 pub PixelInformation: GraphicsPixelBitmask,
83 /// Defines the number of pixel elements per video memory line.
84 pub PixelsPerScanLine: u32,
85}
86
87#[derive(Debug)]
88#[repr(C)]
89pub struct GraphicsOutputMode {
90 /// The number of modes supported by QueryMode() and SetMode().
91 pub MaxMode: u32,
92 /// Current Mode of the graphics device. Valid mode numbers are 0 to MaxMode -1.
93 pub Mode: u32,
94 /// Pointer to read-only EFI_GRAPHICS_OUTPUT_MODE_INFORMATION data.
95 pub Info: &'static GraphicsOutputModeInfo,
96 /// Size of Info structure in bytes.
97 pub SizeOfInfo: usize,
98 /// Base address of graphics linear frame buffer.
99 /// Offset zero in FrameBufferBase represents the upper left pixel of the display.
100 pub FrameBufferBase: usize,
101 /// Amount of frame buffer needed to support the active mode as defined by
102 /// PixelsPerScanLine xVerticalResolution x PixelElementSize.
103 pub FrameBufferSize: usize,
104}
105
106#[repr(C)]
107pub struct GraphicsOutput {
108 pub QueryMode: extern "efiapi" fn(
109 &mut GraphicsOutput,
110 u32,
111 &mut usize,
112 &mut *mut GraphicsOutputModeInfo,
113 ) -> Status,
114 pub SetMode: extern "efiapi" fn(&mut GraphicsOutput, u32) -> Status,
115 pub Blt: extern "efiapi" fn(
116 &mut GraphicsOutput,
117 *mut GraphicsBltPixel,
118 GraphicsBltOp,
119 usize,
120 usize,
121 usize,
122 usize,
123 usize,
124 usize,
125 usize,
126 ) -> Status,
127 pub Mode: &'static mut GraphicsOutputMode,
128}
129
130impl GraphicsOutput {
131 pub const GUID: Guid = guid!("9042a9de-23dc-4a38-96fb-7aded080516a");
132}