add macros

This commit is contained in:
fekhesk 2022-10-26 11:59:02 -07:00
parent 4574150d2b
commit d0817025aa
No known key found for this signature in database
GPG key ID: D17BA3F38ED319DF
4 changed files with 44 additions and 27 deletions

View file

@ -2,24 +2,13 @@
use core::borrow::{BorrowMut};
use crate::{InterruptStackFrame, font};
use crate::{InterruptStackFrame, font, println};
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();
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());
drop(fb_width);
drop(fb_height);
drop(fb);
*/
println!("---KERNEL WARNING UWU---");
println!("breakpoint exception");
println!("stack frame: {:#?}", stack_frame);
loop {}
}

View file

@ -30,6 +30,8 @@ mod internals;
mod allocator;
mod security;
mod boot;
mod memory;
mod macros;
lazy_static! {
static ref IDT: InterruptDescriptorTable = {
@ -94,17 +96,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 +115,7 @@ pub extern fn kernel_main(args: KernelArgs) -> ! {
boot::MemoryType::Kernel => "Kernel",
boot::MemoryType::Bootloader => "Bootloader",
boot::MemoryType::Unknown(_) => "Unknown"
}).as_str());
});
}
loop {}

22
src/macros/mod.rs Normal file
View file

@ -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());
}

4
src/memory/mod.rs Normal file
View file

@ -0,0 +1,4 @@
#[repr(align(4096))]
pub struct PageTable {
entries: [PageTableEntry; 512],
}