add kernel stuff, idt, welcome message

This commit is contained in:
andromeda
2026-03-05 20:32:55 +01:00
parent 094e8c288a
commit fe99ea09fe
3 changed files with 135 additions and 27 deletions

View File

@@ -5,12 +5,11 @@ use core::panic::PanicInfo;
#[unsafe(no_mangle)]
pub extern "C" fn _start() -> ! {
// 'k'
print("kernel\n");
loop {}
welcome_serial();
halt()
}
fn print(s: &str) {
fn print_serial(s: &str) {
let mut bytes = s.bytes();
while let Some(b) = bytes.next() {
unsafe {core::arch::asm!(
@@ -20,8 +19,33 @@ fn print(s: &str) {
};
}
fn println_serial(s: &str) {
print_serial(s);
print_serial("\n");
}
fn welcome_serial() {
print_serial(ANSI_PINK);
println_serial("\nWelcome to Bootle OS");
println_serial("All code GPL licensed and freely available on git.mtgmonkey.net");
print_serial("Enjoy your time! Press "); print_serial(ANSI_RED); print_serial("ctrl+a x"); print_serial(ANSI_PINK); println_serial(" to escape Qemu");
print_serial(ANSI_CLEAR);
}
#[panic_handler]
fn panic(_: &PanicInfo) -> ! {
print("panicked");
loop {}
print_serial("panicked");
halt()
}
fn halt() -> ! {
unsafe {core::arch::asm!(
"hlt"
)};
halt()
}
const ANSI_CLEAR: &str = "\x1b[0m";
const ANSI_RED: &str = "\x1b[31m";
const ANSI_PINK: &str = "\x1b[35m";
const ANSI_GREEN: &str = "\x1b[32m";