Date: Sat, 15 Feb 1997 17:56:23 +0900 From: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> To: Tony Overfield <tony@dell.com> Cc: freebsd-hackers@freebsd.org, yokota@zodiac.mech.utsunomiya-u.ac.jp Subject: Re: psm and kbdio driver (was Re: Stuck! 2.2 Gamma won't go.) Message-ID: <199702150856.RAA23399@zodiac.mech.utsunomiya-u.ac.jp> In-Reply-To: Your message of "Tue, 11 Feb 1997 00:15:23 CST." <3.0.1.32.19970211001523.006a17b8@bugs.us.dell.com> References: Your message of "Mon, 10 Feb 1997 05:15:54 CST." <3.0.1.32.19970210051554.006a2350@bugs.us.dell.com> <3.0.1.32.19970210022848.00691d20@bugs.us.dell.com> <3.0.1.32.19970210051554.006a2350@bugs.us.dell.com> <3.0.1.32.19970211001523.006a17b8@bugs.us.dell.com>
next in thread | previous in thread | raw e-mail | index | archive | help
>>If I ask some qustions regarding the keyboard controller, would you be >>kind enough to answer them and assist me to improve the psm and kbdio >>drivers? >> >>I really want several points clarified about the keyboard/mouse/i8042. > >Go ahead, I'll help with anything I can. My experience has been >primarily focused on moving the data to and from the keyboard and >mouse devices through the keyboard controller, not so much on what >the data within those packets actually is. Should we find a more >appropriate mailing list or should we go to direct e-mail? Thank you. Let's move to the freebsd-hackers list, as we are not quite discussing a bug anymore. Here are first bunch of questions. Before I beg you answers to my questions, I had better tell you my source of information first, so that you can know how I learned the basics of the keyboard, the PS/2 mouse and the keyboard controller. [1] Van Gilluwe, F.: "The Undocumented PC", Addison Wesley, 1994. [2] Hogan, T.: "The Programmer's PC Sourcebook, 2nd Ed.", Microsoft Press, 1991. [3] Brown, R.: "Interrupt List". [4] Phoenix Technologies Ltd.: "System BIOS for IBM PC/XT/AT Computers and Compatibles", Addison Wesley, 1987. [5] Logitech Inc.: "Logitech Mouse Technical Reference and Programmer's Guide", 1992. I also use various magazine articles, English or Japanese. No, I don't have a copy of "Technical Reference - Personal Computer AT" from IBM. I know I should have one. But, is it still available? 1. Internal buffer size I understand that the AT keyboard (84/101) has an internal 16 byte buffer. Does the PS/2 mouse have an internal buffer too? If so, how large is it? Also, does the keyboard controller buffer data from the keyboard and the mouse (I guess this is unlikely though)? 2. Response to the command For most keyboard commands, the keyboard responds with ACK (0xfa). When exactly is it sent back? Suppose a data byte is waiting in the keyboard internal buffer to be transmitted to the system, then a command arrives. Will ACK be sent back before or after the data byte? The keyboard often sends two or more bytes for a single key make/break event. What if a command arrives after the first byte has been sent but before the second byte. Will ACK be sent before the second byte? What should I do to the first byte already received? Should I discard it (because the first byte will be sent again?), or save it so that I can use it together with the second byte which will be later received? The system can interrupt data transmission from the keyboard in the midst of a byte, by bringing the CLOCK line down. In such case, will the keyboard try to re-send the interrupted byte later? As for the PS/2 mouse, the Logitech Mouse Technical Reference is explicit about such circumstances; ACK will be sent immediately. If a command from the system interrupt a data packet from the mouse in the middle, the transmission of the data packet is aborted, and the system should discard data already received. The mouse will send the complete data packet again after the ACK. 3. Reset For the reset command (0xff), the keyboard responds with ACK and a result code (0xaa). The mouse responds with ACK, a result code and an device ID. I learned that the reset action takes a long, long time, and the keyboard/mouse driver has to exercise a long delay before attempting to read response from the device. The duration of necessary delay varies from one system to another (though, I have the impression the keyboard reset takes longer than the mouse reset...). So, we need go give sufficient margin to the delay. Is there standard or semi-standard or practical value for this duration? And when exactly should I wait? I have found many keyboard and mice return ACK immediately and takes their own sweet time to reset itself, so I do "send RESET - receive ACK - wait (up to a few hundred msec) - receive a result code". But, I recently learned that I need to wait before ACK for the built-in mouse device in some laptops. I would be grateful if you could shed some light on these questions. Kazu
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702150856.RAA23399>