From 78553a3190369d102dc33b0205bd9709ae9403d6 Mon Sep 17 00:00:00 2001 From: koniifer Date: Mon, 16 Sep 2024 20:45:19 +0100 Subject: [PATCH] let's just use strings for now --- kernel/src/holeybytes/ecah.rs | 2 +- sysdata/libraries/stn/src/memory.hb | 26 +++++++++++-- sysdata/programs/ps2_driver/src/main.hb | 49 ++++++++++++------------- 3 files changed, 46 insertions(+), 31 deletions(-) diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 7075ccd..7ef5cb4 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -13,7 +13,7 @@ use { pub fn handler(vm: &mut Vm) { let ecall_number = vm.registers[2].cast::(); - log::info!("eca called :pensive:"); + // log::info!("eca called :pensive:"); // debug!("Ecall number {:?}", ecall_number); //info!("Register dump: {:?}", vm.registers); diff --git a/sysdata/libraries/stn/src/memory.hb b/sysdata/libraries/stn/src/memory.hb index bfbd39b..f9cb6df 100644 --- a/sysdata/libraries/stn/src/memory.hb +++ b/sysdata/libraries/stn/src/memory.hb @@ -17,14 +17,32 @@ release_page := fn(ptr: ^u8, page_count: u8): void { return @eca(void, 3, 2, msg, 12) } +// outb := fn(addr: u16, value: u8): void { +// msg := [u8; 5].(1, 0, @as(u8, addr & 0xFF), @as(u8, addr >> 8 & 0xFF), value) +// return @eca(void, 3, 3, &msg, 5) +// } + +// inb := fn(addr: u16): u8 { +// msg := [u8; 4].(0, 0, @as(u8, addr & 0xFF), @as(u8, addr >> 8 & 0xFF)) +// return @eca(u8, 3, 3, &msg, 4) +// } + outb := fn(addr: u16, value: u8): void { - msg := [u8; 5].(1, 0, @as(u8, addr & 0xFF), @as(u8, addr >> 8 & 0xFF), value) - return @eca(void, 3, 3, &msg, 5) + msg := "\0\0\0\0\0"; + *@as(^u8, msg) = @as(u8, 1); + *@as(^u8, msg + 1) = @as(u8, 0); + *@as(^u16, @bitcast(msg + 2)) = addr; + *@as(^u8, msg + 4) = value + @eca(void, 3, 3, msg, 5) + return } inb := fn(addr: u16): u8 { - msg := [u8; 4].(0, 0, @as(u8, addr & 0xFF), @as(u8, addr >> 8 & 0xFF)) - return @eca(u8, 3, 3, &msg, 4) + msg := "\0\0\0\0"; + *@as(^u8, msg) = @as(u8, 0); + *@as(^u8, msg + 1) = @as(u8, 0); + *@as(^u16, @bitcast(msg + 2)) = addr + return @eca(u8, 3, 3, msg, 4) } outl := fn(addr: u16, value: u32): void { diff --git a/sysdata/programs/ps2_driver/src/main.hb b/sysdata/programs/ps2_driver/src/main.hb index 040a41f..f727978 100644 --- a/sysdata/programs/ps2_driver/src/main.hb +++ b/sysdata/programs/ps2_driver/src/main.hb @@ -6,31 +6,28 @@ send_byte := fn(byte: u8): u8 { } main := fn(): int { - memory.outb(96, 238) - // memory.inb(96) - - // send_byte(238) - // log.info("PS/2 Driver Loaded\0") - // if send_byte(238) == 238 { - // log.info("PS/2 Keyboard Echoed\0") - // } - // a := 0 - // a += 1 - // if send_byte(244) == 250 { - // log.info("Enabled scanning\0") - // } - // buf := buffer.create("XKeyboard\0") - // ptr := memory.request_page(1) - // prev_input := 250 - // loop { - // input := memory.inb(96) - // if input == prev_input { - // continue - // } - // prev_input = input - // keycode_str := string.display_int(input, ptr) - // log.info(string.display_int(input, ptr)) - // buffer.send_message(keycode_str, buf) - // } + send_byte(238) + log.info("PS/2 Driver Loaded\0") + if send_byte(238) == 238 { + log.info("PS/2 Keyboard Echoed\0") + } + a := 0 + a += 1 + if send_byte(244) == 250 { + log.info("Enabled scanning\0") + } + buf := buffer.create("XKeyboard\0") + ptr := memory.request_page(1) + prev_input := 250 + loop { + input := memory.inb(96) + if input == prev_input { + continue + } + prev_input = input + keycode_str := string.display_int(input, ptr) + log.info(string.display_int(input, ptr)) + buffer.send_message(keycode_str, buf) + } return 0 } \ No newline at end of file