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.
I am trying to detect keyboard in the protected mode.
I am able to print values that are typed using scan codes but i want to halt the system after grub if the keyboard is not present can any one help.
the error is not thrown if keyboard is unavailable.
I know this is really stupid thing to ask but am missing some thing and cant figure out what .
You want to "detect keyboard"? Well as you said, you can print characters(i assume you are accessing the video memory directly), you must have made a keyboard driver?
Do post what exactly you have done, so other can be benifited too.
You can probably safely assume that the keyboard is plugged in. If it isn't then you simply won't get any data from the keyboard when you send such things as the reset command and the like.
I'd suggest attempting to talk to the keyboard (the PS/2 protocol is heavily documented) and then if you don't get an acknowledge from the keyboard controller (or an error) then you assume that no keyboard is plugged in.
[GLOBAL keybdpre]
[bits 32]
xor eax,eax;
in al,0x60; // read from key board ctrl staus register
kbdpre:
xor eax,eax;
in al,0x64; // get port status
bt ax,1; // test bit 1 of command register to check if it is set
// and will set carry flag
jc print;
jnc areho;
print: mov ah,0x01
ret
areho: mov ah,0x00
ret
I am trying to get the value in c code and then display if the key board is present or not...
but every time its returning garbage value....
pls help
Last edited by naiksidd_85 on Mon Feb 18, 2008 5:46 am, edited 2 times in total.
HI all,
the tips that you guys gave was quite helpful but i think i messed up some where the key board is detected...
but i still need to give a input in the buffer to validate .....
I want to know how can i do that without even giving any input....
we used to send a interrupt in real mode but in Pmode am not able to figure it out as I am new to coding and not from Computers Background.
As said before - *read the PS/2 protocol documentation*. There are commands there that you can send and expect replies to (like, for example, switching the caps-lock LEDs on and off).