Keyboard problem...
Keyboard problem...
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
_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
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Keyboard problem...
and does it work in real mode ?
maybe your keyboard isn't ready when you send the command, or something alike ...
maybe your keyboard isn't ready when you send the command, or something alike ...
Re:Keyboard problem...
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...
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Keyboard problem...
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 ?
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...
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...
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...
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Keyboard problem...
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...
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...
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????
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Keyboard problem...
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...
I've tried that code from that web site... it reboots my computer ???