From owner-freebsd-hackers@FreeBSD.ORG Fri May 9 11:57:09 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 757EE37B401; Fri, 9 May 2003 11:57:09 -0700 (PDT) Received: from anuket.mj.niksun.com (gwnew.niksun.com [65.115.46.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id D80BA43F75; Fri, 9 May 2003 11:57:07 -0700 (PDT) (envelope-from jkim@niksun.com) Received: from daemon.mj.niksun.com (daemon.mj.niksun.com [10.70.0.244]) h49Iug7F045725; Fri, 9 May 2003 14:56:42 -0400 (EDT) (envelope-from jkim@niksun.com) X-RAV-AntiVirus: This e-mail has been scanned for viruses. From: Jung-uk Kim Organization: Niksun, Inc. To: freebsd-hackers@freebsd.org Date: Fri, 9 May 2003 14:56:40 -0400 User-Agent: KMail/1.5.1 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_on/u+u2s27PdMap" Message-Id: <200305091456.40582.jkim@niksun.com> X-Content-Filtered-By: Mailman/MimeDel 2.1.1 cc: imp@freebsd.org Subject: boot2 keyboard probing problem (with patch) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 May 2003 18:57:09 -0000 --Boundary-00=_on/u+u2s27PdMap Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Recently I tried '-P' option in /boot.config for my desktop. boot2 always said 'Keyboard: yes' even if I don't have a keyboard attached. I realized the keyboard probing is somewhat broken for many others, e. g., IBM x335. boot(8) says: Due to space constraints, the keyboard probe initiated by the -P option is simply a test that the BIOS has detected an ``extended'' keyboard. If an ``XT/AT'' keyboard (with no F11 and F12 keys, etc.) is attached, the probe will fail. When I read src/sys/boot/i386/boot2/boot2.c, I found if (opts & 1 << RBX_PROBEKBD) { i = *(uint8_t *)PTOV(0x496) & 0x10; printf("Keyboard: %s\n", i ? "yes" : "no"); if (!i) opts |= 1 << RBX_DUAL | 1 << RBX_SERIAL; opts &= ~(1 << RBX_PROBEKBD); } This confirmed what the manpage said. The problem is 0x496 is set by BIOS but recent BIOSes don't seem to set the flag after actual probing (or they don't care?). I tried to resurrect KEYBOARD_PROBE option (src/sys/boot/i386/libi386/vidconsole.c) but it didn't work at all. Then I started writing my own and used some code from keyboard_init() for Bochs BIOS, which is written by Adam Sulmicki . http://www.eax.com/patches/BOCHS/bochs-bios-keyboard-2.1-diff My patch is simple: send echo command (0xee) to keyboard controller and read it back from keyboard. If keyboard controller doesn't get an echo back for some tries, it fails probing. BTW, I send 0 to port 0x80 (POST return value) to delay because I couldn't find better way. A side effect is POST code will be reset even if your BIOS reported a problem. However, if you got this far, it shouldn't be a critical problem. ;-) Is there any better way to delay? KEYBOARD_PROBE used port 0x84 but it was more tasteless because we cannot know what it might be used for. (In fact, Compaq used it for POST diagnostic.) This patch worked on my two desktops and an IBM 1U server. AT and PS/2 keyboards should work. I think it would work with KVM, too. The patch is against 4-STABLE but it could be okay with 5-CURRENT if there is enough space left in boot2. ;-) Please try this patch and let me know if you find any issues or have suggestions. Thanks, Jung-uk Kim --Boundary-00=_on/u+u2s27PdMap--