diff --git a/Cargo.lock b/Cargo.lock index f418e307..86bd5083 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,6 +114,13 @@ version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" +[[package]] +name = "asl" +version = "0.1.0" +dependencies = [ + "logos", +] + [[package]] name = "atty" version = "0.2.14" @@ -455,18 +462,18 @@ dependencies = [ [[package]] name = "logos" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427e2abca5be13136da9afdbf874e6b34ad9001dd70f2b103b083a85daa7b345" +checksum = "bf8b031682c67a8e3d5446840f9573eb7fe26efe7ec8d195c9ac4c0647c502f1" dependencies = [ "logos-derive", ] [[package]] name = "logos-derive" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56a7d287fd2ac3f75b11f19a1c8a874a7d55744bd91f7a1b3e7cf87d4343c36d" +checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c" dependencies = [ "beef", "fnv", @@ -474,7 +481,6 @@ dependencies = [ "quote", "regex-syntax", "syn", - "utf8-ranges", ] [[package]] @@ -964,12 +970,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" -[[package]] -name = "utf8-ranges" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcfc827f90e53a02eaef5e535ee14266c1d569214c6aa70133a624d8a3164ba" - [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index b3428625..735bcb00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,11 @@ [workspace] -members = ["ableos", "ext2-rs", "kernel", "facepalm", "shadeable", "repbuild"] +members = [ + "ableos", + "asl", + "ext2-rs", + "kernel", + "facepalm", + "shadeable", + "repbuild", +] diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index fff43e2c..5c0d80d7 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -40,6 +40,11 @@ impl InterruptIndex { static IDT: Lazy = Lazy::new(|| { reset_pit_for_cpu(); let mut idt = InterruptDescriptorTable::new(); + + for int in 32..=255 { + idt[int].set_handler_fn(undefined_handler); + } + idt.breakpoint.set_handler_fn(breakpoint_handler); unsafe { idt.double_fault @@ -49,7 +54,7 @@ static IDT: Lazy = Lazy::new(|| { idt[InterruptIndex::Timer.as_usize()].set_handler_fn(timer_interrupt_handler); idt[InterruptIndex::Keyboard.as_usize()].set_handler_fn(keyboard_interrupt_handler); - // idt[InterruptIndex::Mouse.as_usize()].set_handler_fn(crate::hardware::mouse_interrupt_handler); + idt[InterruptIndex::Mouse.as_usize()].set_handler_fn(crate::hardware::mouse_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); @@ -57,6 +62,10 @@ static IDT: Lazy = Lazy::new(|| { idt }); +extern "x86-interrupt" fn undefined_handler(stack_frame: InterruptStackFrame) { + error!("{:?}", stack_frame); +} + extern "x86-interrupt" fn software_int_handler(stack_frame: InterruptStackFrame) { trace!("EXCEPTION: SOFTWARE INT\n{:#?}", stack_frame); } diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index c6193a7b..195ed833 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -3,6 +3,7 @@ use core::sync::atomic::AtomicU64; use crate::arch::{drivers::sysinfo::master, init, sloop}; +use crate::hardware; use crate::relib::network::socket::{SimpleSock, Socket}; use crate::{ boot_conf::KernelConfig, scheduler::SCHEDULER, scratchpad, systeminfo::RELEASE_TYPE, TERM, @@ -32,10 +33,10 @@ pub fn kernel_main() -> ! { // term.draw_term(); // drop(term); - /* x86_64::instructions::interrupts::without_interrupts(|| { hardware::init_mouse(); }); + /* // println!("abc"); let mut ipc_service = IPC.lock(); diff --git a/ableos/src/vterm.rs b/ableos/src/vterm.rs index cbaf1103..32f49aab 100644 --- a/ableos/src/vterm.rs +++ b/ableos/src/vterm.rs @@ -1,4 +1,4 @@ -use crate::vga_e::VGAE; +use crate::{hardware::MOUSE, vga_e::VGAE}; use vga::{colors::Color16, writers::GraphicsWriter}; const TERM_MINUS_ONE_LINE: usize = 4720; @@ -78,33 +78,31 @@ impl Term { let mode = VGAE.lock(); mode.clear_screen(Color16::Black); - /* - let mouse = false; - if mouse { - let mouse_coord = x86_64::instructions::interrupts::without_interrupts(|| { - let cursor = MOUSE.lock(); + // /* + const CURSOR_COLOR: Color16 = Color16::Red; + let mouse_coord = x86_64::instructions::interrupts::without_interrupts(|| { + let cursor = MOUSE.lock(); - (cursor.get_x() as usize, cursor.get_y() as usize) - }); + (cursor.get_x() as usize, cursor.get_y() as usize) + }); - mode.draw_line( - (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 0), - (mouse_coord.0 as isize + 10, mouse_coord.1 as isize + 10), - CURSOR_COLOR, - ); - mode.draw_line( - (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 0), - (mouse_coord.0 as isize + 5, mouse_coord.1 as isize + 0), - CURSOR_COLOR, - ); - mode.draw_line( - (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 0), - (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 5), - CURSOR_COLOR, - ); - } - */ + mode.draw_line( + (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 0), + (mouse_coord.0 as isize + 10, mouse_coord.1 as isize + 10), + CURSOR_COLOR, + ); + mode.draw_line( + (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 0), + (mouse_coord.0 as isize + 5, mouse_coord.1 as isize + 0), + CURSOR_COLOR, + ); + mode.draw_line( + (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 0), + (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 5), + CURSOR_COLOR, + ); + // */ let mut x = 0; let mut y = 0; diff --git a/asl/Cargo.toml b/asl/Cargo.toml new file mode 100644 index 00000000..7004b189 --- /dev/null +++ b/asl/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "asl" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +logos = "0.12.1" diff --git a/asl/assets/asl/asl_simple.asl b/asl/assets/asl/asl_simple.asl new file mode 100644 index 00000000..7d18aa51 --- /dev/null +++ b/asl/assets/asl/asl_simple.asl @@ -0,0 +1,10 @@ +DefinitionBlock ("test.aml", "DSDT", 1, "OEMID ", "TABLEID ", 0x00000000) +{ + Scope (_SB) + { + Device (PCI0) + { + Name (_HID, EisaId ("PNP0A03")) + } + } +} \ No newline at end of file diff --git a/asl/src/lib.rs b/asl/src/lib.rs new file mode 100644 index 00000000..da057100 --- /dev/null +++ b/asl/src/lib.rs @@ -0,0 +1,35 @@ +use logos::{Lexer, Logos}; + +#[derive(Logos, Debug, Clone, Copy, PartialEq)] +enum Token { + #[regex(r"[ \t\n\f]+", logos::skip)] + #[error] + Error, + + #[regex("[1-9]+", num_parser)] + Num(isize), +} +fn num_parser(lex: &mut Lexer) -> isize { + let slice = lex.slice(); + let num_str: String = slice.into(); + let num = num_str.parse::(); + num.unwrap() +} + +#[test] +pub fn num_test() { + let mut lex = Token::lexer("5 42 75"); + assert_eq!(lex.next(), Some(Token::Num(5))); + assert_eq!(lex.next(), Some(Token::Num(42))); + assert_eq!(lex.next(), Some(Token::Num(75))); +} + +#[test] +pub fn asl_simple_test() { + let lex = Token::lexer(include_str!("../assets/asl/asl_simple.asl")); + + for token in lex { + // println!("{:?}", token); + assert_ne!(Token::Error, token); + } +}