Page 1 of 1
Keyboard driver
Posted: Wed Mar 16, 2011 11:38 am
by Karlosoft
My keyboard driver works on my newer pc, but when I try it on my old laptop (It was new in 1996) it doesn't work.
Code: Select all
void keyboard_handler(struct regs *r)
{
unsigned char scancode;
scancode = System->inportb(0x60);
if (scancode & 0x80)
{
}
else
{
System->putc(kbdus[scancode]);
}
}
extern "C" void start(){
System->irqInstall(1, keyboard_handler);
System->print_pass("PS/2 Keyboard driver", "enabled", 0);
return;
}
What is wrong O.O?
Re: Keyboard driver
Posted: Wed Mar 16, 2011 12:33 pm
by neon
Hello,
Define "doesn't work". Please describe what the intent of the software is, what it is doing (or not doing) on your machine, and what debugging steps you have already taken.
Re: Keyboard driver
Posted: Wed Mar 16, 2011 1:53 pm
by DLBuunk
So it is working on a new computer, but fails on an old laptop. This seems like a KBC problem, not an IRQ one, you might want to post the setup part of the keyboard driver. Seeing your code, you haven't taken the KBC out of emulation mode, you might want to look at the contents of the controller command byte and see if you like it's contents. Oh, and if you get nothing at all, it might be that the keyboard is locked.
For more info about keyboard programming, this
http://www.win.tue.nl/~aeb/linux/kbd/scancodes.html is a good resource. (of course, it is also listed at the wiki)
Re: Keyboard driver
Posted: Wed Mar 16, 2011 4:09 pm
by Karlosoft
This piece of code is a driver loaded by the kernel. In the first machine, where it works, it is installed a general irq handler for line 1 which read the code in the keyboard register and than it translate it in ascii. Eventually it displays it on the screen (the function putc works I'm sure).
On the old laptop irq1 never fires...
Perhaps on old machines have I to send some commands to the keyboard before using it?
Re: Keyboard driver
Posted: Wed Mar 16, 2011 5:16 pm
by DLBuunk
Karlosoft wrote:
Perhaps on old machines have I to send some commands to the keyboard before using it?
Yes, that is what i think is happening, the state in which the BIOS leaves the keyboard can be anything, and with old laptops such a state can be, hmm, rather, hmm, funny. So, try to find out what the state is in which the laptop-BIOS leaves the keyboard, and think up a good init-sequence.
Re: Keyboard driver
Posted: Wed Mar 16, 2011 7:41 pm
by Chandra
You may also want to try sending the Reset signal to the keyboard and see if the keyboard responds with the ACK byte(0xFA).
There are lots of commands from which you can track if the keyboard is responding or not. If the keyboard is not responding, reinitialize the keyboard port/controller and try again.
Good Luck.
Re: Keyboard driver
Posted: Thu Mar 17, 2011 5:41 am
by Karlosoft
Isn't 0xfe the system reset command? However now it works sometimes -.-... I added the 0xae command to enable the keyboard. On the other computer it always works...
It's not a problem of the irq I'm sure because the timer handler and the serial port handler are working well.
Re: Keyboard driver
Posted: Thu Mar 17, 2011 9:47 am
by Karlosoft
It seems to work when I don't leave the keyboard buffer of the bios empty O.O... ok I'm going to take a break, or I'll start speaking in a sort of keyboard scancode language -.-...