1pub mod serial;
4
5use crate::{Boolean, Char16, Event, Guid, PhysicalAddress, Status, guid, newtype_enum};
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,
167 blt_operation: GraphicsOutputBltOperation,
168 source_x: usize,
169 source_y: usize,
170 destination_x: usize,
171 destination_y: usize,
172 width: usize,
173 height: usize,
174 delta: usize,
175 ) -> Status,
176 pub mode: *mut GraphicsOutputProtocolMode,
177}
178
179impl GraphicsOutputProtocol {
180 pub const GUID: Guid = guid!("9042a9de-23dc-4a38-96fb-7aded080516a");
181}
182
183#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
184#[repr(C)]
185pub struct GraphicsOutputProtocolMode {
186 pub max_mode: u32,
187 pub mode: u32,
188 pub info: *mut GraphicsOutputModeInformation,
189 pub size_of_info: usize,
190 pub frame_buffer_base: PhysicalAddress,
191 pub frame_buffer_size: usize,
192}
193
194impl Default for GraphicsOutputProtocolMode {
195 fn default() -> Self {
196 Self {
197 max_mode: 0,
198 mode: 0,
199 info: ptr::null_mut(),
200 size_of_info: 0,
201 frame_buffer_base: 0,
202 frame_buffer_size: 0,
203 }
204 }
205}
206
207#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
208#[repr(C)]
209pub struct GraphicsOutputModeInformation {
210 pub version: u32,
211 pub horizontal_resolution: u32,
212 pub vertical_resolution: u32,
213 pub pixel_format: GraphicsPixelFormat,
214 pub pixel_information: PixelBitmask,
215 pub pixels_per_scan_line: u32,
216}
217
218#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
220#[repr(C)]
221pub struct PixelBitmask {
222 pub red: u32,
224
225 pub green: u32,
227
228 pub blue: u32,
230
231 pub reserved: u32,
233}
234
235newtype_enum! {
236 #[derive(Default)]
237 pub enum GraphicsPixelFormat: u32 => {
238 PIXEL_RED_GREEN_BLUE_RESERVED_8_BIT_PER_COLOR = 0,
239 PIXEL_BLUE_GREEN_RED_RESERVED_8_BIT_PER_COLOR = 1,
240 PIXEL_BIT_MASK = 2,
241 PIXEL_BLT_ONLY = 3,
242 PIXEL_FORMAT_MAX = 4,
243 }
244}
245
246#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
247#[repr(C)]
248pub struct GraphicsOutputBltPixel {
249 pub blue: u8,
250 pub green: u8,
251 pub red: u8,
252 pub reserved: u8,
253}
254
255newtype_enum! {
256 #[derive(Default)]
257 pub enum GraphicsOutputBltOperation: u32 => {
258 BLT_VIDEO_FILL = 0,
259 BLT_VIDEO_TO_BLT_BUFFER = 1,
260 BLT_BUFFER_TO_VIDEO = 2,
261 BLT_VIDEO_TO_VIDEO = 3,
262 GRAPHICS_OUTPUT_BLT_OPERATION_MAX = 4,
263 }
264}