From patchwork Wed Oct 20 18:01:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brian Wheeler X-Patchwork-Id: 68464 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 8BACFB70CC for ; Thu, 21 Oct 2010 05:06:29 +1100 (EST) Received: from localhost ([127.0.0.1]:59943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8d3R-0005j7-VW for incoming@patchwork.ozlabs.org; Wed, 20 Oct 2010 14:06:26 -0400 Received: from [140.186.70.92] (port=34696 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8cyi-0002Gi-UZ for qemu-devel@nongnu.org; Wed, 20 Oct 2010 14:01:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8cyh-0001IS-3O for qemu-devel@nongnu.org; Wed, 20 Oct 2010 14:01:32 -0400 Received: from hartman.uits.indiana.edu ([129.79.1.194]:45646 helo=internal-relay.indiana.edu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8cyg-0001HU-VF for qemu-devel@nongnu.org; Wed, 20 Oct 2010 14:01:31 -0400 Received: from mail-relay.iu.edu (candy.uits.indiana.edu [129.79.1.201]) by internal-relay.indiana.edu (8.14.4/8.14.4/IU Messaging Team) with ESMTP id o9KI1RXR015235 for ; Wed, 20 Oct 2010 14:01:27 -0400 Received: from [129.79.35.119] (nibbler.dlib.indiana.edu [129.79.35.119]) (authenticated bits=0) by mail-relay.iu.edu (8.14.4/8.14.4/IU Messaging Team Submission) with ESMTP id o9KI1RGZ003795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 20 Oct 2010 14:01:27 -0400 From: Brian Wheeler To: qemu-devel@nongnu.org Date: Wed, 20 Oct 2010 14:01:27 -0400 Message-ID: <1287597687.2393.63.camel@nibbler.dlib.indiana.edu> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 (2.30.3-1.fc13) X-MIME-Autoconverted: from 8bit to quoted-printable by internal-relay.indiana.edu id o9KI1RXR015235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] Can't compile ISA device... 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 I'm trying to write a busmouse driver and I can't get it to compile. It seems like there's a header issue of some sort that I can't work out. Of course, if someone has a working busmouse driver for qemu, that would be great: OpenStep won't work with the ps/2 emulation and even after pounding on it for a few days I can't seem to narrow down why it OS stops paying attention to it. The consensus in 2006 was "fix the ps/2 emulation" but apparently nobody has been able to figure out how its broken and this seems like a reasonable solution. My code is based on the pc98 busmouse driver by TAKEDA, toshiya and the busmouse patches that floated around the list over the last few years. Anyway, it seems like a typedef is wrong. Did I miss something obvious? Thanks Brian I'm getting: ================================================== and here's the source: ========================= #include "hw.h" #include "pc.h" #include "isa.h" #include "qdev.h" #include "console.h" struct mouse_t { int button; int dx, dy; uint8_t index; qemu_irq irq; int irq_pending; }; typedef struct mouse_isabus_t { ISADevice busdev; struct mouse_t state; } mouse_isabus_t; typedef struct mouse_t mouse_t; /* mouse */ static void mouse_event_handler(void *opaque, int dx, int dy, int dz, int buttons_state) { mouse_t *s = opaque; s->button = buttons_state; s->dx += dx; s->dy += dy; s->irq_pending = 1; } static void busmouse_update_irq(mouse_t *s) { if (s->irq_pending) { qemu_set_irq(s->irq, 1); } else { qemu_set_irq(s->irq, 0); } } /* pio */ static void busmouse_pio_write(void *opaque, uint32_t addr, uint32_t val) { mouse_t *s = opaque; switch(addr) { case 0: //data break; case 1: // signature break; case 2: // control s->index = val; break; case 3: // config break; } } static uint32_t busmouse_pio_read(void *opaque, uint32_t addr) { mouse_t *s = opaque; uint32_t val = 0; static int interrupt_val = 0x01; s->irq_pending = 0; switch(addr) { case 0: // data s->irq_pending = 0; val |= (s->button & 1)? 0x80 : 0x00; val |= (s->button & 2)? 0x40 : 0x00; val |= (s->button & 4)? 0x20 : 0x00; val |= ((s->index & 0x40? s->dy : s->dx) >> (s->index & 0x20? 4 : 0)) & 0x0f; busmouse_update_irq(s); break; case 1: // signature val = 0xa5; busmouse_update_irq(s); break; case 2: // control val = interrupt_val; interrupt_val = (interrupt_val << 1) && 0xff; if (interrupt_val == 0) interrupt_val = 1; break; case 3: // config? break; } return val; } /* interface */ static void busmouse_reset(void *opaque) { mouse_t *s = opaque; s->button = 0; s->dx = s->dy = 0; s->index = 0xf0; } static int busmouse_pre_load(void *opaque) { busmouse_reset(opaque); return 0; } static const VMStateDescription vmstate_mouse = { .name = "logitech-busmouse", .version_id = 1, .minimum_version_id = 1, .minimum_version_id_old = 1, .pre_load = busmouse_pre_load, .fields = (VMStateField []) { VMSTATE_UINT8(index, mouse_t), VMSTATE_END_OF_LIST() } }; static int busmouse_init1(ISADevice *dev) { mouse_isabus_t *isa = DO_UPCAST(mouse_isabus_t, busdev, dev); mouse_t *s = &isa->state; register_ioport_read(0x23c, 4, 1, busmouse_pio_read, s); register_ioport_write(0x23c, 4, 1, busmouse_pio_write, s); isa_init_irq(&isa->busdev, &s->irq, 3); qemu_add_mouse_event_handler(mouse_event_handler, s, 0, "busmouse"); //vmstate_register(-1, &vmstate_mouse, s); busmouse_reset(s); qemu_register_reset(busmouse_reset, s); return 0; } static ISADeviceInfo busmouse_info = { .init = busmouse_init1, .qdev.name = "busmouse", .qdev.size = sizeof(mouse_isabus_t), }; static void busmouse_register_devices(void) { isa_qdev_register(&busmouse_info); } device_init(busmouse_register_devices) ========================= ============================== In file included from /home/bdwheele/Projects/qemu/hw/pc.h:7, from /home/bdwheele/Projects/qemu/hw/busmouse.c:30: /home/bdwheele/Projects/qemu/hw/isa.h:33: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘isa_mem_base’ /home/bdwheele/Projects/qemu/hw/isa.h:35: error: expected ‘)’ before ‘base’ In file included from /home/bdwheele/Projects/qemu/hw/pc.h:8, from /home/bdwheele/Projects/qemu/hw/busmouse.c:30: /home/bdwheele/Projects/qemu/hw/fdc.h:11: error: expected declaration specifiers or ‘...’ before ‘target_phys_addr_t’ /home/bdwheele/Projects/qemu/hw/fdc.h:12: error: expected declaration specifiers or ‘...’ before ‘target_phys_addr_t’ In file included from /home/bdwheele/Projects/qemu/hw/busmouse.c:30: /home/bdwheele/Projects/qemu/hw/pc.h:15: error: expected ‘)’ before ‘base’ /home/bdwheele/Projects/qemu/hw/pc.h:26: error: expected ‘)’ before ‘base’ /home/bdwheele/Projects/qemu/hw/pc.h:78: error: expected declaration specifiers or ‘...’ before ‘target_phys_addr_t’ /home/bdwheele/Projects/qemu/hw/pc.h:78: error: expected declaration specifiers or ‘...’ before ‘ram_addr_t’ /home/bdwheele/Projects/qemu/hw/pc.h:79: error: expected declaration specifiers or ‘...’ before ‘target_phys_addr_t’ /home/bdwheele/Projects/qemu/hw/pc.h:91: error: expected ‘)’ before ‘ram_size’ /home/bdwheele/Projects/qemu/hw/pc.h:106: error: expected ‘)’ before ‘ram_size’ /home/bdwheele/Projects/qemu/hw/pc.h:141: error: expected declaration specifiers or ‘...’ before ‘ram_addr_t’ /home/bdwheele/Projects/qemu/hw/pc.h:159: error: expected ‘)’ before ‘vram_base’ ========================================= I've added it to Makefile.objs: ========================================= diff --git a/Makefile.objs b/Makefile.objs index 816194a..908c21f 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -81,7 +81,7 @@ common-obj-y += bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o u common-obj-y += bt-hci-csr.o common-obj-y += buffered_file.o migration.o migration-tcp.o qemu-sockets.o common-obj-y += qemu-char.o savevm.o #aio.o -common-obj-y += msmouse.o ps2.o +common-obj-y += msmouse.o ps2.o busmouse.o common-obj-y += qdev.o qdev-properties.o common-obj-y += block-migration.o common-obj-y += pflib.o