finish defining simple text output protocol

This commit is contained in:
wmpod2xwie 2024-06-20 18:02:22 +10:00
parent 845559a9f5
commit 43d9a42bec
3 changed files with 53 additions and 26 deletions

View File

@ -11,13 +11,14 @@ pub mod simple_text_output;
use core::panic::PanicInfo; use core::panic::PanicInfo;
use system_table::SystemTable; use system_table::SystemTable;
use types::Handle; use types::Handle;
use simple_text_output::SimpleTextOutputProtocol;
#[no_mangle] #[no_mangle]
#[export_name = "efi_main"] #[export_name = "efi_main"]
extern "efiapi" fn efi_main(image_handle: Handle, system_table: *mut SystemTable) -> usize { extern "efiapi" fn efi_main(image_handle: Handle, system_table: *mut SystemTable) -> usize {
unsafe { unsafe {
let system_table_ref: &SystemTable = &*system_table; let system_table_ref: &SystemTable = &*system_table;
let console_out: *mut structs::SimpleTextOutputProtocol = system_table_ref.console_out; let console_out: *mut SimpleTextOutputProtocol = system_table_ref.console_out;
} }
loop {}; loop {};
0 // EFI_SUCCESS 0 // EFI_SUCCESS

View File

@ -2,7 +2,18 @@ use crate::structs::Status;
use crate::types::Char16; use crate::types::Char16;
#[repr(C)] #[repr(C)]
pub struct SimpleTextOutputProtocol {} pub struct SimpleTextOutputProtocol {
reset: text_reset,
output_string: text_string,
test_string: text_test_string,
query_mode: text_query_mode,
set_mode: text_set_mode,
set_attribute: text_set_attribute,
clear_screen: text_clear_screen,
set_cursor_position: text_set_cursor_position,
enable_cursor: text_enable_cursor,
mode: *mut SimpleTextOutputMode,
}
pub type text_reset = pub type text_reset =
extern "efiapi" fn(this: &SimpleTextOutputProtocol, extended_verification: bool) -> Status; extern "efiapi" fn(this: &SimpleTextOutputProtocol, extended_verification: bool) -> Status;
@ -20,33 +31,47 @@ pub type text_set_mode =
extern "efiapi" fn(this: &SimpleTextOutputProtocol, mode_number: usize) -> Status; extern "efiapi" fn(this: &SimpleTextOutputProtocol, mode_number: usize) -> Status;
pub type text_set_attribute = pub type text_set_attribute =
extern "efiapi" fn(this: &SimpleTextOutputProtocol, Attribute: usize) -> Status; extern "efiapi" fn(this: &SimpleTextOutputProtocol, Attribute: usize) -> Status;
pub type text_clear_screen = extern "efiapi" fn(this: SimpleTextOutputProtocol) -> Status;
pub type text_set_cursor_position =
extern "efiapi" fn(this: &SimpleTextOutputProtocol, column: usize, row: usize) -> Status;
pub type text_enable_cursor =
extern "efiapi" fn(this: &SimpleTextOutputProtocol, visible: bool) -> Status;
#[repr(C)] #[repr(C)]
pub enum Attribute { pub enum Attribute {
Black = 0x00 , Black = 0x00,
Blue = 0x01 , Blue = 0x01,
Green = 0x02 , Green = 0x02,
Cyan = 0x03 , Cyan = 0x03,
Red = 0x04 , Red = 0x04,
Magenta = 0x05 , Magenta = 0x05,
Brown = 0x06 , Brown = 0x06,
LightGray = 0x07 , LightGray = 0x07,
Bright = 0x08 , Bright = 0x08,
// DarkGray = 0x08 , // DarkGray = 0x08 ,
LightBlue = 0x09 , LightBlue = 0x09,
LightGreen = 0x0a , LightGreen = 0x0a,
LightCyan = 0x0b , LightCyan = 0x0b,
LightRed = 0x0c , LightRed = 0x0c,
LightMagenta = 0x0d , LightMagenta = 0x0d,
Yellow = 0x0e , Yellow = 0x0e,
White = 0x0f , White = 0x0f,
// BackgroundBlack = 0x00 , // BackgroundBlack = 0x00 ,
BackgroundBlue = 0x10 , BackgroundBlue = 0x10,
BackgroundGreen = 0x20 , BackgroundGreen = 0x20,
BackgroundCyan = 0x30 , BackgroundCyan = 0x30,
BackgroundRed = 0x40 , BackgroundRed = 0x40,
BackgroundMagenta = 0x50 , BackgroundMagenta = 0x50,
BackgroundBrown = 0x60 , BackgroundBrown = 0x60,
BackgroundLightGray = 0x70 , BackgroundLightGray = 0x70,
}
#[repr(C)]
pub struct SimpleTextOutputMode {
max_mode: i32,
mode: i32,
attribute: i32,
cursor_column: i32,
cursor_row: i32,
cursor_visible: bool,
} }

View File

@ -1,6 +1,7 @@
use crate::boot_services::BootServicesTable; use crate::boot_services::BootServicesTable;
use crate::structs::*; use crate::structs::*;
use crate::types::Handle; use crate::types::Handle;
use crate::simple_text_output::SimpleTextOutputProtocol;
#[repr(C)] #[repr(C)]
pub struct SystemTable { pub struct SystemTable {