Reading the keyboard from port 0x60

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Reading the keyboard from port 0x60

Post 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.
Attachments
kbd_noint.asm
Interrupt-free keyboard driver that boots.
(896 Bytes) Downloaded 74 times
Last edited by Troy Martin on Mon Sep 01, 2008 5:00 pm, edited 1 time in total.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: Reading the keyboard from port 0x60

Post by piranha »

...maybe telling us what the problem is might help.... :wink:

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Reading the keyboard from port 0x60

Post 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.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Reading the keyboard from port 0x60

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Reading the keyboard from port 0x60

Post 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.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
Post Reply