Page 1 of 1

Keyboard problem...

Posted: Sat Oct 12, 2002 3:41 pm
by Ozguxxx
Hi everybody... The following code is not working under pmode, I do know what it is doing, i only copy pasted from a web site, it is called from a c kernel, it should turn on leds on keyboard, is there anything that we should do before controlling keyboard? I am trying to write a keyboard driver from scratch, I do not know the initialization stuff... Thanx...

_setLEDs:
   call kbd
   mov al,0EDh ; 8048 command byte to set LEDs
   out 60h,al
   call kbd
   ; b0 is ScrollLock, b1 is NumLock, b2 is CapsLock
   mov al,07h
   out 60h,al
ret


kbd0: jmp short $+2
   in al,60h
kbd: jmp short $+2
   in al,64h
   test al,1
   jnz kbd0
   test al,2
   jnz kbd
   ret   

Re:Keyboard problem...

Posted: Mon Oct 14, 2002 12:09 am
by Pype.Clicker
and does it work in real mode ?
maybe your keyboard isn't ready when you send the command, or something alike ...

Re:Keyboard problem...

Posted: Mon Oct 14, 2002 4:22 pm
by Ozguxxx
No this code is in protected mode. And you are asking me the vital question that I have been trying to answer nowadays. How do we initialize keyboard? Thanx...

Re:Keyboard problem...

Posted: Tue Oct 15, 2002 3:23 am
by Pype.Clicker
i think you get me wrong: i was asking whether the *same* code is working if executed in real mode ...
btw, i don't think the keyboard needs more initialisation than what BIOS does, but maybe another command (A20 enabling ?) left it in a state where it cannot accept new command (for instance, waiting for a status read or something alike ...)

When you say it doesn't work, does it hang or just get executed without the correct output ?

Re:Keyboard problem...

Posted: Tue Oct 15, 2002 3:04 pm
by Ozguxxx
In fact I am not quite sure if A20 is on or off, is it necessary to turn on A20 before enabling keyboard, if so why? (Am I asking too much questions? ;D) Anyway, I will check A20 line now and try new things. Thanx Pype.Clicker.

Re:Keyboard problem...

Posted: Tue Oct 15, 2002 3:08 pm
by Ozguxxx
BTW, for turning on LEDs, is it necessary for 8042 to signal an IRQ to CPU? (Is terminology usage correct?) I mean, I think IRQ1(Keyboard IRQ) is called when a key is pressed, why would it be necessary to signal an IRQ1 for turning on LEDs? If an IRQ1 is signaled to CPU then correspnding ISR will be called but then this would cause a conflict aint it? Thanks...

Re:Keyboard problem...

Posted: Wed Oct 16, 2002 2:44 am
by Pype.Clicker
AFAIK, you need no IRQ or A20 enabling before the keyboard's led can be switched on ... however, if you did something with the 8042 *before* trying to switch the led on and did it wrong, then probably your led-switching command will be ignored ... that's what i tried to explain.

Re:Keyboard problem...

Posted: Thu Oct 17, 2002 5:08 am
by Ozguxxx
OK. Now we can say that I can turn the leds of keyboard on as soon as I had got into pmode and loaded my kernel anywhere(I mean into a logical place, which does not mess everything up- for example into 0x5000) right? (no A20 or IRQ stuff is needed.) Thanx...

Re:Keyboard problem...

Posted: Thu Oct 17, 2002 3:37 pm
by Ozguxxx
When I try to turn on LEDs as soon as bootloader is loaded, it also does not work. (at address 0x07c0) I had not done anything with Keyboard, however leds are not on. Any thoughts????

Re:Keyboard problem...

Posted: Fri Oct 18, 2002 5:41 am
by Pype.Clicker
the tutorial you found on the Net was probably wrong or miss some point. as i never tried to play with the keyboard leds, i can't help you better ...

Re:Keyboard problem...

Posted: Fri Oct 18, 2002 9:01 am
by Ozguxxx
Its OK, i think i have found the problem...

Re:Keyboard problem...

Posted: Fri Oct 18, 2002 10:41 am
by Tom
I've tried that code from that web site... it reboots my computer ???

Re:Keyboard problem...

Posted: Fri Oct 18, 2002 1:21 pm
by Ozguxxx
which web site?