diff --git a/sysdata/libraries/stn/src/buffer.hb b/sysdata/libraries/stn/src/buffer.hb index 1f5bb17..f6e6779 100644 --- a/sysdata/libraries/stn/src/buffer.hb +++ b/sysdata/libraries/stn/src/buffer.hb @@ -4,9 +4,7 @@ receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u return @eca(^u8, 4, buffer_id, memory_map_location, length) } -send_message := fn(buffer_id: int): void { - message := "Hello there\0" - message_length := string.length(message) +send_message := fn(buffer_id: int, message: ^u8, message_length: int): void { @eca(i32, 3, buffer_id, message, message_length) return } diff --git a/sysdata/programs/ps2_driver/meta.toml b/sysdata/programs/ps2_driver/meta.toml new file mode 100644 index 0000000..0a2d770 --- /dev/null +++ b/sysdata/programs/ps2_driver/meta.toml @@ -0,0 +1,11 @@ +[package] +name = "ps2_driver" +authors = ["Talha Qamar"] + +[dependants.libraries] + +[dependants.binaries] +hblang.version = "1.0.0" + +[build] +command = "hblang src/main.hb" diff --git a/sysdata/programs/ps2_driver/src/main.hb b/sysdata/programs/ps2_driver/src/main.hb index b5b3a7e..3f09a8e 100644 --- a/sysdata/programs/ps2_driver/src/main.hb +++ b/sysdata/programs/ps2_driver/src/main.hb @@ -1,2 +1,31 @@ -main:= fn(): int { +.{memory, log, string, buffer} := @use("../../../libraries/stn/src/lib.hb") + +send_byte := fn(byte: u8): u8 { + memory.outb(0, 96, byte) + input := memory.inb(0, 96) + return input } + +main := fn(): int { + log.info("PS/2 Driver Loaded\0") + if send_byte(238) == 238 { + log.info("PS/2 Keyboard Echoed\0") + } + if send_byte(244) == 250 { + log.info("Enabled scanning\0") + } + buf := buffer.create() + ptr := memory.request_page(1) + prev_input := 250 + loop { + input := memory.inb(0, 96) + if input == prev_input { + continue + } + prev_input = input + keycode_str := string.display_int(input, ptr) + log.info(string.display_int(buf)) + buffer.send_message(buf, keycode_str, string.length(keycode_str)) + } + return 0 +} \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index f0539ef..b9668e4 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -22,6 +22,8 @@ resolution = "1024x768x24" [boot.limine.ableos.modules.a_serial_driver] path = "boot:///a_serial_driver.hbf" +[boot.limine.ableos.modules.ps2_driver] + path = "boot:///ps2_driver.hbf" [boot.limine.ableos.modules.diskio_driver] path = "boot:///diskio_driver.hbf"