From a1483ad6e16872096cf512520e2fed488d725fe8 Mon Sep 17 00:00:00 2001 From: husky Date: Tue, 19 Apr 2022 17:39:17 -0700 Subject: [PATCH] started work on the IDT --- src/internals/mod.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 27 +++++++----------------- 2 files changed, 57 insertions(+), 20 deletions(-) diff --git a/src/internals/mod.rs b/src/internals/mod.rs index f8b5fce..941ed87 100644 --- a/src/internals/mod.rs +++ b/src/internals/mod.rs @@ -1,4 +1,54 @@ pub mod WhyDoTheyCallItOvenWhenYouOfInTheColdFoodOfOutHotEatTheFood { + use core::marker::PhantomData; + + #[derive(Clone, Copy)] + pub struct Point { + pub x: i32, + pub y: i32, + } + + #[derive(Clone, Copy)] + pub struct Colour { + pub r: u8, + pub g: u8, + pub b: u8, + } + + // colours + pub const MICROSOFT_BLUE: Colour = Colour{r:30,g:129,b:176}; + pub const COMMUNIST_RED: Colour = Colour{r:245,g:77,b:30}; + pub const CUM_WHITE: Colour = Colour{r:255,g:255,b:255}; + + pub struct IDTEntry { + based_offset: u16, + code_selector: u16, + ist_offset_wastes_6_bits: u8, + attributes: u8, + mid_offset: u16, + offset_popping_off: u32, + what: PhantomData + } + + pub struct InterruptDescriptorTable { + pub divide_error: IDTEntry, + pub debug: IDTEntry, + pub dream_mask_sus_version: IDTEntry, // non-maskable interrupt + pub breakpoint: IDTEntry, + pub into_detected_overflow: IDTEntry, + pub in_the_fortnite_storm: IDTEntry, // bound range exceeded + pub owo_whats_this: IDTEntry, // invalid opcode + pub device_not_available: IDTEntry, + pub fucky_wucky_twice: IDTEntry, // double fault + we_are_all_about_backwards_compatibility: IDTEntry, // coprocessor segment overrun + pub invalid_tss: IDTEntry, + pub segment_not_present: IDTEntry, + pub stack_segment_fault: IDTEntry, + pub uh_oh_we_gotta_hacker_here: IDTEntry, // general protection fault + + } + + pub struct ErrorHandler(()); + pub enum ErrorKind { HardwareFuckUp, } diff --git a/src/main.rs b/src/main.rs index dc53459..6fa17cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ use bootloader::{entry_point, BootInfo, boot_info}; use core::panic::PanicInfo; use bootloader::boot_info::{FrameBuffer, FrameBufferInfo, PixelFormat}; +use crate::internals::WhyDoTheyCallItOvenWhenYouOfInTheColdFoodOfOutHotEatTheFood::*; use crate::serial::potential_serial_ports; mod font; @@ -11,20 +12,6 @@ mod serial; mod internals; -#[derive(Clone, Copy)] -struct Point { - x: i32, - y: i32, -} - -#[derive(Clone, Copy)] -struct Colour { - r: u8, - g: u8, - b: u8, -} - - const RAINBOW : [Colour; 6] = [Colour{r:255,g:0,b:0}, Colour{r:255,g:127,b:0}, Colour{r:255,g:255,b:0}, Colour{r:0,g:255,b:0}, Colour{r:0,g:255,b:255}, Colour{r:0,g:0,b:255}]; @@ -32,11 +19,11 @@ const RAINBOW : [Colour; 6] = [Colour{r:255,g:0,b:0}, Colour{r:255,g:127,b:0}, C #[panic_handler] fn panic(_info: &PanicInfo) -> ! { loop {} } -fn KernelPanic(msg: &str, fb: &mut FrameBuffer) { +fn KernelPanic(msg: KernelError, fb: &mut FrameBuffer) { // cover the screen in red for y in 0..fb.info().vertical_resolution { for x in 0..fb.info().horizontal_resolution { - put_pixel(x, y, Colour{r:255,g:0,b:0}, fb); + put_pixel(x, y, COMMUNIST_RED, fb); } } } @@ -171,17 +158,17 @@ fn main(boot_info: &'static mut BootInfo) -> ! { //draw_string(20,20, "),:\n\n\n\nuh oh! windows error! your computer is not compatible with windows 12\n\ncontact billgate@realmicrosoft.com to fix this issue!", Colour { r: 255, g: 255, b: 255}, framebuffer); - draw_horizcentre_string(((fb_height/2)-4)-16, "welcome to windows 12! here is info:", Colour { r: 255, g: 255, b: 255 }, framebuffer); + draw_horizcentre_string(((fb_height/2)-4)-16, "welcome to windows 12! here is info:", CUM_WHITE, framebuffer); // time for some funny com port stuff let serial_ports = serial::init_serial(); - draw_horizcentre_string(((fb_height/2)-4)-8, "serial ports:", Colour { r: 255, g: 255, b: 255 }, framebuffer); + draw_horizcentre_string(((fb_height/2)-4)-8, "serial ports:", CUM_WHITE, framebuffer); for port in 0..serial_ports.ports_enabled.len() { if serial_ports.ports_enabled[port] { - draw_horizcentre_string(((fb_height/2)-4)+(port as usize*8), serial_ports.ports[port].base.to_string(), Colour { r: 255, g: 255, b: 255 }, framebuffer); + draw_horizcentre_string(((fb_height/2)-4)+(port as usize*8), serial_ports.ports[port].base.to_string(), CUM_WHITE, framebuffer); } else { // draw in grey - draw_horizcentre_string(((fb_height/2)-4)+(port as usize*8), serial_ports.ports[port].base.to_string(), Colour { r: 255, g: 0, b: 0 }, framebuffer); + draw_horizcentre_string(((fb_height/2)-4)+(port as usize*8), serial_ports.ports[port].base.to_string(), COMMUNIST_RED, framebuffer); } }