[SOS] Remise à jour du patch pour qemu.

Christophe Lucas clucas at rotomalug.org
Mer 25 Mai 15:11:25 CEST 2005


Thomas Petazzoni (thomas.petazzoni at enix.org) wrote:
> Salut,
> 
> Christophe Lucas wrote:
> 
> >Voilà :)
> 
> Merci !
> 
> Il y a quelques temps, j'avais tenté de faire intégrer un tel patch dans 
> le Qemu officiel. Je l'avais donc implémenté "proprement" en utilisant 
> l'interface de périphériques caractères de Qemu, qui permet par exemple 
> de faire "-serial stdio", "-serial vc". Avec mon patch, on pouvait de la 
> même façon faire "-port-e9 stdio", "-port-e9 vc", etc.
> 
> Le patch que j'avais envoyé en janvier : 
> http://lists.gnu.org/archive/html/qemu-devel/2005-01/msg00391.html
> 
> Il faudrait le mettre à jour, et supprimer le fait qu'on puisse avoir 
> plusieurs ports E9.

Bon voilà le patch sans la réduction à un seul port.

	~Christophe
-------------- section suivante --------------
diff -urpN qemu-0.7.0/hw/pc.c qemu-0.7.0-clucas/hw/pc.c
--- qemu-0.7.0/hw/pc.c	2005-04-27 22:52:05.000000000 +0200
+++ qemu-0.7.0-clucas/hw/pc.c	2005-05-25 14:05:02.070101504 +0200
@@ -589,6 +589,12 @@ void pc_init(int ram_size, int vga_ram_s
 
     cmos_init(ram_size, boot_device, bs_table);
 
+	for(i = 0; i < MAX_PORT_E9_PORTS; i++) {
+		if(port_e9_hds[i]) {
+			port_e9_init(port_e9_hds[i]);
+		}
+	}
+
     /* must be done after all PCI devices are instanciated */
     /* XXX: should be done in the Bochs BIOS */
     if (pci_enabled) {
diff -urpN qemu-0.7.0/Makefile.target qemu-0.7.0-clucas/Makefile.target
--- qemu-0.7.0/Makefile.target	2005-04-27 22:52:05.000000000 +0200
+++ qemu-0.7.0-clucas/Makefile.target	2005-05-25 13:57:25.263546656 +0200
@@ -340,7 +340,7 @@ endif
 ifeq ($(TARGET_BASE_ARCH), i386)
 # Hardware support
 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
-VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
+VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o port_e9.o
 VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o
 endif
 ifeq ($(TARGET_ARCH), ppc)
diff -urpN qemu-0.7.0/port_e9.c qemu-0.7.0-clucas/port_e9.c
--- qemu-0.7.0/port_e9.c	1970-01-01 01:00:00.000000000 +0100
+++ qemu-0.7.0-clucas/port_e9.c	2005-05-25 14:09:36.406396048 +0200
@@ -0,0 +1,51 @@
+/*
+ * QEMU Port 0xe9 hack
+ *
+ * Copyright (c) 2000-2004 E. Marty, the bochs team, D. Decotigny
+ *
+ * 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 <stdio.h>
+#include <unistd.h>
+#include <inttypes.h>
+
+#include "vl.h"
+
+static void port_e9_write(void *opaque, uint32_t address, uint32_t data)
+{
+	CharDriverState *chr;
+	chr = opaque;
+
+	qemu_chr_write(chr, & data, 1);
+}
+
+static uint32_t port_e9_read(void *opaque, uint32_t address)
+{
+	return 0xE9;
+}
+
+CharDriverState *port_e9_init (CharDriverState *chr)
+{
+	register_ioport_write(0xe9, 1, 1, port_e9_write, chr);
+	register_ioport_read (0xe9, 1, 1, port_e9_read,  chr);
+
+	return chr;
+}
+
diff -urpN qemu-0.7.0/vl.c qemu-0.7.0-clucas/vl.c
--- qemu-0.7.0/vl.c	2005-04-27 22:52:05.000000000 +0200
+++ qemu-0.7.0-clucas/vl.c	2005-05-25 14:26:49.369361808 +0200
@@ -146,6 +146,7 @@ int graphic_depth = 15;
 int full_screen = 0;
 TextConsole *vga_console;
 CharDriverState *serial_hds[MAX_SERIAL_PORTS];
+CharDriverState *port_e9_hds[MAX_PORT_E9_PORTS];
 CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
 
 /***********************************************************/
@@ -2874,6 +2875,7 @@ enum {
     QEMU_OPTION_monitor,
     QEMU_OPTION_serial,
     QEMU_OPTION_parallel,
+	QEMU_OPTION_port_e9,
     QEMU_OPTION_loadvm,
     QEMU_OPTION_full_screen,
     QEMU_OPTION_pidfile,
@@ -2943,6 +2945,7 @@ const QEMUOption qemu_options[] = {
     { "monitor", 1, QEMU_OPTION_monitor },
     { "serial", 1, QEMU_OPTION_serial },
     { "parallel", 1, QEMU_OPTION_parallel },
+	{ "port-e9", 1, QEMU_OPTION_port_e9 },
     { "loadvm", HAS_ARG, QEMU_OPTION_loadvm },
     { "full-screen", 0, QEMU_OPTION_full_screen },
     { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
@@ -3025,6 +3028,8 @@ int main(int argc, char **argv)
     char monitor_device[128];
     char serial_devices[MAX_SERIAL_PORTS][128];
     int serial_device_index;
+	char port_e9_devices[MAX_PORT_E9_PORTS][128];
+	int port_e9_device_index;
     char parallel_devices[MAX_PARALLEL_PORTS][128];
     int parallel_device_index;
     const char *loadvm = NULL;
@@ -3064,6 +3069,11 @@ int main(int argc, char **argv)
     for(i = 1; i < MAX_PARALLEL_PORTS; i++)
         parallel_devices[i][0] = '\0';
     parallel_device_index = 0;
+
+	pstrcpy(port_e9_devices[0], sizeof(port_e9_devices[0]), "vc");
+	for(i = 1; i < MAX_PORT_E9_PORTS; i++)
+		port_e9_devices[i][0] = '\0';
+	port_e9_device_index = 0;
     
     nb_tun_fds = 0;
     net_if_type = -1;
@@ -3388,6 +3398,16 @@ int main(int argc, char **argv)
                         sizeof(parallel_devices[0]), optarg);
                 parallel_device_index++;
                 break;
+
+			case QEMU_OPTION_port_e9:
+				if (port_e9_device_index >= MAX_PORT_E9_PORTS) {
+					fprintf(stderr, "qemu: too many port e9 ports\n");
+					exit(1);
+				}
+				pstrcpy(port_e9_devices[port_e9_device_index],
+					sizeof(port_e9_devices[0]), optarg);
+					port_e9_device_index++;
+				break;
 	    case QEMU_OPTION_loadvm:
 		loadvm = optarg;
 		break;
@@ -3626,6 +3646,19 @@ int main(int argc, char **argv)
         }
     }
 
+	for(i = 0; i < MAX_PORT_E9_PORTS; i++) {
+		if (port_e9_devices[i][0] != '\0') {
+			port_e9_hds[i] = qemu_chr_open(port_e9_devices[i]);
+			if (!port_e9_hds[i]) {
+				fprintf(stderr, "qemu: could not open port e9 device '%s'\n", 
+					port_e9_devices[i]);
+				exit(1);
+			}
+			if (!strcmp(port_e9_devices[i], "vc"))
+				qemu_chr_printf(port_e9_hds[i], "port_e9_%d console\n", i);
+		}
+	}
+
     /* setup cpu signal handlers for MMU / self modifying code handling */
 #if !defined(CONFIG_SOFTMMU)
     
diff -urpN qemu-0.7.0/vl.h qemu-0.7.0-clucas/vl.h
--- qemu-0.7.0/vl.h	2005-04-27 22:52:05.000000000 +0200
+++ qemu-0.7.0-clucas/vl.h	2005-05-25 14:04:17.064943328 +0200
@@ -232,6 +232,16 @@ extern CharDriverState *serial_hds[MAX_S
 
 extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
 
+/* port E9 ports */
+
+#define MAX_PORT_E9_PORTS 1
+
+#if (MAX_PORT_E9_PORTS != 1)
+ #error "No more than one port E9 is supported"
+#endif
+
+extern CharDriverState *port_e9_hds[MAX_PORT_E9_PORTS];
+
 /* network redirectors support */
 
 #define MAX_NICS 8
@@ -650,6 +660,10 @@ SerialState *serial_init(int base, int i
 typedef struct ParallelState ParallelState;
 ParallelState *parallel_init(int base, int irq, CharDriverState *chr);
 
+/* port-e9.c */
+
+CharDriverState *port_e9_init(CharDriverState *chr);
+
 /* i8259.c */
 
 void pic_set_irq(int irq, int level);


Plus d'informations sur la liste de diffusion Sos