Litrally almost functional PS/2 driver. #19

Open
peony wants to merge 32 commits from peony/ableos:master into master
3 changed files with 45 additions and 25 deletions
Showing only changes of commit a1bfd8e85f - Show all commits

22
Cargo.lock generated
View file

@ -13,9 +13,9 @@ dependencies = [
[[package]] [[package]]
name = "allocator-api2" name = "allocator-api2"
version = "0.2.19" version = "0.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "611cc2ae7d2e242c457e4be7f97036b8ad9ca152b499f53faf99b1ed8fc2553f" checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9"
[[package]] [[package]]
name = "anyhow" name = "anyhow"
@ -82,9 +82,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.1.37" version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8"
dependencies = [ dependencies = [
"shlex", "shlex",
] ]
@ -228,12 +228,12 @@ dependencies = [
[[package]] [[package]]
name = "hbbytecode" name = "hbbytecode"
version = "0.1.0" 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]] [[package]]
name = "hblang" name = "hblang"
version = "0.1.0" 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 = [ dependencies = [
"hashbrown 0.15.1", "hashbrown 0.15.1",
"hbbytecode", "hbbytecode",
@ -245,7 +245,7 @@ dependencies = [
[[package]] [[package]]
name = "hbvm" name = "hbvm"
version = "0.1.0" 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 = [ dependencies = [
"hbbytecode", "hbbytecode",
] ]
@ -675,18 +675,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.214" version = "1.0.215"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.214" version = "1.0.215"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -5,23 +5,27 @@ DeviceID := struct {value: u16}
$Mouse3Button := DeviceID.(0x0) $Mouse3Button := DeviceID.(0x0)
$MouseScrollwheel := DeviceID.(0x3) $MouseScrollwheel := DeviceID.(0x3)
$Mouse5Button := DeviceID.(0x4) $Mouse5Button := DeviceID.(0x4)
$Spacesaver := DeviceID.(0xAB84) $Spacesaver := DeviceID.(0x84AB)
$Keyboard122Key := DeviceID.(0xAB86) $Keyboard122Key := DeviceID.(0x86AB)
$KeyboardJapaneseG := DeviceID.(0xAB90) $KeyboardJapaneseG := DeviceID.(0x90AB)
$KeyboardJapanesep := DeviceID.(0xAB91) $KeyboardJapanesep := DeviceID.(0x91AB)
$KeyboardJapaneseA := DeviceID.(0xAB92) $KeyboardJapaneseA := DeviceID.(0x92AB)
$KeyboardNCDSun := DeviceID.(0xACA1) $KeyboardNCDSun := DeviceID.(0xA1AC)
$NoDevice := DeviceID.(0xFFFF) $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 { $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, 0xAD)
memory.outb(0x64, 0xA7) memory.outb(0x64, 0xA7)
//Disables ports to make sure that they won't interfere with the setup process. //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 { 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 { main := fn(): void {
@inline(initialize_controller)
loop { loop {
port_info := memory.inb(0x64) port_info := memory.inb(0x64)
//Enables port 1. //Enables port 1.

View file

@ -34,8 +34,11 @@ resolution = "1024x768x24"
# [boot.limine.ableos.modules.ps2_keyboard_driver] # [boot.limine.ableos.modules.ps2_keyboard_driver]
# path = "boot:///ps2_keyboard_driver.hbf" # path = "boot:///ps2_keyboard_driver.hbf"
[boot.limine.ableos.modules.sunset_client] [boot.limine.ableos.modules.ps2_driver]
path = "boot:///sunset_client.hbf" path = "boot:///ps2_driver.hbf"
[boot.limine.ableos.modules.sunset_server] # [boot.limine.ableos.modules.sunset_client]
path = "boot:///sunset_server.hbf" # path = "boot:///sunset_client.hbf"
# [boot.limine.ableos.modules.sunset_server]
# path = "boot:///sunset_server.hbf"