detecting Keyboard in P mode: how do I do it
hi everyone ,
as james told i am able to glow the led on my keyboard but then i am not able to get the keyboards reply.( basically i m tryin to detect the ps/2 keyboard i.e whether keyboard is plugged in or not)
i think the keyboard should respond with acknowledgment of [FA] but then my programme is getting into the loop and not coming out as the IBF is not detecting any data. also tell me if am on right track
as james told i am able to glow the led on my keyboard but then i am not able to get the keyboards reply.( basically i m tryin to detect the ps/2 keyboard i.e whether keyboard is plugged in or not)
Code: Select all
[GLOBAL keybdpre]
[bits 32]
keybdpre:
call kbd
mov al,0EDh ; 8048 command byte to set
out 60h,al
call kbd
; b0 is ScrollLock, b1 is NumLock, b2 is CapsLock
mov al,07h
out 60h,al
WaitLoop:
in al, 64h ; Read Status byte
and al, 10b ; Test IBF flag (Status<1>)
jz WaitLoop ; Wait for IBF = 1
;problem here does not come out as no ; value is returned by the keyboard.
in al, 60h ; Read input buffer
cmp al,0xfa
je print;
areho: mov ax,0x00
ret
print: mov ax,0x01
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
i think the keyboard should respond with acknowledgment of [FA] but then my programme is getting into the loop and not coming out as the IBF is not detecting any data. also tell me if am on right track
why don't you try reading the System Flag status bit from the Status port?
I think that shows if the self-test was OK or not.
I think that shows if the self-test was OK or not.
b2 System Flag status: 0=power-up/reset, 1=selftest OK (?)
Code: Select all
#define keyboard_status_port 0x64
#define system_flag_bit 0x04
if(inportb(keyboard_status_port) & system_flag_bit)
{printf("keyboard is on \n");}
else{printf("keyboard is either not on or disconnected \n");}
Website: https://joscor.com
- naiksidd_85
- Member
- Posts: 76
- Joined: Thu Jan 17, 2008 1:15 am
Could you give us some hint on how you did it?
It looks like all methods presented here including mine (and probably except the one posted by Osbios) may work in some machines and fail in others.
Have you tested on several machines to make sure that your method is fully reliable?
The acknowledgment from resetting the keyboard seems to fail on some PC's (maybe just needs elaborate...), reading the SYSTEM FLAG is only useful to test the whether it was properly present at POST. If it is set to 0, then RESET the keyboard, then re-read the SYSTEM FLAG, it doesn't seem to change in any of the PC's I have (4 different ones) to indicate BAT OK or BAT ERROR.
Maybe a timer using the PIT is absolutely required, as well as a keyboard interrupt and filtering out PS/2 mouse.
It looks like all methods presented here including mine (and probably except the one posted by Osbios) may work in some machines and fail in others.
Have you tested on several machines to make sure that your method is fully reliable?
The acknowledgment from resetting the keyboard seems to fail on some PC's (maybe just needs elaborate...), reading the SYSTEM FLAG is only useful to test the whether it was properly present at POST. If it is set to 0, then RESET the keyboard, then re-read the SYSTEM FLAG, it doesn't seem to change in any of the PC's I have (4 different ones) to indicate BAT OK or BAT ERROR.
Maybe a timer using the PIT is absolutely required, as well as a keyboard interrupt and filtering out PS/2 mouse.
- naiksidd_85
- Member
- Posts: 76
- Joined: Thu Jan 17, 2008 1:15 am
hi ~,
sorry for the delay in reply.
I have used the same code that is posted by crazyOS on this page as we are working together.
I will surely post the code.
according to your suggestion I am testing it on various platform when I am really sure that its working comletely fine I will post it .
And any ways you are the guys who have helped me in this . else I would have not done it
sorry for the delay in reply.
I have used the same code that is posted by crazyOS on this page as we are working together.
I will surely post the code.
according to your suggestion I am testing it on various platform when I am really sure that its working comletely fine I will post it .
And any ways you are the guys who have helped me in this . else I would have not done it
Learning a lot these days THANKS to OSdev users