1pub mod serial;
4
5use crate::{guid, Boolean, Char16, Event, Guid, PhysicalAddress, Status};
6use bitflags::bitflags;
7use core::ptr;
8
9bitflags! {
10 #[repr(transparent)]
12 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
13 pub struct AbsolutePointerModeAttributes: u32 {
14 const SUPPORTS_ALT_ACTIVE = 1;
16
17 const SUPPORTS_PRESSURE_AS_Z = 2;
20 }
21}
22
23#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
24#[repr(C)]
25pub struct AbsolutePointerMode {
26 pub absolute_min_x: u64,
27 pub absolute_min_y: u64,
28 pub absolute_min_z: u64,
29 pub absolute_max_x: u64,
30 pub absolute_max_y: u64,
31 pub absolute_max_z: u64,
32 pub attributes: AbsolutePointerModeAttributes,
33}
34
35#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
36#[repr(C)]
37pub struct AbsolutePointerState {
38 pub current_x: u64,
39 pub current_y: u64,
40 pub current_z: u64,
41 pub active_buttons: u32,
42}
43
44#[derive(Debug)]
45#[repr(C)]
46pub struct AbsolutePointerProtocol {
47 pub reset: unsafe extern "efiapi" fn(this: *mut Self, extended_verification: Boolean) -> Status,
48 pub get_state:
49 unsafe extern "efiapi" fn(this: *const Self, state: *mut AbsolutePointerState) -> Status,
50 pub wait_for_input: Event,
51 pub mode: *mut AbsolutePointerMode,
52}
53
54impl AbsolutePointerProtocol {
55 pub const GUID: Guid = guid!("8d59d32b-c655-4ae9-9b15-f25904992a43");
56}
57
58#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
59#[repr(C)]
60pub struct InputKey {
61 pub scan_code: u16,
62 pub unicode_char: Char16,
63}
64
65#[derive(Debug)]
66#[repr(C)]
67pub struct SimpleTextInputProtocol {
68 pub reset: unsafe extern "efiapi" fn(this: *mut Self, extended_verification: Boolean) -> Status,
69 pub read_key_stroke: unsafe extern "efiapi" fn(this: *mut Self, key: *mut InputKey) -> Status,
70 pub wait_for_key: Event,
71}
72
73impl SimpleTextInputProtocol {
74 pub const GUID: Guid = guid!("387477c1-69c7-11d2-8e39-00a0c969723b");
75}
76
77#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
78#[repr(C)]
79pub struct SimpleTextOutputMode {
80 pub max_mode: i32,
81 pub mode: i32,
82 pub attribute: i32,
83 pub cursor_column: i32,
84 pub cursor_row: i32,
85 pub cursor_visible: Boolean,
86}
87
88#[derive(Debug)]
89#[repr(C)]
90pub struct SimpleTextOutputProtocol {
91 pub reset: unsafe extern "efiapi" fn(this: *mut Self, extended: Boolean) -> Status,
92 pub output_string: unsafe extern "efiapi" fn(this: *mut Self, string: *const Char16) -> Status,
93 pub test_string: unsafe extern "efiapi" fn(this: *mut Self, string: *const Char16) -> Status,
94 pub query_mode: unsafe extern "efiapi" fn(
95 this: *mut Self,
96 mode: usize,
97 columns: *mut usize,
98 rows: *mut usize,
99 ) -> Status,
100 pub set_mode: unsafe extern "efiapi" fn(this: *mut Self, mode: usize) -> Status,
101 pub set_attribute: unsafe extern "efiapi" fn(this: *mut Self, attribute: usize) -> Status,
102 pub clear_screen: unsafe extern "efiapi" fn(this: *mut Self) -> Status,
103 pub set_cursor_position:
104 unsafe extern "efiapi" fn(this: *mut Self, column: usize, row: usize) -> Status,
105 pub enable_cursor: unsafe extern "efiapi" fn(this: *mut Self, visible: Boolean) -> Status,
106 pub mode: *mut SimpleTextOutputMode,
107}
108
109impl SimpleTextOutputProtocol {
110 pub const GUID: Guid = guid!("387477c2-69c7-11d2-8e39-00a0c969723b");
111}
112
113#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
114#[repr(C)]
115pub struct SimplePointerMode {
116 pub resolution_x: u64,
117 pub resolution_y: u64,
118 pub resolution_z: u64,
119 pub left_button: u8,
120 pub right_button: u8,
121}
122
123#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
124#[repr(C)]
125pub struct SimplePointerState {
126 pub relative_movement_x: i32,
127 pub relative_movement_y: i32,
128 pub relative_movement_z: i32,
129 pub left_button: Boolean,
130 pub right_button: Boolean,
131}
132
133#[derive(Debug)]
134#[repr(C)]
135pub struct SimplePointerProtocol {
136 pub reset: unsafe extern "efiapi" fn(
137 this: *mut SimplePointerProtocol,
138 extended_verification: Boolean,
139 ) -> Status,
140 pub get_state: unsafe extern "efiapi" fn(
141 this: *mut SimplePointerProtocol,
142 state: *mut SimplePointerState,
143 ) -> Status,
144 pub wait_for_input: Event,
145 pub mode: *const SimplePointerMode,
146}
147
148impl SimplePointerProtocol {
149 pub const GUID: Guid = guid!("31878c87-0b75-11d5-9a4f-0090273fc14d");
150}
151
152#[derive(Debug)]
153#[repr(C)]
154pub struct GraphicsOutputProtocol {
155 pub query_mode: unsafe extern "efiapi" fn(
156 *const Self,
157 mode_number: u32,
158 size_of_info: *mut usize,
159 info: *mut *const GraphicsOutputModeInformation,
160 ) -> Status,
161 pub set_mode: unsafe extern "efiapi" fn(*mut Self, mode_number: u32) -> Status,
162 pub blt: unsafe extern "efiapi" fn(
163 *mut Self,
164 blt_buffer: *mut GraphicsOutputBltPixel,
165 blt_operation: GraphicsOutputBltOperation,
166 source_x: usize,
167 source_y: usize,
168 destination_x: usize,
169 destination_y: usize,
170 width: usize,
171 height: usize,
172 delta: usize,
173 ) -> Status,
174 pub mode: *mut GraphicsOutputProtocolMode,
175}
176
177impl GraphicsOutputProtocol {
178 pub const GUID: Guid = guid!("9042a9de-23dc-4a38-96fb-7aded080516a");
179}
180
181#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
182#[repr(C)]
183pub struct GraphicsOutputProtocolMode {
184 pub max_mode: u32,
185 pub mode: u32,
186 pub info: *mut GraphicsOutputModeInformation,
187 pub size_of_info: usize,
188 pub frame_buffer_base: PhysicalAddress,
189 pub frame_buffer_size: usize,
190}
191
192impl Default for GraphicsOutputProtocolMode {
193 fn default() -> Self {
194 Self {
195 max_mode: 0,
196 mode: 0,
197 info: ptr::null_mut(),
198 size_of_info: 0,
199 frame_buffer_base: 0,
200 frame_buffer_size: 0,
201 }
202 }
203}
204
205#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
206#[repr(C)]
207pub struct GraphicsOutputModeInformation {
208 pub version: u32,
209 pub horizontal_resolution: u32,
210 pub vertical_resolution: u32,
211 pub pixel_format: GraphicsPixelFormat,
212 pub pixel_information: PixelBitmask,
213 pub pixels_per_scan_line: u32,
214}
215
216#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
218#[repr(C)]
219pub struct PixelBitmask {
220 pub red: u32,
222
223 pub green: u32,
225
226 pub blue: u32,
228
229 pub reserved: u32,
231}
232
233newtype_enum! {
234 #[derive(Default)]
235 pub enum GraphicsPixelFormat: u32 => {
236 PIXEL_RED_GREEN_BLUE_RESERVED_8_BIT_PER_COLOR = 0,
237 PIXEL_BLUE_GREEN_RED_RESERVED_8_BIT_PER_COLOR = 1,
238 PIXEL_BIT_MASK = 2,
239 PIXEL_BLT_ONLY = 3,
240 PIXEL_FORMAT_MAX = 4,
241 }
242}
243
244#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
245#[repr(C)]
246pub struct GraphicsOutputBltPixel {
247 pub blue: u8,
248 pub green: u8,
249 pub red: u8,
250 pub reserved: u8,
251}
252
253newtype_enum! {
254 #[derive(Default)]
255 pub enum GraphicsOutputBltOperation: u32 => {
256 BLT_VIDEO_FILL = 0,
257 BLT_VIDEO_TO_BLT_BUFFER = 1,
258 BLT_BUFFER_TO_VIDEO = 2,
259 BLT_VIDEO_TO_VIDEO = 3,
260 GRAPHICS_OUTPUT_BLT_OPERATION_MAX = 4,
261 }
262}