From 48f0ef96996329038f99c81abbfe8d5f32c4a81b Mon Sep 17 00:00:00 2001 From: able Date: Fri, 29 Jul 2022 11:51:54 -0500 Subject: [PATCH] various bugs added --- ableos/src/arch/x86_64/interrupts.rs | 102 +++++++++++++++------------ ableos/src/kmain.rs | 4 +- ableos/src/logger.rs | 1 + ableos/src/scratchpad.rs | 4 ++ kernel/src/lib.rs | 10 ++- qrcode-rust/Cargo.toml | 21 ------ 6 files changed, 73 insertions(+), 69 deletions(-) diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index 7538c28..d74e96f 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -57,23 +57,27 @@ static IDT: Lazy = Lazy::new(|| { idt[6].set_handler_fn(floppy_disk_interrupt_handler); + // run `a + b + l + e + o + s print;` in ablescript and its 54 thats why this seemingly arbitrary number was chosen + idt[54].set_handler_fn(software_int_handler); idt }); +extern "x86-interrupt" fn software_int_handler(stack_frame: InterruptStackFrame) { + println!("EXCEPTION: SOFTWARE INT\n{:#?}", stack_frame); +} + extern "x86-interrupt" fn breakpoint_handler(stack_frame: InterruptStackFrame) { println!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame); } extern "x86-interrupt" fn double_fault_handler( stack_frame: InterruptStackFrame, - error_code: u64, + // NOTE(able): ignore this always is 0 + _error_code: u64, ) -> ! { - bsod(&stack_frame, error_code); + bsod(&stack_frame, BSODSource::DoubleFault); - panic!( - "EXCEPTION: Error code{}\nDOUBLE FAULT\n{:#?}", - error_code, stack_frame - ); + panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame); } #[naked] @@ -195,7 +199,7 @@ pub fn reset_pit_for_cpu() { set_pit_3(1000); } -fn bsod(stack_frame: &InterruptStackFrame, error_code: u64) { +fn bsod(stack_frame: &InterruptStackFrame, src: BSODSource) { let mut mode = SCREEN_BUFFER.lock(); mode.force_redraw(); @@ -206,44 +210,15 @@ fn bsod(stack_frame: &InterruptStackFrame, error_code: u64) { } let mut x = 1; - let mut y = 1; + let mut y = 0; - let sf = format!("DF"); + let st = format!( + "We fucked up ඞ : {:?}\nThe following qr code will link you to the\nwiki which hopefully solves your problems", + src + ); - let code = QrCode::new("DOUBLE FAULT").unwrap(); - // let image = code - // .render::() - // .dark_color(unicode::Dense1x2::Light) - // .light_color(unicode::Dense1x2::Dark) - // .build(); - - let image = code - .render::() - .quiet_zone(false) - .module_dimensions(2, 1) - .build(); - - // let st = image; - let st = format!("We fucked up ඞ\n{:#?}", stack_frame); - - for current in image.chars() { - x += 1; - if current == '\n' { - trace!("{}", y); - y += 1; - x = 1; - } else { - if current == '█' { - mode.draw_filled_rect(x * 6, y * 6, (x * 6) + 6, (y * 6) + 6, 0xffff0000); - } - } - } - let mut x = 0; - let mut y = 6; for current in st.chars() { - x += 1; if current == '\n' { - trace!("{}", y); y += 1; x = 1; } else { @@ -253,12 +228,49 @@ fn bsod(stack_frame: &InterruptStackFrame, error_code: u64) { current, 0xffff0000, ); - - // if current == '█' { - // mode.draw_filled_rect(x * 4, y * 4, (x * 4) + 4, (y * 4) + 4, 0xffff0000); - // } } + x += 1; + } + + let mut x = 1; + let mut y = 11; + + // 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", + }; + + let code = QrCode::new(sd).unwrap(); + + let image = code + .render::() + .quiet_zone(false) + .module_dimensions(2, 1) + .build(); + + for current in image.chars() { + if current == '\n' { + 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); + } + } + } + x += 1; } mode.copy_to_buffer(); } + +#[derive(Debug)] +pub enum BSODSource { + DoubleFault, +} diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index bae6941..ca22b2c 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -49,10 +49,9 @@ 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(scratchpad); }); @@ -60,6 +59,7 @@ pub fn kernel_main() -> ! { } pub fn traceloop() { + // TODO: Having an empty function double faults // let mut last_time = 0.0; /* diff --git a/ableos/src/logger.rs b/ableos/src/logger.rs index 2482dd8..b85301e 100644 --- a/ableos/src/logger.rs +++ b/ableos/src/logger.rs @@ -47,6 +47,7 @@ impl log::Log for SimpleLogger { ); } /* + TODO: Get a proper socket from IPC instead of this deprecated method let log_socket_id = SimpleSock::grab_socket("Logger".to_string()); match log_socket_id { Some(mut log_socket_id) => { diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index 1b0a702..8c9ef33 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -23,6 +23,7 @@ use ext2::sys::inode; use genfs::OpenOptions; use genfs::{DirEntry, Fs}; use kernel::proccess::PID; +use kernel::software_int; use vga::writers::GraphicsWriter; // TODO: move to a better place @@ -71,8 +72,11 @@ pub fn scratchpad() { print: (None) -> (None); foo: (None) -> (Num); }"; + let axel = axel::parse(axel_raw.to_string()); + software_int(); + // let xyz = pci::brute_force_scan(); // for dev in xyz { // trace!("{:?}", dev); diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 3cbadca..76b07dc 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -18,7 +18,10 @@ pub mod proccess; pub mod syscalls; pub mod time; -use core::sync::atomic::{AtomicU64, Ordering::Relaxed}; +use core::{ + arch::asm, + sync::atomic::{AtomicU64, Ordering::Relaxed}, +}; use versioning::Version; /// The number of ticks since the first CPU was started @@ -38,3 +41,8 @@ pub fn tick() { TICK.store(data, Relaxed) } + +/// Cause a software interrupt +pub fn software_int() { + unsafe { asm!("int 54") } +} diff --git a/qrcode-rust/Cargo.toml b/qrcode-rust/Cargo.toml index 4a33b82..f442da3 100644 --- a/qrcode-rust/Cargo.toml +++ b/qrcode-rust/Cargo.toml @@ -6,17 +6,7 @@ version = "0.12.0" edition = "2018" authors = ["kennytm "] keywords = ["qrcode"] -repository = "https://github.com/kennytm/qrcode-rust" -readme = "README.md" -documentation = "http://docs.rs/qrcode" -exclude = [".travis.yml", ".gitignore", "test-data/**"] -[badges] -travis-ci = { repository = "kennytm/qrcode-rust" } -coveralls = { repository = "kennytm/qrcode-rust" } -is-it-maintained-issue-resolution = { repository = "kennytm/qrcode-rust" } -is-it-maintained-open-issues = { repository = "kennytm/qrcode-rust" } -maintenance = { status = "passively-maintained" } [dependencies] # checked_int_cast = "1" @@ -29,14 +19,3 @@ svg = [] [[bin]] name = "qrencode" - -[[example]] -name = "encode_image" -required-features = ["image"] - -[[example]] -name = "encode_string" - -[[example]] -name = "encode_svg" -required-features = ["svg"]