From 1cead2eccf40b12537ddb4ab0c42eb57a4d0c8a8 Mon Sep 17 00:00:00 2001 From: able Date: Fri, 29 Jul 2022 12:48:45 -0500 Subject: [PATCH] shuffling --- ableos/src/arch/x86_64/interrupts.rs | 45 ++++++++++++++++------------ ableos/src/handle.rs | 1 + ableos/src/kmain.rs | 2 +- ableos/src/lib.rs | 3 +- ableos/src/panic.rs | 11 +++++++ ableos/src/scratchpad.rs | 4 ++- kernel/src/lib.rs | 2 +- kernel/src/panic.rs | 1 + 8 files changed, 46 insertions(+), 23 deletions(-) create mode 100644 ableos/src/panic.rs diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index d74e96fa..dde42a8f 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -1,3 +1,5 @@ +use core::panic::PanicInfo; + use crate::{ arch::{drivers::vga::WRITER, gdt}, image::mono_bitmap::bruh, @@ -75,9 +77,8 @@ extern "x86-interrupt" fn double_fault_handler( // NOTE(able): ignore this always is 0 _error_code: u64, ) -> ! { - bsod(&stack_frame, BSODSource::DoubleFault); - - panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame); + bsod(BSODSource::DoubleFault(&stack_frame)); + // panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame); } #[naked] @@ -198,23 +199,28 @@ pub fn reset_pit_for_cpu() { set_pit_2(1000); set_pit_3(1000); } - -fn bsod(stack_frame: &InterruptStackFrame, src: BSODSource) { +pub fn bsod(src: BSODSource) -> ! { let mut mode = SCREEN_BUFFER.lock(); - mode.force_redraw(); + /* for y in 0..480 { for x in 0..640 { mode.set_pixel(x, y, 0x0000ff00); } } + */ let mut x = 1; let mut y = 0; + let src1 = match src { + BSODSource::DoubleFault(_) => "DoubleFault", + BSODSource::Panic(_) => "Panic", + }; + let st = format!( - "We fucked up ඞ : {:?}\nThe following qr code will link you to the\nwiki which hopefully solves your problems", - src + "We fucked up ඞ : {}\nThe following qr code will link you to the\nwiki which hopefully solves your problems", + src1 ); for current in st.chars() { @@ -238,7 +244,11 @@ fn bsod(stack_frame: &InterruptStackFrame, src: BSODSource) { // let sf = format!("https://git.ablecorp.us/able/ableos/wiki/Double-Faults"); let sd = match src { - BSODSource::DoubleFault => "https://git.ablecorp.us/able/ableos/wiki/Double-Faults", + BSODSource::DoubleFault(_) => "https://git.ablecorp.us/able/ableos/wiki/Double-Faults", + BSODSource::Panic(_) => { + // + "https://git.ablecorp.us/able/ableos/wiki/" + } }; let code = QrCode::new(sd).unwrap(); @@ -254,23 +264,20 @@ fn bsod(stack_frame: &InterruptStackFrame, src: BSODSource) { y += 1; x = 0; } else { - if x == 0 { - if current == '█' { - mode.draw_filled_rect(x, y * 7, x + 6, (y * 7) + 7, 0xffff0000); - } - } else { - if current == '█' { - mode.draw_filled_rect(x * 6, y * 7, (x * 6) + 6, (y * 7) + 7, 0xffff0000); - } + if current == '█' { + mode.draw_filled_rect(x * 6, y * 7, (x * 6) + 6, (y * 7) + 7, 0xffffff00); } } x += 1; } mode.copy_to_buffer(); + + loop {} } #[derive(Debug)] -pub enum BSODSource { - DoubleFault, +pub enum BSODSource<'a> { + DoubleFault(&'a InterruptStackFrame), + Panic(&'a PanicInfo<'a>), } diff --git a/ableos/src/handle.rs b/ableos/src/handle.rs index 8f6f162e..5d35bc51 100644 --- a/ableos/src/handle.rs +++ b/ableos/src/handle.rs @@ -15,6 +15,7 @@ pub struct BinaryData { pub enum HandleResource { Channel, Socket, + BinaryData, } diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index ca22b2c8..bd0afedd 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -50,7 +50,7 @@ pub fn kernel_main() -> ! { x86_64::instructions::interrupts::without_interrupts(|| { let mut scheduler = SCHEDULER.lock(); // comment this out to resume normal use - scheduler.enqueue_spawn(traceloop); + // scheduler.enqueue_spawn(traceloop); scheduler.enqueue_spawn(scratchpad); }); diff --git a/ableos/src/lib.rs b/ableos/src/lib.rs index 5a6fab0a..67aa8a3d 100644 --- a/ableos/src/lib.rs +++ b/ableos/src/lib.rs @@ -70,6 +70,7 @@ pub mod allocator; pub mod channels; pub mod handle; pub mod ipc; +pub mod panic; mod unicode_utils; pub mod vga_e; @@ -81,7 +82,7 @@ pub use experiments::*; pub use graphics::*; pub use kernel; pub use kernel::messaging; -pub use kernel::panic; +// pub use kernel::panic; pub use kernel_state::*; pub use keyboard::*; pub use logger::*; diff --git a/ableos/src/panic.rs b/ableos/src/panic.rs new file mode 100644 index 00000000..725f7f3d --- /dev/null +++ b/ableos/src/panic.rs @@ -0,0 +1,11 @@ +use core::panic::PanicInfo; +use log::error; + +use crate::arch::interrupts::{bsod, BSODSource}; + +#[panic_handler] +fn panic_handler(info: &PanicInfo) -> ! { + error!("{}", info); + + bsod(BSODSource::Panic(info)); +} diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index 8c9ef336..5aa674d9 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -75,7 +75,9 @@ pub fn scratchpad() { let axel = axel::parse(axel_raw.to_string()); - software_int(); + // software_int(); + + unsafe { asm!("int 5") } // let xyz = pci::brute_force_scan(); // for dev in xyz { diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 76b07dcc..d400cccd 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -13,7 +13,7 @@ pub mod allocator; pub mod arch; pub mod device_interface; pub mod messaging; -pub mod panic; +// pub mod panic; pub mod proccess; pub mod syscalls; pub mod time; diff --git a/kernel/src/panic.rs b/kernel/src/panic.rs index 98e65030..2da2b00f 100644 --- a/kernel/src/panic.rs +++ b/kernel/src/panic.rs @@ -6,5 +6,6 @@ use log::error; #[panic_handler] fn panic_handler(info: &PanicInfo) -> ! { error!("{}", info); + loop {} }