ExpertCentral.coman About company
Your Search is Over!
Expert Home Sign Up My ExpertCentral Answer Library Help
Search for Experts in 
View question by Expert saintly
Question History!
From : jeffhill
To : saintly
User Comment :
This was horribly embarassing. I must have been under the influence of heavy narcotics at the time I wrote the first answer, because the same thing occurred to me after I said it. :( I hang my head in shame. And of course, you don't have to work in assembler either. You can also test the ports with a C application.
Rating :
Message Status : Public

[08-09-2000] jeffhill : Hello,

I am trying to find out how to access the status of the keyboard lock that is present in many pc's. I am writing a Linux application and I need the extra security of a physical key (not those stupid little round ones, but an actual key). I have determined that the keyboard lock is not simply switching the clock or data lines for the keyboard, as the keyboard will function normally with the switch disconnected from the motherboard. I have two good references for the pc (Undocumented PC - Gilluwe, and The Indespensible Hardware Handbook - Messmer) and the information that I seek is not there. I need my software written in C to be able to determine the status of the keyboard lock. I am assuming there is a port I can read. Do you have any idea how this can be accomplished?

Jeff Hill
[08-09-2000] saintly : The keyboard-lock switch on your PC (the one that connects to a jumper on the motherboard) is NOT designed to be software readable. It is a brainless jumper connector; when the key is in the closed/locked position, the jumper is closed (you could just put a regular jumper across it to lock up the keyboard too if you like). The keyboard controller in BIOS checks this and ignores any keyboard input if the jumper is closed. All the BIOS keyboard-reading services act like there is no keyboard input.

If you need physical security, your best bet is to purchase a commercial package. The most secure ones I've seen use a token (a "smartcard") in combination with a password or PIN. The user must have both the physical card and the PIN to log in (or whatever).

http://www.westcoast.com/securecomputing/1999_02/cover/cover.html
http://www.ie.ibm.com/news/ie151199.html

Or if you want to use the keyboard lock on the front of the computer and a physical key, I would probably try to cut the jumper end off, strip the wires a bit and wire it to pins on an unused IO port. Then you might be able to check the status of the IO port to see whether the kb switch is open or closed.

Hope that helps. You have some excellent books; you may also find the comp.sys.ibm.pc.hardware.* FAQ helpful:

http://www.faqs.org/faqs/pc-hardware-faq/
(the General FAQs are halfway down the page)

Particularly part 2, which covers the keyboard controller:
http://www.faqs.org/faqs/pc-hardware-faq/part2/
[08-09-2000] saintly : If you're willing to work in assembler, this might be a way to test the keylock jumper:

Direct access to the keyboard is controlled through IO ports 60H and 64H. You can write command 'AA' (keyboard self-check) to port 64H. It returns '55' in port 60H if successful. You can also test the keyboard interface by writing 'AB' (keyboard interface check) to port 64H. It returns 0 if OK, 1 or 2 if there is a stuck clock and 3 or 4 if there is a stuck data line to port 60H.

There *are* also some cases where you may be able to get the status of the keyboard lock switch. Write 'C0' to port 64H. Bit 7 or 5 of the byte returned on port 60H may be the keyboard inhibit switch status.

This may depend on the BIOS, and of course accessing the keyboard directly will tend to make your code non-portable. But if you only intend to use the program on the machine you are writing it for, it should work fine!

A good FAQ on direct keyboard access in assembler:
http://webster.cs.ucr.edu/Page_asm/ArtofAssembly/CH20/CH20-2.html#HEADING2-1

Hope that helps!
[08-09-2000] saintly : Forgot to mention:

If you're testing keyboard status with IO ports 64H and 60H, remember to disable BIOS interrupt service while you're doing it. Otherwise any status bytes you get back in 60H will also end up in the keyboard buffer.

Write 'AD' to 64H to disable INT 9, test the keyboard, then write 'AE' back to 64H to re-enable it.
[08-10-2000] jeffhill : From your first response I was quite suprised. You mentioned that there was no way to check the status of the keyboard lock with software, and then mentioned that the BIOS checks it. If the BIOS can check it, I can check it. I gave the task to my programmer after delving deeper into the chapter on the keyboard. I had found info on ports 60 and 64 and after about an hour, my programmer demo'd an application to me that was completely successful. Then I got your additional response with info about the two ports mentioned.

I do appreciate your input, you pushed me in the right direction by telling me that it could not be done. Thank you again.

Jeff Hill

ExpertCentral.com
Home | Sign Up | My ExpertCentral | Answer Library | Help | Log Out
Public Board | How it Works | Why Join? | Tell a Friend | About Us | Contact Us

Copyright © 2000 ExpertCentral.com, Inc. All Rights Reserved.
ExpertCentral and ExpertCentral.com are trademarks of ExpertCentral.com, Inc.
Use of this site constitutes your acceptance to the terms and conditions of the ExpertCentral Member Agreement.