diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index 7075ccd23..7ef5cb419 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 bfbd39b42..f9cb6df5d 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 040a41f1e..f72797822 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