Difference between revisions of "Qemu-0.9.0-openstep-busmouse-2.diff"
From Computer History Wiki
(diff needs formatting......) |
m (fixed the diff's formatting) |
||
Line 38: | Line 38: | ||
+ * | + * | ||
+ * Permission is hereby granted, free of charge, to any person obtaining copy | + * Permission is hereby granted, free of charge, to any person obtaining copy | ||
− | + | + * of this software and associated documentation files (the "Software"), to deal | |
− | + * of this software and associated documentation files (the "Software"), to | ||
− | |||
+ * in the Software without restriction, including without limitation the rights | + * in the Software without restriction, including without limitation the rights | ||
− | |||
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
+ * copies of the Software, and to permit persons to whom the Software is | + * copies of the Software, and to permit persons to whom the Software is | ||
Line 54: | Line 51: | ||
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | + * 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 | + | + * 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 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
+ * THE SOFTWARE. | + * THE SOFTWARE. |
Revision as of 17:14, 4 July 2009
This diff adds busmouse support to Qemu 0.8.0
Caveat
There may be some wordwrap issues as I just copied this out of a terminal... But this diff is too important to lose!
Credit
Full credit goes to Michael Engel who uploaded this diff onto the Qemu-devel list
Dr. rer. nat. Michael Engel - [EMAIL PROTECTED] University of Marburg - Dept. of Mathematics and Computer Science Hans-Meerwein-Str. - D-35032 Marburg, Germany Phone: +49 6421 / 28 21562 - Fax: +49 6421 / 28 21573
diff
diff -ruN qemu-0.9.0-dist/Makefile.target qemu-0.9.0/Makefile.target --- qemu-0.9.0-dist/Makefile.target Mon Feb 5 18:01:54 2007 +++ qemu-0.9.0/Makefile.target Sat Jul 4 11:54:57 2009 @@ -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-dist/hw/busmouse.c qemu-0.9.0/hw/busmouse.c --- qemu-0.9.0-dist/hw/busmouse.c Wed Dec 31 19:00:00 1969 +++ qemu-0.9.0/hw/busmouse.c Sat Jul 4 12:00:58 2009 @@ -0,0 +1,160 @@ +/* + * 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 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, "QEMU BusMouse Mouse"); + + return s; +} diff -ruN qemu-0.9.0-dist/hw/dma.c qemu-0.9.0/hw/dma.c --- qemu-0.9.0-dist/hw/dma.c Mon Feb 5 18:01:54 2007 +++ qemu-0.9.0/hw/dma.c Sat Jul 4 11:55:32 2009 @@ -198,7 +198,7 @@ switch (iport) { case 0x08: /* command */ if ((data != 0) && (data & CMD_NOT_SUPPORTED)) { - dolog ("command %#x not supported\n", data); +// dolog ("command %#x not supported\n", data); return; } d->command = data; diff -ruN qemu-0.9.0-dist/hw/pc.c qemu-0.9.0/hw/pc.c --- qemu-0.9.0-dist/hw/pc.c Mon Feb 5 18:01:54 2007 +++ qemu-0.9.0/hw/pc.c Sat Jul 4 11:57:17 2009 @@ -400,6 +400,10 @@ 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 +659,10 @@ 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-dist/hw/ps2.c qemu-0.9.0/hw/ps2.c --- qemu-0.9.0-dist/hw/ps2.c Mon Feb 5 18:01:54 2007 +++ qemu-0.9.0/hw/ps2.c Sat Jul 4 12:00:16 2009 @@ -560,7 +560,7 @@ 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"); + /*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-dist/hw/sb16.c qemu-0.9.0/hw/sb16.c --- qemu-0.9.0-dist/hw/sb16.c Mon Feb 5 18:01:54 2007 +++ qemu-0.9.0/hw/sb16.c Sat Jul 4 11:57:29 2009 @@ -50,7 +50,7 @@ int dma; int hdma; int port; -} conf = {5, 4, 5, 1, 5, 0x220}; +} conf = {5, 4, 7, 1, 5, 0x220}; typedef struct SB16State { QEMUSoundCard card; diff -ruN qemu-0.9.0-dist/vl.h qemu-0.9.0/vl.h --- qemu-0.9.0-dist/vl.h Mon Feb 5 18:01:54 2007 +++ qemu-0.9.0/vl.h Sat Jul 4 11:59:07 2009 @@ -346,7 +346,11 @@ /* parallel ports */ -#define MAX_PARALLEL_PORTS 3 +#define MAX_PARALLEL_PORTS 0 + +/* busmouse ports */ + +#define MAX_BUSMOUSE_PORTS 1 extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; @@ -1008,6 +1012,11 @@ 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 */