started work on the IDT

This commit is contained in:
husky 2022-04-19 17:39:17 -07:00
parent c2533a256f
commit a1483ad6e1
Signed by: MlCROSOFT
GPG key ID: E00F7FA3381F0647
2 changed files with 57 additions and 20 deletions

View file

@ -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<F> {
based_offset: u16,
code_selector: u16,
ist_offset_wastes_6_bits: u8,
attributes: u8,
mid_offset: u16,
offset_popping_off: u32,
what: PhantomData<F>
}
pub struct InterruptDescriptorTable {
pub divide_error: IDTEntry<ErrorHandler>,
pub debug: IDTEntry<ErrorHandler>,
pub dream_mask_sus_version: IDTEntry<ErrorHandler>, // non-maskable interrupt
pub breakpoint: IDTEntry<ErrorHandler>,
pub into_detected_overflow: IDTEntry<ErrorHandler>,
pub in_the_fortnite_storm: IDTEntry<ErrorHandler>, // bound range exceeded
pub owo_whats_this: IDTEntry<ErrorHandler>, // invalid opcode
pub device_not_available: IDTEntry<ErrorHandler>,
pub fucky_wucky_twice: IDTEntry<ErrorHandler>, // double fault
we_are_all_about_backwards_compatibility: IDTEntry<ErrorHandler>, // coprocessor segment overrun
pub invalid_tss: IDTEntry<ErrorHandler>,
pub segment_not_present: IDTEntry<ErrorHandler>,
pub stack_segment_fault: IDTEntry<ErrorHandler>,
pub uh_oh_we_gotta_hacker_here: IDTEntry<ErrorHandler>, // general protection fault
}
pub struct ErrorHandler(());
pub enum ErrorKind {
HardwareFuckUp,
}

View file

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