Page 1 of 1

Keyboard handling with BIOS

Posted: Thu Aug 15, 2002 11:00 pm
by cutebomb
I write my os keyboard handling using BIOS interrupt 0x16 subfunction
0x0.But when I call the get_keystroke function,the machine reboot
immediately,and in VMware this procedure cause a triple fault.This
function post below.
   How can I handle my keyboard with BIOS?
   And is there any interrupt I should use befor I call interrupt 0x16
subfunction 0x0 to initialize the keyboard?
   Can I find some tutorial on Web?
   Any idea?
   Thanks!
/////////////////////////////////////////////
typedef unsigned short word;

word get_keystroke()
{
word _ax;
__asm__ __volatile__ ("movb $0x0,%%ah;
int $0x16;"
:"=a"(_ax));
return _ax;
}
/////////////////////////////////////////////

RE:Keyboard handling with BIOS

Posted: Thu Aug 15, 2002 11:00 pm
by carbonBased
Don't know how many times it can be said, but... you _cannot_ use the BIOS in protected mode!

Possible solutions are to run the BIOS through a vm86 task, or write a real pmode driver for it (ie, the "normal" way).

A keyboard driver is one of the easiest you'll ever write.  Check out some programming docs on the 'net.  Basically, it involves writting an ISR, and reading ports (0x60, I think... but I don't remember exactly).

Jeff

RE:Keyboard handling with BIOS

Posted: Fri Aug 16, 2002 11:00 pm
by cutebomb
I forgot to say that I still in Real Mode :)

RE:Keyboard handling with BIOS

Posted: Fri Aug 16, 2002 11:00 pm
by carbonBased
> I forgot to say that I still in Real Mode :)

Ahh, yes... that'd be a useful tidbit to know :)  I read "triple fault" and assumed pmode (imagine that! ;)

Anyway, if your code is, indeed, read mode, then you shouldn't be using GCC (which cannot produce real mode code).  And how are you booting this OS?

Jeff