mouse support added back in and premature work on asl

This commit is contained in:
able 2022-08-01 21:56:01 -05:00
parent 6ba5f35654
commit 53751a7b0b
8 changed files with 109 additions and 39 deletions

22
Cargo.lock generated
View file

@ -114,6 +114,13 @@ version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
[[package]]
name = "asl"
version = "0.1.0"
dependencies = [
"logos",
]
[[package]] [[package]]
name = "atty" name = "atty"
version = "0.2.14" version = "0.2.14"
@ -455,18 +462,18 @@ dependencies = [
[[package]] [[package]]
name = "logos" name = "logos"
version = "0.12.0" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427e2abca5be13136da9afdbf874e6b34ad9001dd70f2b103b083a85daa7b345" checksum = "bf8b031682c67a8e3d5446840f9573eb7fe26efe7ec8d195c9ac4c0647c502f1"
dependencies = [ dependencies = [
"logos-derive", "logos-derive",
] ]
[[package]] [[package]]
name = "logos-derive" name = "logos-derive"
version = "0.12.0" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56a7d287fd2ac3f75b11f19a1c8a874a7d55744bd91f7a1b3e7cf87d4343c36d" checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c"
dependencies = [ dependencies = [
"beef", "beef",
"fnv", "fnv",
@ -474,7 +481,6 @@ dependencies = [
"quote", "quote",
"regex-syntax", "regex-syntax",
"syn", "syn",
"utf8-ranges",
] ]
[[package]] [[package]]
@ -964,12 +970,6 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "utf8-ranges"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcfc827f90e53a02eaef5e535ee14266c1d569214c6aa70133a624d8a3164ba"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.4"

View file

@ -1,3 +1,11 @@
[workspace] [workspace]
members = ["ableos", "ext2-rs", "kernel", "facepalm", "shadeable", "repbuild"] members = [
"ableos",
"asl",
"ext2-rs",
"kernel",
"facepalm",
"shadeable",
"repbuild",
]

View file

@ -40,6 +40,11 @@ impl InterruptIndex {
static IDT: Lazy<InterruptDescriptorTable> = Lazy::new(|| { static IDT: Lazy<InterruptDescriptorTable> = Lazy::new(|| {
reset_pit_for_cpu(); reset_pit_for_cpu();
let mut idt = InterruptDescriptorTable::new(); let mut idt = InterruptDescriptorTable::new();
for int in 32..=255 {
idt[int].set_handler_fn(undefined_handler);
}
idt.breakpoint.set_handler_fn(breakpoint_handler); idt.breakpoint.set_handler_fn(breakpoint_handler);
unsafe { unsafe {
idt.double_fault idt.double_fault
@ -49,7 +54,7 @@ static IDT: Lazy<InterruptDescriptorTable> = Lazy::new(|| {
idt[InterruptIndex::Timer.as_usize()].set_handler_fn(timer_interrupt_handler); idt[InterruptIndex::Timer.as_usize()].set_handler_fn(timer_interrupt_handler);
idt[InterruptIndex::Keyboard.as_usize()].set_handler_fn(keyboard_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 // 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[54].set_handler_fn(software_int_handler);
@ -57,6 +62,10 @@ static IDT: Lazy<InterruptDescriptorTable> = Lazy::new(|| {
idt idt
}); });
extern "x86-interrupt" fn undefined_handler(stack_frame: InterruptStackFrame) {
error!("{:?}", stack_frame);
}
extern "x86-interrupt" fn software_int_handler(stack_frame: InterruptStackFrame) { extern "x86-interrupt" fn software_int_handler(stack_frame: InterruptStackFrame) {
trace!("EXCEPTION: SOFTWARE INT\n{:#?}", stack_frame); trace!("EXCEPTION: SOFTWARE INT\n{:#?}", stack_frame);
} }

View file

@ -3,6 +3,7 @@
use core::sync::atomic::AtomicU64; use core::sync::atomic::AtomicU64;
use crate::arch::{drivers::sysinfo::master, init, sloop}; use crate::arch::{drivers::sysinfo::master, init, sloop};
use crate::hardware;
use crate::relib::network::socket::{SimpleSock, Socket}; use crate::relib::network::socket::{SimpleSock, Socket};
use crate::{ use crate::{
boot_conf::KernelConfig, scheduler::SCHEDULER, scratchpad, systeminfo::RELEASE_TYPE, TERM, boot_conf::KernelConfig, scheduler::SCHEDULER, scratchpad, systeminfo::RELEASE_TYPE, TERM,
@ -32,10 +33,10 @@ pub fn kernel_main() -> ! {
// term.draw_term(); // term.draw_term();
// drop(term); // drop(term);
/*
x86_64::instructions::interrupts::without_interrupts(|| { x86_64::instructions::interrupts::without_interrupts(|| {
hardware::init_mouse(); hardware::init_mouse();
}); });
/*
// println!("abc"); // println!("abc");
let mut ipc_service = IPC.lock(); let mut ipc_service = IPC.lock();

View file

@ -1,4 +1,4 @@
use crate::vga_e::VGAE; use crate::{hardware::MOUSE, vga_e::VGAE};
use vga::{colors::Color16, writers::GraphicsWriter}; use vga::{colors::Color16, writers::GraphicsWriter};
const TERM_MINUS_ONE_LINE: usize = 4720; const TERM_MINUS_ONE_LINE: usize = 4720;
@ -78,33 +78,31 @@ impl Term {
let mode = VGAE.lock(); let mode = VGAE.lock();
mode.clear_screen(Color16::Black); mode.clear_screen(Color16::Black);
/* // /*
let mouse = false; const CURSOR_COLOR: Color16 = Color16::Red;
if mouse { let mouse_coord = x86_64::instructions::interrupts::without_interrupts(|| {
let mouse_coord = x86_64::instructions::interrupts::without_interrupts(|| { let cursor = MOUSE.lock();
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( 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 + 0),
(mouse_coord.0 as isize + 10, mouse_coord.1 as isize + 10), (mouse_coord.0 as isize + 10, mouse_coord.1 as isize + 10),
CURSOR_COLOR, CURSOR_COLOR,
); );
mode.draw_line( 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 + 0),
(mouse_coord.0 as isize + 5, mouse_coord.1 as isize + 0), (mouse_coord.0 as isize + 5, mouse_coord.1 as isize + 0),
CURSOR_COLOR, CURSOR_COLOR,
); );
mode.draw_line( 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 + 0),
(mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 5), (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 5),
CURSOR_COLOR, CURSOR_COLOR,
); );
}
*/
// */
let mut x = 0; let mut x = 0;
let mut y = 0; let mut y = 0;

9
asl/Cargo.toml Normal file
View file

@ -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"

View file

@ -0,0 +1,10 @@
DefinitionBlock ("test.aml", "DSDT", 1, "OEMID ", "TABLEID ", 0x00000000)
{
Scope (_SB)
{
Device (PCI0)
{
Name (_HID, EisaId ("PNP0A03"))
}
}
}

35
asl/src/lib.rs Normal file
View file

@ -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<Token>) -> isize {
let slice = lex.slice();
let num_str: String = slice.into();
let num = num_str.parse::<isize>();
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);
}
}