Compare commits
2 Commits
4574150d2b
...
9a5a004243
Author | SHA1 | Date |
---|---|---|
fekhesk | 9a5a004243 | |
fekhesk | d0817025aa |
|
@ -1,25 +1,31 @@
|
|||
|
||||
use core::borrow::{BorrowMut};
|
||||
use x86_64::registers::control::Cr2;
|
||||
use x86_64::structures::idt::PageFaultErrorCode;
|
||||
|
||||
|
||||
use crate::{InterruptStackFrame, font};
|
||||
use crate::{InterruptStackFrame, font, println, print};
|
||||
use crate::internals::WhyDoTheyCallItOvenWhenYouOfInTheColdFoodOfOutHotEatTheFood::{COMMUNIST_RED, CUM_WHITE, Colour};
|
||||
use crate::serial::terminal::ST;
|
||||
|
||||
pub extern "x86-interrupt" fn breakpoint_exception(stack_frame: InterruptStackFrame) {
|
||||
/*
|
||||
// cover the screen in a nice communist red (:
|
||||
let mut fb = FACEBOOK.fb_mutex.lock();
|
||||
let fb_width = FACEBOOK.fb_width.lock();
|
||||
let fb_height = FACEBOOK.fb_height.lock();
|
||||
println!("---KERNEL WARNING UWU---");
|
||||
println!("breakpoint exception");
|
||||
println!("stack frame: {:#?}", stack_frame);
|
||||
}
|
||||
|
||||
draw_box(0,0,*fb_width,*fb_height, COMMUNIST_RED, fb.borrow_mut());
|
||||
// draw our funny text
|
||||
draw_horizcentre_string(*fb_width,(*fb_height / 2) - (14 * (8/2)), "OOPSY WOOPSY, THE KERNEL HAD A FUCKY WUCKY UWU", CUM_WHITE, fb.borrow_mut());
|
||||
draw_horizcentre_string(*fb_width,(*fb_height / 2) - (10 * (8/2)), "WHOEVER WAS PROGRAMMING THE KERNEL DECIDED TO LEAVE A BREAKPOINT IN IT, OOPS (:", CUM_WHITE, fb.borrow_mut());
|
||||
draw_horizcentre_string(*fb_width,(*fb_height / 2) - (4 * (8/2)), "THE KERNEL IS NOW HALTED, YOU CAN'T DO ANYTHING UNTIL YOU RESTART THE KERNEL", CUM_WHITE, fb.borrow_mut());
|
||||
pub extern "x86-interrupt" fn double_fault(stack_frame: InterruptStackFrame, _error_code: u64) -> ! {
|
||||
println!("---KERNEL FUCKY WUKKY UWU---");
|
||||
println!("double fault!");
|
||||
println!("stack frame: {:#?}", stack_frame);
|
||||
loop {}
|
||||
}
|
||||
|
||||
drop(fb_width);
|
||||
drop(fb_height);
|
||||
drop(fb);
|
||||
*/
|
||||
pub extern "x86-interrupt" fn page_fault(stack_frame: InterruptStackFrame, error_code: PageFaultErrorCode) -> ! {
|
||||
println!("---KERNEL FUCKY WUKKY UWU---");
|
||||
println!("page fault!");
|
||||
println!("accessed address: {:?}", Cr2::read());
|
||||
println!("error code: {:?}", error_code);
|
||||
println!("stack frame: {:#?}", stack_frame);
|
||||
loop {}
|
||||
}
|
24
src/lib.rs
24
src/lib.rs
|
@ -30,11 +30,15 @@ mod internals;
|
|||
mod allocator;
|
||||
mod security;
|
||||
mod boot;
|
||||
mod memory;
|
||||
mod macros;
|
||||
|
||||
lazy_static! {
|
||||
static ref IDT: InterruptDescriptorTable = {
|
||||
let mut idt = InterruptDescriptorTable::new();
|
||||
idt.breakpoint.set_handler_fn(internals::errors::breakpoint_exception);
|
||||
idt.double_fault.set_handler_fn(internals::errors::double_fault);
|
||||
idt.page_fault.set_handler_fn(internals::errors::page_fault);
|
||||
idt
|
||||
};
|
||||
}
|
||||
|
@ -94,17 +98,17 @@ pub extern fn kernel_main(args: KernelArgs) -> ! {
|
|||
}
|
||||
};
|
||||
|
||||
ST.logln("");
|
||||
ST.logln("");
|
||||
ST.logln("");
|
||||
ST.logln("welcome to wukkOS!");
|
||||
ST.logln("(c) 2022 Real Microsoft, LLC");
|
||||
ST.log("initialising memory maps...");
|
||||
println!();
|
||||
println!();
|
||||
println!();
|
||||
println!("welcome to wukkOS!");
|
||||
println!("(c) 2022 Real Microsoft, LLC");
|
||||
print!("initialising memory maps...");
|
||||
let mem_areas = kern_info.get_memory_areas();
|
||||
ST.logln("[OK]");
|
||||
ST.logln("memory map:");
|
||||
println!("[OK]");
|
||||
println!("memory map:");
|
||||
for area in mem_areas {
|
||||
ST.logln(format!("{:x} - {:x} : {}", area.start, area.end, match area.area_type {
|
||||
println!("{:x} - {:x} : {}", area.start, area.end, match area.area_type {
|
||||
boot::MemoryType::Available => "Available",
|
||||
boot::MemoryType::Reserved => "Reserved",
|
||||
boot::MemoryType::AcpiReclaimable => "ACPI Reclaimable",
|
||||
|
@ -113,7 +117,7 @@ pub extern fn kernel_main(args: KernelArgs) -> ! {
|
|||
boot::MemoryType::Kernel => "Kernel",
|
||||
boot::MemoryType::Bootloader => "Bootloader",
|
||||
boot::MemoryType::Unknown(_) => "Unknown"
|
||||
}).as_str());
|
||||
});
|
||||
}
|
||||
|
||||
loop {}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
use alloc::fmt::format;
|
||||
use core::fmt;
|
||||
use std::fmt::format;
|
||||
use crate::serial::terminal::ST;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! print {
|
||||
($($arg:tt)*) => ($crate::macros::_print(format_args!($($arg)*)));
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! println {
|
||||
() => ($crate::print!("\n"));
|
||||
($($arg:tt)*) => ($crate::print!("{}\n", format_args!($($arg)*)));
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub fn _print(args: fmt::Arguments) {
|
||||
use core::fmt::Write;
|
||||
let string = format(args);
|
||||
ST.log(string.as_str());
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
#[repr(align(4096))]
|
||||
pub struct PageTable {
|
||||
entries: [PageTableEntry; 512],
|
||||
}
|
Loading…
Reference in New Issue