Keyboard problem...

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
Ozguxxx

Keyboard problem...

Post 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   
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Keyboard problem...

Post by Pype.Clicker »

and does it work in real mode ?
maybe your keyboard isn't ready when you send the command, or something alike ...
Ozguxxx

Re:Keyboard problem...

Post 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...
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Keyboard problem...

Post 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 ?
Ozguxxx

Re:Keyboard problem...

Post 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.
Ozguxxx

Re:Keyboard problem...

Post 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...
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Keyboard problem...

Post 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.
Ozguxxx

Re:Keyboard problem...

Post 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...
Ozguxxx

Re:Keyboard problem...

Post 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????
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Keyboard problem...

Post 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 ...
Ozguxxx

Re:Keyboard problem...

Post by Ozguxxx »

Its OK, i think i have found the problem...
Tom

Re:Keyboard problem...

Post by Tom »

I've tried that code from that web site... it reboots my computer ???
Ozguxxx

Re:Keyboard problem...

Post by Ozguxxx »

which web site?
Post Reply