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(this: *mut Self, extended_verification: Boolean) -> Status,
137 pub get_state:
138 unsafe extern "efiapi" fn(this: *mut Self, state: *mut SimplePointerState) -> Status,
139 pub wait_for_input: Event,
140 pub mode: *const SimplePointerMode,
141}
142
143impl SimplePointerProtocol {
144 pub const GUID: Guid = guid!("31878c87-0b75-11d5-9a4f-0090273fc14d");
145}
146
147#[derive(Debug)]
148#[repr(C)]
149pub struct GraphicsOutputProtocol {
150 pub query_mode: unsafe extern "efiapi" fn(
151 *const Self,
152 mode_number: u32,
153 size_of_info: *mut usize,
154 info: *mut *const GraphicsOutputModeInformation,
155 ) -> Status,
156 pub set_mode: unsafe extern "efiapi" fn(*mut Self, mode_number: u32) -> Status,
157 pub blt: unsafe extern "efiapi" fn(
158 *mut Self,
159 blt_buffer: *mut GraphicsOutputBltPixel,
162 blt_operation: GraphicsOutputBltOperation,
163 source_x: usize,
164 source_y: usize,
165 destination_x: usize,
166 destination_y: usize,
167 width: usize,
168 height: usize,
169 delta: usize,
170 ) -> Status,
171 pub mode: *mut GraphicsOutputProtocolMode,
172}
173
174impl GraphicsOutputProtocol {
175 pub const GUID: Guid = guid!("9042a9de-23dc-4a38-96fb-7aded080516a");
176}
177
178#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
179#[repr(C)]
180pub struct GraphicsOutputProtocolMode {
181 pub max_mode: u32,
182 pub mode: u32,
183 pub info: *mut GraphicsOutputModeInformation,
184 pub size_of_info: usize,
185 pub frame_buffer_base: PhysicalAddress,
186 pub frame_buffer_size: usize,
187}
188
189impl Default for GraphicsOutputProtocolMode {
190 fn default() -> Self {
191 Self {
192 max_mode: 0,
193 mode: 0,
194 info: ptr::null_mut(),
195 size_of_info: 0,
196 frame_buffer_base: 0,
197 frame_buffer_size: 0,
198 }
199 }
200}
201
202#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
203#[repr(C)]
204pub struct GraphicsOutputModeInformation {
205 pub version: u32,
206 pub horizontal_resolution: u32,
207 pub vertical_resolution: u32,
208 pub pixel_format: GraphicsPixelFormat,
209 pub pixel_information: PixelBitmask,
210 pub pixels_per_scan_line: u32,
211}
212
213#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
215#[repr(C)]
216pub struct PixelBitmask {
217 pub red: u32,
219
220 pub green: u32,
222
223 pub blue: u32,
225
226 pub reserved: u32,
228}
229
230newtype_enum! {
231 #[derive(Default)]
232 pub enum GraphicsPixelFormat: u32 => {
233 PIXEL_RED_GREEN_BLUE_RESERVED_8_BIT_PER_COLOR = 0,
234 PIXEL_BLUE_GREEN_RED_RESERVED_8_BIT_PER_COLOR = 1,
235 PIXEL_BIT_MASK = 2,
236 PIXEL_BLT_ONLY = 3,
237 PIXEL_FORMAT_MAX = 4,
238 }
239}
240
241#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
242#[repr(C)]
243pub struct GraphicsOutputBltPixel {
244 pub blue: u8,
245 pub green: u8,
246 pub red: u8,
247 pub reserved: u8,
248}
249
250newtype_enum! {
251 #[derive(Default)]
252 pub enum GraphicsOutputBltOperation: u32 => {
253 BLT_VIDEO_FILL = 0,
254 BLT_VIDEO_TO_BLT_BUFFER = 1,
255 BLT_BUFFER_TO_VIDEO = 2,
256 BLT_VIDEO_TO_VIDEO = 3,
257 GRAPHICS_OUTPUT_BLT_OPERATION_MAX = 4,
258 }
259}