From a1bfd8e85fff4f16fd77d15739fd792bbf2e856c Mon Sep 17 00:00:00 2001 From: peony Date: Tue, 12 Nov 2024 22:36:43 +0100 Subject: [PATCH] Driver not work --- Cargo.lock | 22 +++++++-------- sysdata/programs/ps2_driver/src/main.hb | 37 ++++++++++++++++++------- sysdata/system_config.toml | 11 +++++--- 3 files changed, 45 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4664788..54ba9a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611cc2ae7d2e242c457e4be7f97036b8ad9ca152b499f53faf99b1ed8fc2553f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "anyhow" @@ -82,9 +82,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.1.37" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" +checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8" dependencies = [ "shlex", ] @@ -228,12 +228,12 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#b6274f3455d0545a64f2cc866b39d409e0a73427" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#0d87bf8f0977fd929af28f6cd8007b603bc974bc" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#b6274f3455d0545a64f2cc866b39d409e0a73427" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#0d87bf8f0977fd929af28f6cd8007b603bc974bc" dependencies = [ "hashbrown 0.15.1", "hbbytecode", @@ -245,7 +245,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#b6274f3455d0545a64f2cc866b39d409e0a73427" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#0d87bf8f0977fd929af28f6cd8007b603bc974bc" dependencies = [ "hbbytecode", ] @@ -675,18 +675,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", diff --git a/sysdata/programs/ps2_driver/src/main.hb b/sysdata/programs/ps2_driver/src/main.hb index 351187b..dc4bbe0 100644 --- a/sysdata/programs/ps2_driver/src/main.hb +++ b/sysdata/programs/ps2_driver/src/main.hb @@ -5,23 +5,27 @@ DeviceID := struct {value: u16} $Mouse3Button := DeviceID.(0x0) $MouseScrollwheel := DeviceID.(0x3) $Mouse5Button := DeviceID.(0x4) -$Spacesaver := DeviceID.(0xAB84) -$Keyboard122Key := DeviceID.(0xAB86) -$KeyboardJapaneseG := DeviceID.(0xAB90) -$KeyboardJapanesep := DeviceID.(0xAB91) -$KeyboardJapaneseA := DeviceID.(0xAB92) -$KeyboardNCDSun := DeviceID.(0xACA1) +$Spacesaver := DeviceID.(0x84AB) +$Keyboard122Key := DeviceID.(0x86AB) +$KeyboardJapaneseG := DeviceID.(0x90AB) +$KeyboardJapanesep := DeviceID.(0x91AB) +$KeyboardJapaneseA := DeviceID.(0x92AB) +$KeyboardNCDSun := DeviceID.(0xA1AC) $NoDevice := DeviceID.(0xFFFF) -Port := struct {exists: bool, device: DeviceID, command_queued: bool, command_queue: u8} +State := struct {value: u8} +$Recive := State.(0) +$Reboot := State.(1) + +Port := struct {exists: bool, device: DeviceID, command_queued: bool, command_queue: u8, state: State, expecting: bool, expecting_data: u8} $check_bit := fn(value: u8, bit: u8, state: u8): bool { - return value >> bit & 1 == state + return (value >> bit & 1) == state } -ports := [Port].(.(true, NoDevice, false, 0xFF), .(true, NoDevice, false, 0xFF)) +ports := [Port].(.(true, NoDevice, false, 0xFF, Reboot, false, 0x0), .(true, NoDevice, false, 0xFF, Reboot, false, 0x0)) -$initialize_controller := fn(): void { +initialize_controller := fn(): void { memory.outb(0x64, 0xAD) memory.outb(0x64, 0xA7) //Disables ports to make sure that they won't interfere with the setup process. @@ -71,9 +75,22 @@ $initialize_controller := fn(): void { } handle_input := fn(port: uint, input: u8): void { + if ports[port].state.value == Recive.value { + } else if ports[port].state.value == Reboot.value { + if input == 0xAA { + log.info("Device rebooted!\0") + ports[port].state = Recive + } else if (ports[port].device.value & 15) == 0 { + ports[port].device.value |= input + } else { + ports[port].device.value |= input << 4 + } + } } main := fn(): void { + @inline(initialize_controller) + loop { port_info := memory.inb(0x64) //Enables port 1. diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index da9cbd0..89830c9 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -34,8 +34,11 @@ resolution = "1024x768x24" # [boot.limine.ableos.modules.ps2_keyboard_driver] # path = "boot:///ps2_keyboard_driver.hbf" -[boot.limine.ableos.modules.sunset_client] -path = "boot:///sunset_client.hbf" +[boot.limine.ableos.modules.ps2_driver] +path = "boot:///ps2_driver.hbf" -[boot.limine.ableos.modules.sunset_server] -path = "boot:///sunset_server.hbf" +# [boot.limine.ableos.modules.sunset_client] +# path = "boot:///sunset_client.hbf" + +# [boot.limine.ableos.modules.sunset_server] +# path = "boot:///sunset_server.hbf"