Skip to content

Commit

Permalink
Add splash screen
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgian committed Jul 12, 2023
1 parent 621b139 commit 38ec552
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/build
/target
bx_enh_dbg.ini
out.txt

.idea
14 changes: 14 additions & 0 deletions bootloader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod print;

mod disk;
mod gdt;
mod splash;

use core::arch::asm;
use core::panic::PanicInfo;
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
}
17 changes: 15 additions & 2 deletions bootloader/src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
39 changes: 39 additions & 0 deletions bootloader/src/splash.rs
Original file line number Diff line number Diff line change
@@ -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),
}
}
}
2 changes: 1 addition & 1 deletion kernel/src/interrupts/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
4 changes: 2 additions & 2 deletions kernel/src/shell/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 38ec552

Please sign in to comment.