qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] OpenStep / Busmouse - correct patch


From: Johannes Schindelin
Subject: Re: [Qemu-devel] OpenStep / Busmouse - correct patch
Date: Sun, 1 Jan 2006 23:35:46 +0100 (CET)

Hi,

On Sun, 1 Jan 2006, address@hidden wrote:

> I attached the correct version to this mail. Sorry...

Impressive! How about this on top (unfortunately untested, since I do not 
have a system handy which supports a busmouse):

---
[PATCH] Add -busmouse switch

Now, you can enable the busmouse (thereby disabling the PS/2 mouse) 
emulation with "qemu -busmouse".

---

 hw/busmouse.c |   21 ++++++++++-----------
 hw/pc.c       |    7 -------
 hw/ps2.c      |   10 +++++++---
 vl.c          |   18 ++++++++++++++++++
 vl.h          |    8 ++------
 5 files changed, 37 insertions(+), 27 deletions(-)

10fcdd858caaaec8e7deaa5d349afbb1d93c4640
diff --git a/hw/busmouse.c b/hw/busmouse.c
index b0eb0e3..a935f5c 100644
--- a/hw/busmouse.c
+++ b/hw/busmouse.c
@@ -29,7 +29,7 @@
  * and internal state
  */
 
-struct BusmouseState {
+typedef struct BusmouseState {
     uint8_t data;
     uint8_t signature;
     uint8_t control;
@@ -38,13 +38,12 @@ struct BusmouseState {
     uint8_t command;
     int irq;
     int irq_pending;
-    CharDriverState *chr;
     int hw_driver;
     uint16_t mouse_dx;
     uint16_t mouse_dy;
     uint16_t mouse_dz;
     uint16_t mouse_buttons;
-};
+} BusmouseState;
 
 static void busmouse_update_irq(BusmouseState *s);
 
@@ -139,22 +138,22 @@ static uint32_t busmouse_ioport_read(voi
     return ret;
 }
 
+#define BUSMOUSE_BASE 0x238
+#define BUSMOUSE_IRQ 5
+
 /* If fd is zero, it means that the busmouse device uses the console */
-BusmouseState *busmouse_init(int base, int irq, CharDriverState *chr)
+void busmouse_init()
 {
     BusmouseState *s;
 
     s = qemu_mallocz(sizeof(BusmouseState));
     if (!s)
-        return NULL;
-    s->chr = chr;
+        return;
     s->hw_driver = 0;
-    s->irq = irq;
+    s->irq = BUSMOUSE_IRQ;
     s->data = 0;
     s->mouse_buttons = 0x0;
-    register_ioport_write(base, 8, 1, busmouse_ioport_write, s);
-    register_ioport_read(base, 8, 1, busmouse_ioport_read, s);
+    register_ioport_write(BUSMOUSE_BASE, 8, 1, busmouse_ioport_write, s);
+    register_ioport_read(BUSMOUSE_BASE, 8, 1, busmouse_ioport_read, s);
     qemu_add_mouse_event_handler(busmouse_event, s);
-
-    return s;
 }
diff --git a/hw/pc.c b/hw/pc.c
index cc3ec3e..8e750b6 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -574,9 +574,6 @@ static int serial_irq[MAX_SERIAL_PORTS] 
 static int parallel_io[MAX_PARALLEL_PORTS] = { 0x378, 0x278, 0x3bc };
 static int parallel_irq[MAX_PARALLEL_PORTS] = { 7, 7, 7 };
 
-static int busmouse_io[MAX_BUSMOUSE_PORTS] = { 0x238 };
-static int busmouse_irq[MAX_BUSMOUSE_PORTS] = { 5 };
-
 #ifdef HAS_AUDIO
 static void audio_init (PCIBus *pci_bus)
 {
@@ -803,10 +800,6 @@ static void pc_init1(int ram_size, int v
         }
     }
 
-    for(i = 0; i < 1; i++) {
-        busmouse_init(busmouse_io[i], busmouse_irq[i], 0);
-    }
-
     if (pci_enabled) {
         for(i = 0; i < nb_nics; i++) {
             pci_ne2000_init(pci_bus, &nd_table[i]);
diff --git a/hw/ps2.c b/hw/ps2.c
index 7fbc535..500da2b 100644
--- a/hw/ps2.c
+++ b/hw/ps2.c
@@ -500,15 +500,19 @@ void *ps2_kbd_init(void (*update_irq)(vo
 
 void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg)
 {
-    PS2MouseState *s = (PS2MouseState *)qemu_mallocz(sizeof(PS2MouseState));
+    PS2MouseState *s;
+
+    if (!ps2_mouse_enabled)
+        return NULL;
+
+    s = (PS2MouseState *)qemu_mallocz(sizeof(PS2MouseState));
 
     s->common.update_irq = update_irq;
     s->common.update_arg = update_arg;
     ps2_reset(&s->common);
     register_savevm("ps2mouse", 0, 1, ps2_mouse_save, ps2_mouse_load, s);
 
-    /* disabled for busmouse emulation (req'd for running OpenStep) */
-    /* qemu_add_mouse_event_handler(ps2_mouse_event, s); */
+    qemu_add_mouse_event_handler(ps2_mouse_event, s);
     qemu_register_reset(ps2_reset, &s->common);
     return s;
 }
diff --git a/vl.c b/vl.c
index 794ed22..f82177b 100644
--- a/vl.c
+++ b/vl.c
@@ -144,6 +144,8 @@ int win2k_install_hack = 0;
 int usb_enabled = 0;
 USBPort *vm_usb_ports[MAX_VM_USB_PORTS];
 USBDevice *vm_usb_hub;
+int ps2_mouse_enabled = 1;
+int busmouse_enabled = 0;
 static VLANState *first_vlan;
 int smp_cpus = 1;
 #if defined(TARGET_SPARC)
@@ -3983,6 +3985,9 @@ void help(void)
 #endif
            "-usb            enable the USB driver (will be the default soon)\n"
            "-usbdevice name add the host or guest USB device 'name'\n"
+#ifdef TARGET_I386
+           "-busmouse       emulate busmouse instead of standard PS/2\n"
+#endif
 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
            "-g WxH[xDEPTH]  Set the initial graphical resolution and depth\n"
 #endif
@@ -4125,6 +4130,7 @@ enum {
     QEMU_OPTION_win2k_hack,
     QEMU_OPTION_usb,
     QEMU_OPTION_usbdevice,
+    QEMU_OPTION_busmouse,
     QEMU_OPTION_smp,
 };
 
@@ -4191,6 +4197,7 @@ const QEMUOption qemu_options[] = {
     { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
     { "win2k-hack", 0, QEMU_OPTION_win2k_hack },
     { "usbdevice", HAS_ARG, QEMU_OPTION_usbdevice },
+    { "busmouse", 0, QEMU_OPTION_busmouse },
     { "smp", HAS_ARG, QEMU_OPTION_smp },
     
     /* temporary options */
@@ -4766,6 +4773,12 @@ int main(int argc, char **argv)
                         optarg);
                 usb_devices_index++;
                 break;
+#ifdef TARGET_I386
+            case QEMU_OPTION_busmouse:
+                busmouse_enabled = 1;
+                ps2_mouse_enabled = 0;
+                break;
+#endif
             case QEMU_OPTION_smp:
                 smp_cpus = atoi(optarg);
                 if (smp_cpus < 1 || smp_cpus > MAX_CPUS) {
@@ -4921,6 +4934,11 @@ int main(int argc, char **argv)
         }
     }
 
+#ifdef TARGET_I386
+    if (busmouse_enabled)
+        busmouse_init();
+#endif
+
     register_savevm("timer", 0, 1, timer_save, timer_load, NULL);
     register_savevm("ram", 0, 1, ram_save, ram_load, NULL);
 
diff --git a/vl.h b/vl.h
index c50ac5d..6d87a6e 100644
--- a/vl.h
+++ b/vl.h
@@ -137,6 +137,7 @@ extern const char *keyboard_layout;
 extern int kqemu_allowed;
 extern int win2k_install_hack;
 extern int usb_enabled;
+extern int ps2_mouse_enabled;
 extern int smp_cpus;
 
 /* XXX: make it dynamic */
@@ -271,10 +272,6 @@ extern CharDriverState *serial_hds[MAX_S
 
 #define MAX_PARALLEL_PORTS 3
 
-/* busmouse ports */
-
-#define MAX_BUSMOUSE_PORTS 1
-
 extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
 
 /* VLANs support */
@@ -761,8 +758,7 @@ ParallelState *parallel_init(int base, i
 
 /* busmouse.c */
 
-typedef struct BusmouseState BusmouseState;
-BusmouseState *busmouse_init(int base, int irq, CharDriverState *chr);
+void busmouse_init();
 
 /* i8259.c */
 
-- 
1.0.GIT




reply via email to

[Prev in Thread] Current Thread [Next in Thread]