Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/interrupts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use crate::println;
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};

use lazy_static::lazy_static;

lazy_static! {
static ref IDT: InterruptDescriptorTable = {
let mut idt = InterruptDescriptorTable::new();
idt.breakpoint.set_handler_fn(breakpoint_handler);
idt
};
}

pub fn init_idt() {
IDT.load();
}

extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame) {
println!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame);
}

#[test_case]
fn test_breakpoint_exception() {
x86_64::instructions::interrupts::int3();
}
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
#![feature(custom_test_frameworks)]
#![test_runner(crate::test_runner)]
#![reexport_test_harness_main = "test_main"]
#![feature(abi_x86_interrupt)]

use core::panic::PanicInfo;

pub mod interrupts;
pub mod serial;
pub mod vga_buffer;

pub fn init() {
interrupts::init_idt();
}

pub trait Testable {
fn run(&self) -> ();
}
Expand Down Expand Up @@ -59,6 +65,7 @@ pub fn test_panic_handler(info: &PanicInfo) -> ! {
#[cfg(test)]
#[no_mangle]
pub extern "C" fn _start() -> ! {
init();
test_main();
loop {}
}
Expand Down
11 changes: 10 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ use infinity_os::println;

#[no_mangle]
pub extern "C" fn _start() -> ! {
println!("Hello World{}", "!");
println!(" _____ __ _ _ _ ____ _____ ");
println!(" |_ _| / _(_) (_) | / __ \\ / ____|");
println!(" | | _ __ | |_ _ _ __ _| |_ _ _| | | | (___ ");
println!(" | | | '_ \\| _| | '_ \\| | __| | | | | | |\\___ \\ ");
println!(" _| |_| | | | | | | | | | | |_| |_| | |__| |____) |");
println!(" |_____|_| |_|_| |_|_| |_|_|\\__|\\__, |\\____/|_____/ ");
println!(" __/ | ");
println!(" |___/ ");

infinity_os::init();

#[cfg(test)]
test_main();
Expand Down
2 changes: 1 addition & 1 deletion src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ macro_rules! serial_println {
($fmt:expr) => ($crate::serial_print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => ($crate::serial_print!(
concat!($fmt, "\n"), $($arg)*));
}
}