From 38ec552c2b5b9cb15ecb8ec41dc6528b7518fcf1 Mon Sep 17 00:00:00 2001 From: mrgian Date: Wed, 12 Jul 2023 20:53:02 +0200 Subject: [PATCH] Add splash screen --- .gitignore | 1 + bootloader/src/main.rs | 14 ++++++++++++ bootloader/src/print.rs | 17 +++++++++++++-- bootloader/src/splash.rs | 39 ++++++++++++++++++++++++++++++++++ kernel/src/interrupts/timer.rs | 2 +- kernel/src/shell/shell.rs | 4 ++-- 6 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 bootloader/src/splash.rs diff --git a/.gitignore b/.gitignore index d1fcbb8..43504db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /build /target bx_enh_dbg.ini +out.txt .idea diff --git a/bootloader/src/main.rs b/bootloader/src/main.rs index 96e0d2a..d7d3545 100644 --- a/bootloader/src/main.rs +++ b/bootloader/src/main.rs @@ -6,6 +6,7 @@ mod print; mod disk; mod gdt; +mod splash; use core::arch::asm; use core::panic::PanicInfo; @@ -31,6 +32,13 @@ fn panic(info: &PanicInfo) -> ! { #[no_mangle] #[link_section = ".start"] pub extern "C" fn _start() -> ! { + clear!(); + + splash::splash(); + + wait_for_key(); + clear!(); + //unreal mode is needed because diskreader needs to copy from buffer to protected mode memory println!("[!] Switching to 16bit unreal mode..."); unreal_mode(); @@ -133,3 +141,9 @@ fn unreal_mode() { asm!("mov ss, {0:x}", in(reg) ss); } } + +fn wait_for_key() { + unsafe { + asm!("int 0x16", in("ah") 0x00 as u8); + } +} diff --git a/bootloader/src/print.rs b/bootloader/src/print.rs index 8439ab1..2f098da 100644 --- a/bootloader/src/print.rs +++ b/bootloader/src/print.rs @@ -45,8 +45,7 @@ impl Printer { } //set bios video mode to clear the screen - #[allow(dead_code)] - pub fn clear() { + pub fn clear(&self) { unsafe { asm!( "int 0x10", @@ -56,6 +55,14 @@ impl Printer { } } +//macro for clear! +#[macro_export] +macro_rules! clear { + () => { + $crate::print::_clear() + }; +} + //macro for print! #[macro_export] macro_rules! print { @@ -76,6 +83,12 @@ pub fn _print(args: fmt::Arguments) { } } +pub fn _clear() { + unsafe { + PRINTER.clear(); + } +} + //bios interrupt to print to the screen /*pub fn print(message: &str) { unsafe { diff --git a/bootloader/src/splash.rs b/bootloader/src/splash.rs new file mode 100644 index 0000000..9ba60bb --- /dev/null +++ b/bootloader/src/splash.rs @@ -0,0 +1,39 @@ +pub const SPLASH: &'static str = +"▄ ▄ ▄ + ██▄ ▄██ + █ ▀█▄ ▄█▀▐█ + █ ▀▄ ▄▀ ▐█ + █ ▀█ █▀ ▐█ + █ ██▄ ▀█▄ ▄█▀ ▄█▌ ▐█ + █ █▌▀█▄ ▀██ ██▀ ▄█▀▐▌ ▐█ + █ █▌ ▀▄ ▄▀ ▐▌ ▐█ + █ ▐██ ▄▀ ██ ▀▄ ██▌▐█ + █ █▀ ▐▌ ▀█ ▐█ + █ ▄█▀ ▐▌ ▀█▄ ▐█ + █▄█▀ ▐▌ ▀█▄█ + █▀ ▐▌ ▀█ + ▐▌ + ▀█▄▄▄▄▄▄▄▄▄▄ ▐▌ ▄▄▄▄▄▄▄▄▄▄█▀ + ▐▌ + ▐▌ + ▄▄ ▐▌ ▄▄ + ▀█▄▄▄▄▄▄▄▄▄▄▄▄▄▄██ ▄▄▄▄▄▄▄▄▄▄ ██▄▄▄▄▄▄▄▄▄▄▄▄▄▄█▀ + ▀██████▀ + ▀▀▀▀▀▀▀▀▀▀▀▀▀▀██ ▀██▀ ██▀▀▀▀▀▀▀▀▀▀▀▀▀▀ + ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀▀▀▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ + + Press any key to start..."; + +pub fn splash() { + for c in SPLASH.chars() { + match c { + '▀' => print!("{}", 0xdf as char), + '▐' => print!("{}", 0xde as char), + '▌' => print!("{}", 0xdd as char), + '▄' => print!("{}", 0xdc as char), + '█' => print!("{}", 0xdb as char), + '\n' => {}, + _ => print!("{}", c), + } + } +} \ No newline at end of file diff --git a/kernel/src/interrupts/timer.rs b/kernel/src/interrupts/timer.rs index 2dab41b..88d6243 100644 --- a/kernel/src/interrupts/timer.rs +++ b/kernel/src/interrupts/timer.rs @@ -60,7 +60,7 @@ pub extern "C" fn timer_handler(esp: u32) -> u32 { let slot = TASK_MANAGER.get_current_slot(); let target = APP_TARGET + (slot as u32 * APP_SIZE); - //map table 8 (0x02000000) to the address where the executable is loaded + //map table 8 (0x02000000) to the address where the executable is loaded TABLES[8].set(target); PAGING.set_table(8, &TABLES[8]); diff --git a/kernel/src/shell/shell.rs b/kernel/src/shell/shell.rs index afb91f7..5235f5e 100644 --- a/kernel/src/shell/shell.rs +++ b/kernel/src/shell/shell.rs @@ -197,10 +197,10 @@ impl Shell { let slot = TASK_MANAGER.get_free_slot(); let target = APP_TARGET + (slot as u32 * APP_SIZE); - //map table 8 (0x02000000) to the address where the executable is loaded + //map table 8 (0x02000000) to the address where the executable is loaded TABLES[8].set(target); PAGING.set_table(8, &TABLES[8]); - + FAT.read_file_to_target(&entry, target as *mut u32); unsafe {