aboutsummaryrefslogtreecommitdiff
path: root/sys/isa/syscons.c
diff options
context:
space:
mode:
authorSøren Schmidt <sos@FreeBSD.org>1996-12-01 19:05:50 +0000
committerSøren Schmidt <sos@FreeBSD.org>1996-12-01 19:05:50 +0000
commit1f9d9075e43147bf28dfb2ab3d39c63eff1c0e3d (patch)
tree54352ee80d9cef4ec7de46e9031694a7e6a7126f /sys/isa/syscons.c
parent661a46b5a163770aa911b4314e6ea6f5e621f989 (diff)
Alot of fixes from kazu:
1. All the suggestions earlier made by Bruce: renaming some symbols, stricter error checking, removing redundant code, etc. 2. The `psm' driver preserves the default counter resolution and report rate, whatever they are after reset. (Based on reports and suggestion from Nate and Rob Bolin). 3. The `psm' driver now does not check the so-called sync. bit in the first byte of the data packet by default, so that the tapping feature of ALPUS GlidePoint works (based on reports from Louis Mamakos). I tested the code with ALPUS Desktop GlidePoint (M/N GP101) and found no problem; tapping worked. It appears ALPUS produces several models of GlidePoint. I hope the other models are OK too. The check code can still be activated by defining the PSM_CHECKSYNC option in the config file. (The bit checking slightly reduces, if not completely eliminates, weird mouse behavior cased by unsynchronized mouse data packets. It also helps us to detect if the mouse interrupt can ever be lost. But, well, if there are devices which cannot be supported this way...) 4. The `psm' driver does not include the protocol emulation code by default. The code can still be compiled in if the PSM_EMULATION option is specified in the config file. Louis Mamakos suggests the emulation code is putting too much in the kernel, and `moused' works well. I will think about this later and decide if the entire emulation code should be removed. 5. And, of course, the fix in `scprobe()' from Bruce to cure the UserConfig problem. My code in `kbdio.c' is slightly different from his patch, but has the same effect. There still is a possibility that `scprobe()' gets confused, if, for whatever reasons, the user holds down a key for very long time during the boot process. But we cannot cope with everything, can we? Submitted by: Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
Notes
Notes: svn path=/head/; revision=20073
Diffstat (limited to 'sys/isa/syscons.c')
-rw-r--r--sys/isa/syscons.c71
1 files changed, 53 insertions, 18 deletions
diff --git a/sys/isa/syscons.c b/sys/isa/syscons.c
index 8b9fff188bba..691460aa1404 100644
--- a/sys/isa/syscons.c
+++ b/sys/isa/syscons.c
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: syscons.c,v 1.188 1996/11/15 08:45:24 sos Exp $
+ * $Id: syscons.c,v 1.189 1996/11/19 17:08:10 nate Exp $
*/
#include "sc.h"
@@ -298,31 +298,47 @@ scprobe(struct isa_device *dev)
sc_port = dev->id_iobase;
+ /* discard anything left after UserConfig */
+ empty_both_buffers(sc_port, 10);
+
/* save the current keyboard controller command byte */
- write_controller_command(sc_port, KBDC_GET_COMMAND_BYTE);
+ c = -1;
+ if (!write_controller_command(sc_port, KBDC_GET_COMMAND_BYTE)) {
+ /* CONTROLLER ERROR */
+ printf("sc%d: unable to get the current command byte value.\n",
+ dev->id_unit);
+ goto fail;
+ }
c = read_controller_data(sc_port);
if (c == -1) {
+ /* CONTROLLER ERROR */
printf("sc%d: unable to get the current command byte value.\n",
dev->id_unit);
goto fail;
}
+#if 0
+ /* override the keyboard lock switch */
+ c |= KBD_OVERRIDE_KBD_LOCK;
+#endif
/*
* enable the keyboard port, but disable the keyboard intr.
* the aux port (mouse port) is disabled too.
*/
- write_controller_command(sc_port, KBDC_DISABLE_KBD_PORT);
- set_controller_command_byte(sc_port,
- c&~(KBD_KBD_CONTROL_BITS|KBD_AUX_CONTROL_BITS),
- KBD_ENABLE_KBD_PORT|KBD_DISABLE_KBD_INT
- |KBD_DISABLE_AUX_PORT|KBD_DISABLE_AUX_INT);
-
- /* flush any noise in the buffer */
- empty_both_buffers(sc_port);
+ if (!set_controller_command_byte(sc_port,
+ c & ~(KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS),
+ KBD_ENABLE_KBD_PORT | KBD_DISABLE_KBD_INT
+ | KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
+ /* CONTROLLER ERROR
+ * there is very little we can do...
+ */
+ printf("sc%d: unable to set the command byte.\n", dev->id_unit);
+ goto fail;
+ }
/* reset keyboard hardware */
if (!reset_kbd(sc_port)) {
- /*
+ /* KEYBOARD ERROR
* Keyboard reset may fail either because the keyboard doen't exist,
* or because the keyboard doesn't pass the self-test, or the keyboard
* controller on the motherboard and the keyboard somehow fail to
@@ -331,15 +347,17 @@ scprobe(struct isa_device *dev)
* test_controller() and test_kbd_port() appear to bring the keyboard
* controller back (I don't know why and how, though.)
*/
+ empty_both_buffers(sc_port, 10);
test_controller(sc_port);
test_kbd_port(sc_port);
/* We could disable the keyboard port and interrupt... but,
- * the keyboard may still exist (see above). Just leave the command
- * byte as before.
+ * the keyboard may still exist (see above).
*/
- set_controller_command_byte(sc_port, c, 0);
+ if (bootverbose)
+ printf("sc%d: failed to reset the keyboard.\n", dev->id_unit);
goto fail;
}
+
/*
* Allow us to set the XT_KEYBD flag in UserConfig so that keyboards
* such as those on the IBM ThinkPad laptop computers can be used
@@ -347,19 +365,36 @@ scprobe(struct isa_device *dev)
*/
if (dev->id_flags & XT_KEYBD) {
if (send_kbd_command_and_data(
- sc_port, KBDC_SET_SCAN_CODESET, 1) == KBD_ACK)
+ sc_port, KBDC_SET_SCAN_CODESET, 1) == KBD_ACK) {
/* XT kbd doesn't need scan code translation */
c &= ~KBD_TRANSLATION;
- wait_while_controller_busy(sc_port);
+ } else {
+ /* KEYBOARD ERROR
+ * The XT kbd isn't usable unless the proper scan code set
+ * is selected.
+ */
+ printf("sc%d: unable to set the XT keyboard mode.\n", dev->id_unit);
+ goto fail;
+ }
}
/* enable the keyboard port and intr. */
- set_controller_command_byte(sc_port, c & ~KBD_KBD_CONTROL_BITS,
- KBD_ENABLE_KBD_PORT | KBD_ENABLE_KBD_INT);
+ if (!set_controller_command_byte(sc_port, c & ~KBD_KBD_CONTROL_BITS,
+ KBD_ENABLE_KBD_PORT | KBD_ENABLE_KBD_INT)) {
+ /* CONTROLLER ERROR
+ * This is serious; we are left with the disabled keyboard intr.
+ */
+ printf("sc%d: unable to enable the keyboard port and intr.\n",
+ dev->id_unit);
+ goto fail;
+ }
succeed:
return (IO_KBDSIZE);
fail:
+ if (c != -1)
+ /* try to restore the command byte as before, if possible */
+ set_controller_command_byte(sc_port, c, 0);
return ((dev->id_flags & DETECT_KBD) ? 0 : IO_KBDSIZE);
}