From patchwork Sat Mar 13 20:23:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin O'Connor X-Patchwork-Id: 47719 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9D070B7D41 for ; Sun, 14 Mar 2010 07:24:04 +1100 (EST) Received: from localhost ([127.0.0.1]:35126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NqXsO-0005s2-Nx for incoming@patchwork.ozlabs.org; Sat, 13 Mar 2010 15:24:00 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NqXrp-0005rA-8r for qemu-devel@nongnu.org; Sat, 13 Mar 2010 15:23:25 -0500 Received: from [199.232.76.173] (port=52569 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NqXrn-0005r2-Td for qemu-devel@nongnu.org; Sat, 13 Mar 2010 15:23:23 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NqXrj-0008Rp-Uq for qemu-devel@nongnu.org; Sat, 13 Mar 2010 15:23:23 -0500 Received: from mail-vw0-f45.google.com ([209.85.212.45]:51203) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NqXrj-0008Ri-LU for qemu-devel@nongnu.org; Sat, 13 Mar 2010 15:23:19 -0500 Received: by vws8 with SMTP id 8so234802vws.4 for ; Sat, 13 Mar 2010 12:23:18 -0800 (PST) Received: by 10.220.122.210 with SMTP id m18mr2113658vcr.94.1268511798610; Sat, 13 Mar 2010 12:23:18 -0800 (PST) Received: from localhost (207-172-165-101.s101.tnt1.nywnj.ny.dialup.rcn.com [207.172.165.101]) by mx.google.com with ESMTPS id 33sm21693565vws.10.2010.03.13.12.23.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 13 Mar 2010 12:23:17 -0800 (PST) Date: Sat, 13 Mar 2010 15:23:15 -0500 From: Kevin O'Connor To: Roy Tam , Natalia Portillo Message-ID: <20100313202315.GA25967@morn.localdomain> References: <16B78474-99FE-4671-8428-21CE0B12425A@claunia.com> <20100228195107.GB15352@morn.localdomain> <20100312015937.GA24688@morn.localdomain> <7547EDEE-9F39-43E7-BD30-1A18E5670BB2@claunia.com> <473191351003122230y652073edqecdbcceea76dce3@mail.gmail.com> <473191351003130644g5bf53d12lbd8fe36bc655a64c@mail.gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <473191351003130644g5bf53d12lbd8fe36bc655a64c@mail.gmail.com> User-Agent: Mutt/1.5.20 (2009-08-17) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: seabios@seabios.org, qemu-devel@nongnu.org Subject: [Qemu-devel] Re: PS/2 mouse emulation problems X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Sat, Mar 13, 2010 at 10:44:46PM +0800, Roy Tam wrote: > 2010/3/13 Natalia Portillo : > > Ok so in resume we have the following PS/2 mouse bugs: > > > > NeXTStep and OpenStep PS/2 driver receives no movement at all from the mouse > > (Darwin PS/2 driver seems to be made from scratch so no helpful here). > > MS-DOS Mouse driver hangs the whole machine. > > Windows Me Setup mouse driver receives no movement at all from the mouse. > > Old XFree86 PS/2 mouse driver receives no movement at all from standard > > protocols (PS/2, IMPS/2) or random movements (Microsoft). > > Hydrogen OS mouse driver does not work. > > > > While the NeXTStep PS/2 bug is known from QEMU 0.7.0 (which used Bochs > > BIOS), the other ones are new (as far as I know) so they may be or may not > > be caused by SeaBIOS. > > > > for Hydrogen OS, when I use QEMU BIOS (yes with my -old-bios hack) it > works in git head. Can you test with: http://linuxtogo.org/~kevin/SeaBIOS/test/bios.bin-0.5.1-debug-20100313 Change summary in this test image: * int 1601 / int 1a00 should enable irqs - fixes several boot hangs * Backup/restore registers on mouse/keyboard callbacks - fixes d090723b.zip * The mouse getid command may only return 1 byte - fixes msdos mouse hang * Always process key event in irq 09 handler - restores keyboard in ghost and fdos0138.img This image is based off stable-0.5.1 (image debug-20100311 was mistakenly based off of git head which had an additional regression of enabling mouse irqs by default). Interestingly, a ghost 11.5 image I found now works with mouse where it used to fail with bochs bios. The code changes I've used are below. These changes are for testing - I'm still looking into a full fix. -Kevin diff --git a/src/clock.c b/src/clock.c index e32bf1b..241119e 100644 --- a/src/clock.c +++ b/src/clock.c @@ -228,6 +228,7 @@ timer_setup(void) static void handle_1a00(struct bregs *regs) { + yield(); u32 ticks = GET_BDA(timer_counter); regs->cx = ticks >> 16; regs->dx = ticks; diff --git a/src/config.h b/src/config.h index 6297a48..9a3a165 100644 --- a/src/config.h +++ b/src/config.h @@ -16,9 +16,9 @@ #define CONFIG_COREBOOT 0 // Control how verbose debug output is. -#define CONFIG_DEBUG_LEVEL 1 +#define CONFIG_DEBUG_LEVEL 8 // Send debugging information to serial port -#define CONFIG_DEBUG_SERIAL 0 +#define CONFIG_DEBUG_SERIAL 1 // Screen writes are also sent to debug ports. #define CONFIG_SCREEN_AND_DEBUG 1 diff --git a/src/kbd.c b/src/kbd.c index 6f3ae15..7e3434a 100644 --- a/src/kbd.c +++ b/src/kbd.c @@ -73,6 +73,7 @@ enqueue_key(u8 scan_code, u8 ascii_code) static void dequeue_key(struct bregs *regs, int incr, int extended) { + yield(); u16 buffer_head; u16 buffer_tail; for (;;) { @@ -552,9 +553,19 @@ process_key(u8 key) // allow for keyboard intercept u32 eax = (0x4f << 8) | key; u32 flags; +#if 0 call16_simpint(0x15, &eax, &flags); if (!(flags & F_CF)) return; +#else + struct bregs br; + memset(&br, 0, sizeof(br)); + br.eax = eax; + call16_int(0x15, &br); + flags = br.flags; + if (!(flags & F_CF)) + return; +#endif key = eax; } __process_key(key); diff --git a/src/mouse.c b/src/mouse.c index 52e225c..92fb16a 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -305,15 +305,17 @@ process_mouse(u8 data) return; } - //BX_DEBUG_INT74("int74_function: make_farcall=1\n"); u16 status = GET_EBDA2(ebda_seg, mouse_data[0]); u16 X = GET_EBDA2(ebda_seg, mouse_data[1]); u16 Y = GET_EBDA2(ebda_seg, mouse_data[2]); SET_EBDA2(ebda_seg, mouse_flag1, 0); struct segoff_s func = GET_EBDA2(ebda_seg, far_call_pointer); + dprintf(16, "mouse farcall s=%04x x=%04x y=%04x func=%04x:%04x\n" + , status, X, Y, func.seg, func.offset); asm volatile( + "pusha\n" "sti\n" "pushl %0\n" @@ -326,6 +328,7 @@ process_mouse(u8 data) "cli\n" "cld\n" + "popa\n" : : "r"(func.segoff), "r"(status), "r"(X), "r"(Y) : "cc" diff --git a/src/ps2port.c b/src/ps2port.c index fb9d24a..759ad37 100644 --- a/src/ps2port.c +++ b/src/ps2port.c @@ -226,8 +226,11 @@ ps2_command(int aux, int command, u8 *param) if (ret) return ret; + // Flush any interrupts already pending. + yield(); + if (command == ATKBD_CMD_RESET_BAT) { - // Reset is special wrt timeouts. + // Reset is special wrt timeouts and bytes received. // Send command. ret = ps2_sendbyte(aux, command, 1000); @@ -244,6 +247,29 @@ ps2_command(int aux, int command, u8 *param) // Some devices only respond with one byte on reset. ret = 0; param[1] = ret; + } else if (command == ATKBD_CMD_GETID) { + // Getid is special wrt bytes received. + + // Send command. + ret = ps2_sendbyte(aux, command, 200); + if (ret) + goto fail; + + // Receive parameters. + ret = ps2_recvbyte(aux, 0, 500); + if (ret < 0) + goto fail; + param[0] = ret; + if (ret == 0xab || ret == 0xac || ret == 0x2b || ret == 0x5d + || ret == 0x60 || ret == 0x47) { + // These ids (keyboards) return two bytes. + ret = ps2_recvbyte(aux, 0, 500); + if (ret < 0) + goto fail; + param[1] = ret; + } else { + param[1] = 0; + } } else { // Send command. ret = ps2_sendbyte(aux, command, 200); @@ -336,7 +362,8 @@ handle_09(void) return; debug_isr(DEBUG_ISR_09); - process_ps2irq(); +// process_ps2irq(); + process_ps2byte(inb(PORT_PS2_STATUS), inb(PORT_PS2_DATA)); eoi_pic1(); }