Page 1 of 1

Reading the keyboard from port 0x60

Posted: Mon Sep 01, 2008 4:10 pm
by Troy Martin
I'm having a problem reading keys from I/O port 0x60. I'm not sure where the problem is since I don't use an emulator with a debugger.

I'm using Geezer's read_kbd code to grab scancodes, and my own little bootloader to get everything else done. My intention is to be able to write a small keyboard driver that can grab all alphabetic keys in less than 510 bytes.

EDIT: I'm pretty sure the problem is in the reading of the keyboard.

Attached is the assembly code, 16-bit, and it boots.

Re: Reading the keyboard from port 0x60

Posted: Mon Sep 01, 2008 4:40 pm
by piranha
...maybe telling us what the problem is might help.... :wink:

-JL

Re: Reading the keyboard from port 0x60

Posted: Mon Sep 01, 2008 4:47 pm
by Troy Martin
Heh, right.

I did some extra testing by doing "mov 00h, al out 64h, al" on .r. Didn't work, so now I know that the reading of the keyboard is the problem.

Re: Reading the keyboard from port 0x60

Posted: Mon Sep 01, 2008 5:44 pm
by Brendan
Hi,

The problem is that the BIOS has it's own keyboard handling IRQ (when a key is pressed IRQ 1 occurs and the BIOS probably gets the scancode before you can).

Have you considered just using the BIOS functions? I can guarantee that it won't have all the bugs that your code does (you'd need to handle make codes, break codes and extended codes, but currently just assume everything is a make code).

I'd also assume that a simple BIOS function call will fit in 510 bytes easier; and to be honest you've got nothing to lose because your code relies on the BIOS's keyboard controller initialization, the BIOS's keyboard detection, and (potentially) the BIOS's "PS/2 keyboard emulation for USB keyboards" SMM code.


Cheers,

Brendan

Re: Reading the keyboard from port 0x60

Posted: Mon Sep 01, 2008 6:13 pm
by Troy Martin
Hey,

I'm going to pmode, that's why I need to lose the interrupts.

Also, I threw in a CLI at the start, after the data segment setup, and everything works now.