Qemu 0.9.0 patches & whatnot... works under Vista64

Started by neozeed, May 25, 2008, 05:52:40 pm

Previous topic - Next topic

neozeed

For what it's worth I slapped up my patch so I could do more work on the Frontier port to NeXTSTEP... I needed SVGA!!!

The sad thing is that Qemu 0.9.1 crashes on my Vista install, and the newest snapshot of Qemu requires a lot more 'thinking' WRT the busmouse driver then I want to do right now... So here is the busmouse & some PCI hacking for 0.9.0.

You'll want the following device drivers for NeXTSTEP to make it worth the while.

http://www-teaching.physics.ox.ac.uk/NextStep/NE2K_driver.fdd
http://www.nextcomputers.org/NeXTfiles/Software/NEXTSTEP/Drivers/nextstep_3.3/released/CL_GD5434.pkg.compressed

Anyways here is the patch.


diff -ruN qemu-0.9.0/Makefile.target qemu-0.9.0-nextstep/Makefile.target
--- qemu-0.9.0/Makefile.target Mon Feb  5 18:01:54 2007
+++ qemu-0.9.0-nextstep/Makefile.target Sun May 25 13:06:29 2008
@@ -370,7 +370,7 @@
VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o acpi.o piix_pci.o
-VL_OBJS+= usb-uhci.o smbus_eeprom.o
+VL_OBJS+= usb-uhci.o smbus_eeprom.o busmouse.o
CPPFLAGS += -DHAS_AUDIO
endif
ifeq ($(TARGET_BASE_ARCH), ppc)
diff -ruN qemu-0.9.0/hw/busmouse.c qemu-0.9.0-nextstep/hw/busmouse.c
--- qemu-0.9.0/hw/busmouse.c Wed Dec 31 19:00:00 1969
+++ qemu-0.9.0-nextstep/hw/busmouse.c Sun May 25 13:09:41 2008
@@ -0,0 +1,159 @@
+/*
+ * QEMU Busmouse emulation
+ *
+ * Copyright (c) 2005 Michael Engel (engel-at-informatik.uni-marburg.de)
+ * using hints from parallel.c and ps2.c
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN
+ * THE SOFTWARE.
+ */
+#include "vl.h"
+
+/*
+ * These are the definitions for the busmouse controller registers
+ * and internal state
+ */
+
+struct BusmouseState {
+    uint8_t data;
+    uint8_t signature;
+    uint8_t control;
+    uint8_t interrupt;
+    uint8_t config;
+    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;
+};
+
+static void busmouse_update_irq(BusmouseState *s);
+
+static void busmouse_event(void *opaque,
+                            int dx, int dy, int dz, int buttons_state)
+{
+    BusmouseState *s = opaque;
+
+    s->mouse_dx += dx;
+    s->mouse_dy += dy;
+    s->mouse_dz += dz;
+    /* XXX: SDL sometimes generates nul events: we delete them */
+    if (s->mouse_dx == 0 && s->mouse_dy == 0 && s->mouse_dz == 0 &&
+        s->mouse_buttons == buttons_state)
+       return;
+    s->mouse_buttons = buttons_state;
+
+    s->irq_pending = 1;
+    busmouse_update_irq(s);
+}
+
+static void busmouse_update_irq(BusmouseState *s)
+{
+    if (s->irq_pending)
+        pic_set_irq(s->irq, 1);
+    else
+        pic_set_irq(s->irq, 0);
+}
+
+static void busmouse_ioport_write(void *opaque, uint32_t addr, uint32_t val)
+{
+    BusmouseState *s = opaque;
+
+    addr &= 0xf;
+    switch(addr) {
+    case 0xc: /* data port */
+        break;
+    case 0xd: /* signature port */
+        break;
+    case 0xe: /* control/interrupt port */
+        s->command = val;
+        break;
+    case 0xf: /* config port */
+        break;
+    }
+}
+static uint32_t busmouse_ioport_read(void *opaque, uint32_t addr)
+{
+    BusmouseState *s = opaque;
+    uint32_t ret = 0x00;
+    static int interrupt_val = 0x01;
+
+    addr &= 0xf;
+    switch(addr) {
+    case 0xc: /* data port */
+        s->irq_pending = 0;
+        switch (s->command) {
+        case 0x00: /* no op? */
+            break;
+        case 0x80: /* x low */
+            ret = s->mouse_dx & 0xf;
+            ret += (7 - s->mouse_buttons) << 5; /* button state */
+            break;
+        case 0xa0: /* x high */
+            ret = (s->mouse_dx >> 4) & 0xf;
+            s->mouse_dx = 0;
+            break;
+        case 0xc0: /* y low */
+            ret = s->mouse_dy & 0xf;
+            break;
+        case 0xe0: /* y high */
+            ret =  (s->mouse_dy >> 4) & 0xf;
+            s->mouse_dy = 0;
+            break;
+        }
+        busmouse_update_irq(s);
+        break;
+    case 0xd: /* signature port */
+        ret = 0xa5; /* return signature byte */
+        busmouse_update_irq(s);
+        break;
+    case 0xe: /* control/interrupt port */
+        ret = interrupt_val;
+        interrupt_val = (interrupt_val << 1) & 0xff;
+        if (interrupt_val == 0) interrupt_val = 1;
+
+        break;
+    case 0xf: /* config port */
+        break;
+    }
+    return ret;
+}
+
+/* If fd is zero, it means that the busmouse device uses the console */
+BusmouseState *busmouse_init(int base, int irq, CharDriverState *chr)
+{
+    BusmouseState *s;
+
+    s = qemu_mallocz(sizeof(BusmouseState));
+    if (!s)
+        return NULL;
+    s->chr = chr;
+    s->hw_driver = 0;
+    s->irq = 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);
+    qemu_add_mouse_event_handler(busmouse_event, s,0,"Busmouse");
+
+    return s;
+}
diff -ruN qemu-0.9.0/hw/cirrus_vga.c qemu-0.9.0-nextstep/hw/cirrus_vga.c
--- qemu-0.9.0/hw/cirrus_vga.c Mon Feb  5 18:01:54 2007
+++ qemu-0.9.0-nextstep/hw/cirrus_vga.c Sun May 25 13:17:30 2008
@@ -3172,7 +3172,7 @@
    CirrusVGAState *s;
    int device_id;
   
-    device_id = CIRRUS_ID_CLGD5446;
+    device_id = CIRRUS_ID_CLGD5434;

    /* setup PCI configuration registers */
    d = (PCICirrusVGAState *)pci_register_device(bus, "Cirrus VGA",
diff -ruN qemu-0.9.0/hw/i8259.c qemu-0.9.0-nextstep/hw/i8259.c
--- qemu-0.9.0/hw/i8259.c Mon Feb  5 18:01:54 2007
+++ qemu-0.9.0-nextstep/hw/i8259.c Sun May 25 13:19:38 2008
@@ -119,7 +119,8 @@
       master, the IRQ coming from the slave is not taken into account
       for the priority computation. */
    mask = s->isr;
-    if (s->special_fully_nested_mode && s == &s->pics_state->pics[0])
+    //if (s->special_fully_nested_mode && s == &s->pics_state->pics[0])
+    if (s == &s->pics_state->pics[0])
        mask &= ~(1 << 2);
    cur_priority = get_priority(s, mask);
    if (priority < cur_priority) {
diff -ruN qemu-0.9.0/hw/pc.c qemu-0.9.0-nextstep/hw/pc.c
--- qemu-0.9.0/hw/pc.c Mon Feb  5 18:01:54 2007
+++ qemu-0.9.0-nextstep/hw/pc.c Sun May 25 13:13:11 2008
@@ -400,6 +400,9 @@
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)
{
@@ -655,6 +658,11 @@
            parallel_init(parallel_io[i], parallel_irq[i], parallel_hds[i]);
        }
    }
+
+    for(i = 0; i < 1; i++) {
+        busmouse_init(busmouse_io[i], busmouse_irq[i], 0);
+    }
+

    for(i = 0; i < nb_nics; i++) {
        nd = &nd_table[i];
diff -ruN qemu-0.9.0/hw/ps2.c qemu-0.9.0-nextstep/hw/ps2.c
--- qemu-0.9.0/hw/ps2.c Mon Feb  5 18:01:54 2007
+++ qemu-0.9.0-nextstep/hw/ps2.c Sun May 25 13:13:44 2008
@@ -560,7 +560,8 @@
    s->common.update_arg = update_arg;
    ps2_reset(&s->common);
    register_savevm("ps2mouse", 0, 2, ps2_mouse_save, ps2_mouse_load, s);
-    qemu_add_mouse_event_handler(ps2_mouse_event, s, 0, "QEMU PS/2 Mouse");
+//  disabled for busmouse
+//    qemu_add_mouse_event_handler(ps2_mouse_event, s, 0, "QEMU PS/2 Mouse");
    qemu_register_reset(ps2_reset, &s->common);
    return s;
}
diff -ruN qemu-0.9.0/vl.h qemu-0.9.0-nextstep/vl.h
--- qemu-0.9.0/vl.h Mon Feb  5 18:01:54 2007
+++ qemu-0.9.0-nextstep/vl.h Sun May 25 13:15:29 2008
@@ -348,6 +348,11 @@

#define MAX_PARALLEL_PORTS 3

+/* busmouse ports */
+
+#define MAX_BUSMOUSE_PORTS 1
+
+
extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];

/* VLANs support */
@@ -1008,6 +1013,12 @@

typedef struct ParallelState ParallelState;
ParallelState *parallel_init(int base, int irq, CharDriverState *chr);
+
+/* busmouse.c */
+
+typedef struct BusmouseState BusmouseState;
+BusmouseState *busmouse_init(int base, int irq, CharDriverState *chr);
+

/* i8259.c */


# include <wittycomment.h>

itomato

Thanks for this!!!

:D :D :D

I was able to install directly to hard disk on a machine without a floppy, and without fighting with those boot cds.

Now, perhaps I'll be able to build a good and proper ISO.

(Note: If you install with bus mouse, and add PS2 - you might want to remove the bus mouse before you boot, or else use the 'set mouse' command in the qemu monitor..  I lost mouse after I got the rest of the packages installed and ran Configure.app..)
-itomato

kb7sqi

Just FYI,
    I finally got a copy of the updated busmouse patch for qemu-0.9.1 from one of the guys on the qemu forums that updated it.  I compiled it under OpenSolaris/x86 & Solaris 10/sparc.  It works fine.  I'd like a an updated version of the libpcap patch.  If you want a copy of the patch, I can post it l8r.  The patch has changed quite a bit & now has an additional flag for NeXT systems. :-)   I'll have to ask about an updated libpcap patch.  Take care.

neozeed

Quote from: "kb7sqi"Just FYI,
    I finally got a copy of the updated busmouse patch for qemu-0.9.1 from one of the guys on the qemu forums that updated it.  I compiled it under OpenSolaris/x86 & Solaris 10/sparc.  It works fine.  I'd like a an updated version of the libpcap patch.  If you want a copy of the patch, I can post it l8r.  The patch has changed quite a bit & now has an additional flag for NeXT systems. :-)   I'll have to ask about an updated libpcap patch.  Take care.


Thats cool!  I was thinking about updating the libpcap patch, but I guess I don't have to worry about it anymore...

lol I know it was ugly, but it did compile... It's more so that I'd never programmed anything with libpcap.

The next thing I'm looking at is HECNet...
http://www.update.uu.se/~bqt/hecnet.html
I was thinking of ripping out the DecNET specifics, and interfacing it directly to qemu so that in addition to slirp you can join a "hecnet".. it'd allow for some kind of vpn like solution for Virtual machines...  Perhaps even a safe place to put legacy file/db/web/app servers without all the haxors.
# include <wittycomment.h>

neozeed

Quote from: "itomato"Thanks for this!!!

:D :D :D

I was able to install directly to hard disk on a machine without a floppy, and without fighting with those boot cds.

Now, perhaps I'll be able to build a good and proper ISO.

(Note: If you install with bus mouse, and add PS2 - you might want to remove the bus mouse before you boot, or else use the 'set mouse' command in the qemu monitor..  I lost mouse after I got the rest of the packages installed and ran Configure.app..)


Yeah I should have mentioned that... (about the busmouse/ps/2 mouse)..

I'm just glad this runs, and is free for us what? 5 NeXTSTEP intel users out there?
# include <wittycomment.h>

neozeed

reviving an old thread for a reason... anyways if you are going to use this qemu version on linux or Windows you really REALLY need to apply that patch.  Otherwise, it's our dear friend lost IRQ's and the PS/2 mouse doesn't work. :|

./configure --cc=gcc-3.4 --target-list=i386-softmmu --enable-vnc --disable-kqemu --disable-sdl --without-sdl --disable-gfx-check --static

I put a pre-compiled up binary here: qemu-090_static.tar.gz, which includes a static VNC version of Qemu 0.90 that you can run on any i386 (or x64 with i386 compat) machine, or any VPS you want to drop it off on.....

This isn't really a usability tutorial but something like this:

./qemu -L pc-bios  -hda 2GB.qcow  -boot c -vnc :0 -net nic -net user -m 32 -redir tcp:42323::23

will run it from the command line, redirect port 42323 into the VM's telnet port, and let you use the default port 0 for VNC to connect into it.  You can run it behind screen so it'll keep on running after you logoff.

If you really wanted to be evil  :twisted:  Qemu is 100% user mode code, no device drivers or special privileges are needed for high port NAT, you could shop something like lowendbox, and get a VPS, drop this linux onto there + OPENSTEP/Rhapsody and have that 1999 web server you've always wanted/needed.....  :roll:
# include <wittycomment.h>

cuby

Quote from: "neozeed"reviving an old thread for a reason... anyways if you are going to use this qemu version on linux or Windows you really REALLY need to apply that patch.  Otherwise, it's our dear friend lost IRQ's and the PS/2 mouse doesn't work. :|

Whow, good to see that my old busmouse emulation for qemu is still being used.

Back then, I was unable to find out what exactly caused the problems with qemu's PS/2 mouse emulation... with the Darwin sources at hand, I should have another look at this.

-- Michael

neozeed

Quote from: "cuby"
Quote from: "neozeed"reviving an old thread for a reason... anyways if you are going to use this qemu version on linux or Windows you really REALLY need to apply that patch.  Otherwise, it's our dear friend lost IRQ's and the PS/2 mouse doesn't work. :|

Whow, good to see that my old busmouse emulation for qemu is still being used.

Back then, I was unable to find out what exactly caused the problems with qemu's PS/2 mouse emulation... with the Darwin sources at hand, I should have another look at this.

-- Michael


For sure, or even try taking a shot at writing one...   There is those VMWare drivers with source, and in the kernel ...

http://unix.superglobalmegacorp.com/cgi-bin/cvsweb.cgi/kernel/bsd/dev/i386/?cvsroot=Darwin0

Although it looks like these are more baked into the kernel.  maybe the can also be turned into standalone? I really don't know  :oops:


Oh I should have added this one thing.... in the busmouse for Rhapsody, for some reason it reads the mice buttons wrong (although it works fine in NeXTSTEP/OPENSTEP so NeXT must have screwed something up)

if(buttons_state==1)
   s->mouse_buttons = 4;
else
   s->mouse_buttons = buttons_state;


I replaced this over the mouse_buttons=buttons_state ...
# include <wittycomment.h>