Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgian committed Jul 13, 2023
1 parent e893fb1 commit 7b6d1d7
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 55 deletions.
1 change: 1 addition & 0 deletions bootloader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ fn unreal_mode() {
}
}

#[allow(dead_code)]
fn wait_for_key() {
unsafe {
asm!("int 0x16", in("ah") 0x00 as u8);
Expand Down
2 changes: 2 additions & 0 deletions bootloader/src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl Printer {
}

//set bios video mode to clear the screen
#[allow(dead_code)]
pub fn clear(&self) {
unsafe {
asm!(
Expand Down Expand Up @@ -83,6 +84,7 @@ pub fn _print(args: fmt::Arguments) {
}
}

#[allow(dead_code)]
pub fn _clear() {
unsafe {
PRINTER.clear();
Expand Down
3 changes: 2 additions & 1 deletion bootloader/src/splash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ pub const SPLASH: &'static str =
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀▀▀▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
Press any key to start...";


#[allow(dead_code)]
pub fn splash() {
for c in SPLASH.chars() {
match c {
Expand Down
74 changes: 21 additions & 53 deletions kernel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use filesystem::fat::FAT;
use interrupts::idt::IDT;
use memory::allocator::Allocator;
use memory::paging::PAGING;
use memory::paging::TABLES;
use shell::shell::SHELL;
use syscalls::print::PRINTER;

Expand All @@ -45,94 +44,63 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
#[no_mangle]
#[link_section = ".start"]
pub extern "C" fn _start() -> ! {
//setup stack
unsafe {
//setup stack
asm!("mov esp, {}", in(reg) STACK_START);
}

//setup paging
unsafe {
//setup paging
PAGING.identity();

PAGING.enable();
}

unsafe {
//bochs magic breakpoint
asm!("xchg bx, bx");
}

unsafe {
//init idt
IDT.init();

//add CPU exceptions to idt
IDT.add_exceptions();

//add timer interrupt to idt
//setup idt
IDT.init(); //init idt
IDT.add_exceptions(); //add CPU exceptions to idt
IDT.add(
interrupts::timer::TIMER_INT as usize,
interrupts::timer::timer as u32,
);

//add system call handler interrupt
); //add timer interrupt to idt
IDT.add(
syscalls::handler::SYSCALL_INT as usize,
syscalls::handler::syscall as u32,
);

//add keyboard interrupt to idt
); //add system call handler interrupt
IDT.add(
drivers::keyboard::KEYBOARD_INT as usize,
drivers::keyboard::keyboard as u32,
);
); //add keyboard interrupt to idt
IDT.load(); //load idt

//load idt
IDT.load();
}

//init programmable interrupt controllers
PICS.init();
//init programmable interrupt controllers
PICS.init();

unsafe {
//check if ata drive is working
//enable ata disk if present
DISK.check();
}

print_info();

unsafe {
//init filesystem
if DISK.enabled {
//init filesystem
FAT.load_header();
FAT.load_entries();
FAT.load_table();
}
}

unsafe {
//print name, version and copyright
print_info();

//init felix shell
SHELL.init();
}

unsafe {
//init multitasking
TASK_MANAGER.init();
}

//bochs magic breakpoint
unsafe {
//bochs magic breakpoint
asm!("xchg bx, bx");
}

//enable hardware interrupts
unsafe {
//enable hardware interrupts
asm!("sti");
}

//halt cpu while waiting for interrupts
loop {
unsafe {
asm!("hlt");
}
loop {}
}
}

Expand Down
7 changes: 6 additions & 1 deletion kernel/src/multitasking/task.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//TASK MANAGER
use core::arch::asm;

const STACK_SIZE: usize = 4096;
const MAX_TASKS: i8 = 32;
Expand Down Expand Up @@ -191,7 +192,11 @@ impl TaskManager {
}

fn idle() {
loop {}
loop {
unsafe {
asm!("hlt");
}
}
}

//EXAMPLE TASKS
Expand Down

0 comments on commit 7b6d1d7

Please sign in to comment.