+ int response;
+
+ /* Enable interrupts and keyboard, etc. */
+ if (kbc_8042cmd(K_LDCMDBYTE) != 0)
+ printf("Timeout specifying load of keyboard command byte\n");
+ if (kbd_cmd(CMDBYTE) != 0)
+ printf("Timeout writing keyboard command byte\n");
+ /*
+ * Discard any stale keyboard activity. The 0.1 boot code isn't
+ * very careful and sometimes leaves a KBR_RESEND.
+ */
+ while (inb(KBSTATP) & KBS_DIB)
+ kbd_response();
+
+ /* Start keyboard reset */
+ if (kbd_cmd(KBC_RESET) != 0)
+ printf("Timeout for keyboard reset command\n");
+
+ /* Wait for the first response to reset and handle retries */
+ while ((response = kbd_response()) != KBR_ACK) {
+ if (response < 0) {
+ printf("Timeout for keyboard reset ack byte #1\n");
+ response = KBR_RESEND;
+ }
+ if (response == KBR_RESEND) {
+ if (!again) {
+ printf("KEYBOARD disconnected: RECONNECT\n");
+ again = 1;
+ }
+ if (kbd_cmd(KBC_RESET) != 0)
+ printf("Timeout for keyboard reset command\n");
+ }
+ /*
+ * Other responses are harmless. They may occur for new
+ * keystrokes.
+ */
+ }