From owner-freebsd-current@FreeBSD.ORG Tue Jul 25 21:58:58 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7AA5216A4DD for ; Tue, 25 Jul 2006 21:58:58 +0000 (UTC) (envelope-from maksim.yevmenkin@savvis.net) Received: from mailgate1b.savvis.net (mailgate1b.savvis.net [216.91.182.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id EFACF43D46; Tue, 25 Jul 2006 21:58:57 +0000 (GMT) (envelope-from maksim.yevmenkin@savvis.net) Received: from localhost (localhost.localdomain [127.0.0.1]) by mailgate1b.savvis.net (Postfix) with ESMTP id 357E23BE8F; Tue, 25 Jul 2006 16:58:57 -0500 (CDT) Received: from mailgate1b.savvis.net ([127.0.0.1]) by localhost (mailgate1b.savvis.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 09083-01-5; Tue, 25 Jul 2006 16:58:57 -0500 (CDT) Received: from [10.12.163.251] (unknown [10.12.163.251]) by mailgate1b.savvis.net (Postfix) with ESMTP id BEE603BE29; Tue, 25 Jul 2006 16:58:56 -0500 (CDT) Message-ID: <44C69416.4090104@savvis.net> Date: Tue, 25 Jul 2006 14:58:46 -0700 From: Maksim Yevmenkin User-Agent: Thunderbird 1.5.0.2 (X11/20060603) MIME-Version: 1.0 To: freebsd-current@freebsd.org References: <20060710212815.GA46336@dragon.NUXI.org> <200607102027.18106.jhb@freebsd.org> <20060711181600.GB64759@dragon.NUXI.org> <44B3ECFC.1050806@savvis.net> <44B3F154.7030001@centtech.com> <44B4015D.8050105@savvis.net> In-Reply-To: <44B4015D.8050105@savvis.net> Content-Type: multipart/mixed; boundary="------------070501090004020303040002" X-Virus-Scanned: amavisd-new at savvis.net Cc: brien@freebsd.org Subject: Re: PS/2 keyboard support in mid-boot borked [PATCH] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jul 2006 21:58:58 -0000 This is a multi-part message in MIME format. --------------070501090004020303040002 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit hackers, [...] >>> like i said before, i think, the problem is that atkbd(4) does not >>> deal with "polled" mode properly. kbdmux(4) never sees input from >>> atkbd(4) because (imo) atkbd(4) interrupt handler is never called. >>> the atkbd(4) patch i posted awhile ago has a regression, i.e. >>> atkbd(4) produces duplicate characters in ddb(4), midboot, etc. >>> *without* kbdmux(4). patched atkbd(4) with kbdmux(4) works fine. >>> >>> i'm actually a bit puzzled why atkbd(4) works without kbdmux(4) in >>> ddb(4), midboot,e etc. obviously i need to spend some quality time >>> with the debugger :) i hope to get to it, eventually :) sorry for the >>> delay. >> >> What can we do to help you debug it? I know for me, it's a major >> pain, and I'm sure others have gotten jammed up too. > > i just spent half of my lunch hour with the debugger :) and, i think, i > know what is going on here. i think, there is some twisted interaction > going on in > > sccngetch(int flags) > { > ... > kbd_poll(scp->sc->kbd, TRUE); > c = scgetc(scp->sc, SCGETC_CN | flags); > kbd_poll(scp->sc->kbd, FALSE); > ... > } > > and > > sckbdevent() > { > ... > while ((c = scgetc(sc, SCGETC_NONBLOCK)) != NOKEY) { > ... > } > > code that causes duplicated input in atkbd(4) without kbdmux(4). so, my > original patch was not 100% correct. i will try to redo it to see if i > can work around the problem. if you have problems with kbdmux(4) and atkbd(4) NOT working mid-boot, could you please try the attached patch. i decided to add a little hack to kbdmux(4) instead of messing around with atkbd(4). please let me know if it works for you. thanks, max --------------070501090004020303040002 Content-Type: text/plain; name="kbdmux.c.diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="kbdmux.c.diff.txt" --- kbdmux.c.orig Tue Jul 25 14:50:22 2006 +++ kbdmux.c Tue Jul 25 14:41:47 2006 @@ -657,6 +657,27 @@ /* see if there is something in the keyboard queue */ scancode = getc(&state->ks_inq); if (scancode == -1) { + if (state->ks_flags & POLLING) { + kbdmux_kbd_t *k; + + SLIST_FOREACH(k, &state->ks_kbds, next) { + while (KBDMUX_CHECK_CHAR(k->kbd)) { + scancode = KBDMUX_READ_CHAR(k->kbd, 0); + if (scancode == NOKEY) + break; + if (scancode == ERRKEY) + continue; + if (!KBD_IS_BUSY(k->kbd)) + continue; + + putc(scancode, &state->ks_inq); + } + } + + if (state->ks_inq.c_cc > 0) + goto next_code; + } + KBDMUX_UNLOCK(state); return (NOKEY); } --------------070501090004020303040002--