Sadly (or happily) there are very few online resources for the PS/2
port. When I need to figure something out about PS/2, I use my copy of
“The Undocumented PC” by Frank Van Gilluwe. PS/2 is pretty obtuse and
has lots of weird quirks. It’s not really the best introduction to
driver writing (the DDK’s toaster sample is pretty reasonable for that,
actually).
While I agree with the spirit of Doron’s suggestion of using USB/HID
even for embedded laptop devices, you might want to check whether any
laptop OEM is actually willing to *buy* one before you invest a lot of
effort in that direction :-).
Anyway, I’m happy to answer any specific questions you might come up with.
Here’s a summary to help get you started: a PS/2 keyboard controller
exposes 2 IO ports, 0x60 and 0x64. 0x60 is the “data” port, and 0x64 is
the “command port”. I8042prt sends commands to the host keyboard
controller itself using port 0x64. There are numerous examples of this
in the source. Commands for a mouse or keyboard are sent to port 0x60.
In the case of the mouse, you first send a 0xD4 to port 0x64. Responses
and keyboard/mouse data come back via port 0x60. There are bits you can
get by reading port 0x64 that tell you which device the byte is from,
among other things.
Anyway, none of this is really relevant for a simple mouse/keyboard
filter. You shouldn’t be touching the ports directly in that driver
(unless you *really* understand what’s going on and have a lot of time
for debugging), because you’ll interfere with i8042prt, and if you do
something wrong you can wedge the keyboard and mouse, requiring a reboot.
The i8042prt pseudo-minidriver architecture is documented in the DDK.
You are passed pointers to functions you can call to send commands/data
to the mouse or keyboard. You set up a callback function to receive
response/packet bytes from i8042prt’s ISR.
Doron Holan wrote:
- mouclass sends this during its AddDevice routine, so it is sent when the stack is being built. The flag is set to know when to handle the start(s) for both devices
2a) yes. Touching the mouse requires writing a byte to the controller indicating “direction” and then the device itself
2b) the controller has different modes (translation for the devices connected to it, etc)
2c) ps2 devices don’t have ports, just the controller itself.
Why do you need to learn ps2? It is a dead end technology really. If you are creating new products, it should be USB HID based (even for a laptop embedded device). Perhaps Ray Trent knows where you can find some online resources ;).
d
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of S. Drasnin
Sent: Tuesday, November 15, 2005 5:03 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] PS/2 mouse/keyboard sample DDK driver (i8042prt) question
hi
A couple of general questions for the driver operation…I’m looking at the driver to try to get a general overview of operation in conjunction with the underlying hardware (I and haven’t actually tried stepping through it yet).
(1) In the IOCTL_INTERNAL_MOUSE_CONNECT handling code, I see the code assumes that the mouse hardware is present
(it calls SET_HW_FLAGS(MOUSE_HARDWARE_PRESENT) without checking the hardware via a port operation, etc.)
When does the system (not sure what entity this is – the Mouseclass service?) decide when to send this IOCTL? Is it part of start-up / initialization code for the DO created by the Mousclass?
(Similar question for IOCTL_INTERNAL_KEYBOARD connect.)
(2) I see that there are 3 entities a data byte can be read from/written to (e.g. in I8xGetByteAsychronous): the ControllerDeviceType, the KeyboardDeviceType, and the MouseDeviceType. ( These are defined in the typedef _I8042_DEVICE_TYPE ).
( a ) Does each of these three “device” accesses correspond to port accesses inside the i8042 controller itself?
( b ) In general, what is the purpose of accessing the ControllerDeviceType device versus the Keyboard and Mouse ones? Are the ControllerDeviceType device accesses more for configuration?
( c ) Does this driver always access the keyboard and mouse through the i8042 controller? Is there any cases in which it accesses ports exposed directly on the keyboard and/or mouse hardware ? (I’m betting the answer is no - because why have a controller otherwise?!)
The reason I ask is that I don’t know how the i8042 controller works. Any suggestions of where to find this info on the web?
thanks
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com
–
Ray