PS/2 driver going well (it still doesn't work)
This commit is contained in:
parent
98b15d4c10
commit
11976b752f
|
@ -1,35 +1,52 @@
|
|||
.{memory, log} := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{bit5} := @use("bits.hb")
|
||||
.{bit0, bit5} := @use("bits.hb")
|
||||
|
||||
init := fn(): void {
|
||||
memory.outb(0x64, 0xAD)
|
||||
memory.outb(0x64, 0xA7)
|
||||
//Disables ports to make sure that they won't interfere with the setup process.
|
||||
$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)
|
||||
|
||||
loop if (memory.inb(0x64) & 1) == 0 break else memory.inb(0x60)
|
||||
//Flushes any output because apperantly that might interfere with stuff.
|
||||
//TODO test functions
|
||||
/*test_port1 := fn(): bool {
|
||||
|
||||
memory.outb(0x64, 0xA8)
|
||||
//Enables port 2.
|
||||
}*/
|
||||
|
||||
get_config_byte := fn(): u8 {
|
||||
memory.outb(0x64, 0x20)
|
||||
//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 has_input(get_info()) break
|
||||
return memory.inb(0x60)
|
||||
}
|
||||
|
||||
loop if (memory.inb(0x64) & 1) == 0 break else memory.inb(0x60)
|
||||
//Flushes any output because apperantly that might interfere with stuff.
|
||||
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 {
|
||||
disable_port1()
|
||||
disable_port2()
|
||||
//Disables ports to make sure that they won't interfere with the setup process.
|
||||
|
||||
flush_input()
|
||||
|
||||
enable_port2()
|
||||
ports[1].exists = bit5(@inline(get_config_byte)) == false
|
||||
disable_port2()
|
||||
|
||||
flush_input()
|
||||
|
||||
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
|
||||
//Test port 1.
|
||||
|
||||
if ports[1].exists {
|
||||
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
|
||||
}
|
||||
//Test port 2.
|
||||
|
@ -40,14 +57,12 @@ init := fn(): void {
|
|||
|
||||
if ports[0].exists {
|
||||
log.info("Port 1 exists.\0")
|
||||
memory.outb(0x64, 0xAE)
|
||||
//Enables port 1.
|
||||
enable_port1()
|
||||
ports[0].commands_queued = 1
|
||||
}
|
||||
if ports[1].exists {
|
||||
log.info("Port 2 exists.\0")
|
||||
memory.outb(0x64, 0xA8)
|
||||
//Enables port 2.
|
||||
enable_port2()
|
||||
ports[1].commands_queued = 1
|
||||
}
|
||||
}
|
12
sysdata/programs/ps2_driver/src/devices.hb
Normal file
12
sysdata/programs/ps2_driver/src/devices.hb
Normal 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)
|
|
@ -1,3 +1,5 @@
|
|||
.{DeviceID} := @use("devices.hb")
|
||||
|
||||
Port := struct {
|
||||
exists: bool
|
||||
device: DeviceID
|
||||
|
|
Loading…
Reference in a new issue