1
0
Fork 0
forked from AbleOS/ableos

PS/2 driver going well (it still doesn't work)

This commit is contained in:
peony 2024-11-16 22:56:00 +01:00
parent 98b15d4c10
commit 11976b752f
3 changed files with 51 additions and 22 deletions

View file

@ -1,35 +1,52 @@
.{memory, log} := @use("../../../libraries/stn/src/lib.hb"); .{memory, log} := @use("../../../libraries/stn/src/lib.hb");
.{bit5} := @use("bits.hb") .{bit0, bit5} := @use("bits.hb")
$disable_port1 := fn(): void memory.outb(0x64, 0xAD)
$enable_port1 := fn(): void memory.outb(0x64, 0xAE)
$disable_port2 := fn(): void memory.outb(0x64, 0xA7)
$enable_port2 := fn(): void memory.outb(0x64, 0xA8)
//TODO test functions
/*test_port1 := fn(): bool {
}*/
get_config_byte := fn(): u8 {
memory.outb(0x64, 0x20)
loop if has_input(get_info()) break
return memory.inb(0x60)
}
Info := struct {d: u8}
$get_info := fn(): u8 return .(memory.inb(0x64))
$has_input := fn(info: Info): bool return bit0(info.d)
flush_input := fn(): void {
loop if has_input(get_info()) == false break else memory.inb(0x60)
}
init := fn(): void { init := fn(): void {
memory.outb(0x64, 0xAD) disable_port1()
memory.outb(0x64, 0xA7) disable_port2()
//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.
loop if (memory.inb(0x64) & 1) == 0 break else memory.inb(0x60) flush_input()
//Flushes any output because apperantly that might interfere with stuff.
memory.outb(0x64, 0xA8) enable_port2()
//Enables port 2. ports[1].exists = bit5(@inline(get_config_byte)) == false
memory.outb(0x64, 0x20) disable_port2()
//Gimme configuration byte.
loop if (memory.inb(0x64) & 1) == 1 break
ports[1].exists = bit5(memory.inb(0x60)) == false
if ports[1].exists {
memory.outb(0x64, 0xA7)
}
loop if (memory.inb(0x64) & 1) == 0 break else memory.inb(0x60) flush_input()
//Flushes any output because apperantly that might interfere with stuff.
memory.outb(0x64, 0xAB) memory.outb(0x64, 0xAB)
loop if (memory.inb(0x64) & 1) == 1 break loop if has_input(get_info()) break
ports[0].exists = memory.inb(0x60) == 0x0 ports[0].exists = memory.inb(0x60) == 0x0
//Test port 1. //Test port 1.
if ports[1].exists { if ports[1].exists {
memory.outb(0x64, 0xA9) memory.outb(0x64, 0xA9)
loop if (memory.inb(0x64) & 1) == 1 break loop if has_input(get_info()) break
ports[1].exists = memory.inb(0x60) == 0x0 ports[1].exists = memory.inb(0x60) == 0x0
} }
//Test port 2. //Test port 2.
@ -40,14 +57,12 @@ init := fn(): void {
if ports[0].exists { if ports[0].exists {
log.info("Port 1 exists.\0") log.info("Port 1 exists.\0")
memory.outb(0x64, 0xAE) enable_port1()
//Enables port 1.
ports[0].commands_queued = 1 ports[0].commands_queued = 1
} }
if ports[1].exists { if ports[1].exists {
log.info("Port 2 exists.\0") log.info("Port 2 exists.\0")
memory.outb(0x64, 0xA8) enable_port2()
//Enables port 2.
ports[1].commands_queued = 1 ports[1].commands_queued = 1
} }
} }

View file

@ -0,0 +1,12 @@
DeviceID := struct {value: u16}
$Mouse3Button := DeviceID.(0x0)
$MouseScrollwheel := DeviceID.(0x3)
$Mouse5Button := DeviceID.(0x4)
$Spacesaver := DeviceID.(0x84AB)
$Keyboard122Key := DeviceID.(0x86AB)
$KeyboardJapaneseG := DeviceID.(0x90AB)
$KeyboardJapanesep := DeviceID.(0x91AB)
$KeyboardJapaneseA := DeviceID.(0x92AB)
$KeyboardNCDSun := DeviceID.(0xA1AC)
$NoDevice := DeviceID.(0xFFFF)

View file

@ -1,3 +1,5 @@
.{DeviceID} := @use("devices.hb")
Port := struct { Port := struct {
exists: bool exists: bool
device: DeviceID device: DeviceID