Skip to content

Commit 8db30d0

Browse files
committedFeb 7, 2024
first draft for GOP
1 parent c27ada5 commit 8db30d0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
 

‎src/uefi.rs

+23
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ use core::{cmp, fmt::Write, mem, slice};
55
use hermit_entry::elf::KernelObject;
66
use log::info;
77
use uefi::{
8+
Identify,
89
prelude::*,
10+
proto::console::gop::GraphicsOutput,
911
table::{boot::*, cfg},
1012
};
1113

@@ -21,6 +23,25 @@ unsafe fn loader_main(_handle: Handle, mut system_table: SystemTable<Boot>) -> S
2123
crate::log::init();
2224

2325
info!("Hello World from UEFI boot!");
26+
let stdout = system_table.stdout();
27+
stdout.clear().unwrap();
28+
writeln!(stdout, "Hello World! This is the bootloader").unwrap();
29+
30+
31+
let bs = system_table.boot_services();
32+
let gop_handle = bs.get_handle_for_protocol::<GraphicsOutput>().unwrap();
33+
let mut gop = bs.open_protocol_exclusive::<GraphicsOutput>(gop_handle).unwrap();
34+
// for g in gop.modes(){
35+
// info!("gop_handle modes: {:#?}", g.info());
36+
// }
37+
let gop_mode = gop.query_mode(0).unwrap();
38+
gop.set_mode(&gop_mode).unwrap();
39+
let mut framebuffer = gop.frame_buffer();
40+
for i in 0..1000 {
41+
unsafe {framebuffer.write_byte(i, 69)};
42+
43+
}
44+
drop(gop);
2445
// look for the rsdp in the EFI system table before calling exit boot services (see UEFI specification for more)
2546
let rsdp_addr = {
2647
// returns an iterator to the config table entries which in turn point to other system-specific tables
@@ -56,6 +77,7 @@ unsafe fn loader_main(_handle: Handle, mut system_table: SystemTable<Boot>) -> S
5677

5778
// exit boot services for getting a runtime view of the system table and an iterator to the UEFI memory map
5879
let (runtime_system_table, mut memory_map) = system_table.exit_boot_services();
80+
//writeln!(stdout, "Hello World! This is the bootloader").unwrap();
5981

6082
memory_map.sort();
6183
let mut entries = memory_map.entries();
@@ -88,6 +110,7 @@ unsafe fn loader_main(_handle: Handle, mut system_table: SystemTable<Boot>) -> S
88110
runtime_system_table,
89111
start_address,
90112
end_address,
113+
91114
)
92115
}
93116

0 commit comments

Comments
 (0)