Skip to content

Commit

Permalink
uefi-raw: Add SimpleTextInputProtocol and SimpleTextOutputProtocol
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasbishop committed Jun 19, 2023
1 parent 50657ce commit f064301
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
54 changes: 54 additions & 0 deletions uefi-raw/src/protocol/console.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use crate::{guid, Char16, Event, Guid, Status};

#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
#[repr(C)]
pub struct InputKey {
pub scan_code: u16,
pub unicode_char: Char16,
}

#[repr(C)]
pub struct SimpleTextInputProtocol {
pub reset: unsafe extern "efiapi" fn(this: *mut Self, extended_verification: bool) -> Status,
pub read_key_stroke: unsafe extern "efiapi" fn(this: *mut Self, key: *mut InputKey) -> Status,
pub wait_for_key: Event,
}

impl SimpleTextInputProtocol {
pub const GUID: Guid = guid!("387477c1-69c7-11d2-8e39-00a0c969723b");
}

#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
#[repr(C)]
pub struct SimpleTextOutputMode {
pub max_mode: i32,
pub mode: i32,
pub attribute: i32,
pub cursor_column: i32,
pub cursor_row: i32,
pub cursor_visible: bool,
}

#[repr(C)]
pub struct SimpleTextOutputProtocol {
pub reset: unsafe extern "efiapi" fn(this: *mut Self, extended: bool) -> Status,
pub output_string: unsafe extern "efiapi" fn(this: *mut Self, string: *const Char16) -> Status,
pub test_string: unsafe extern "efiapi" fn(this: *mut Self, string: *const Char16) -> Status,
pub query_mode: unsafe extern "efiapi" fn(
this: *mut Self,
mode: usize,
columns: *mut usize,
rows: *mut usize,
) -> Status,
pub set_mode: unsafe extern "efiapi" fn(this: *mut Self, mode: usize) -> Status,
pub set_attribute: unsafe extern "efiapi" fn(this: *mut Self, attribute: usize) -> Status,
pub clear_screen: unsafe extern "efiapi" fn(this: *mut Self) -> Status,
pub set_cursor_position:
unsafe extern "efiapi" fn(this: *mut Self, column: usize, row: usize) -> Status,
pub enable_cursor: unsafe extern "efiapi" fn(this: *mut Self, visible: bool) -> Status,
pub mode: *mut SimpleTextOutputMode,
}

impl SimpleTextOutputProtocol {
pub const GUID: Guid = guid!("387477c2-69c7-11d2-8e39-00a0c969723b");
}
1 change: 1 addition & 0 deletions uefi-raw/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
//! ID. They can be implemented by a UEFI driver or occasionally by a
//! UEFI application.

pub mod console;
pub mod device_path;
pub mod rng;

0 comments on commit f064301

Please sign in to comment.