From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1CtvnH-0000vx-PV for qemu-devel@nongnu.org; Wed, 26 Jan 2005 17:37:48 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1CtvnD-0000tX-Tj for qemu-devel@nongnu.org; Wed, 26 Jan 2005 17:37:45 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CtvnC-0000t0-RE for qemu-devel@nongnu.org; Wed, 26 Jan 2005 17:37:43 -0500 Received: from [213.228.0.176] (helo=postfix4-2.free.fr) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Ctvap-00082i-Uq for qemu-devel@nongnu.org; Wed, 26 Jan 2005 17:24:56 -0500 Received: from [192.168.1.2] (humanoidz.org [81.56.146.155]) by postfix4-2.free.fr (Postfix) with ESMTP id 69FBA2BBE09 for ; Wed, 26 Jan 2005 23:24:52 +0100 (CET) Message-ID: <41F818B3.1020106@enix.org> Date: Wed, 26 Jan 2005 23:24:51 +0100 From: Thomas Petazzoni MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Port E9 hack, for debugging purposes References: <41E94DA5.9030809@enix.org> <41EBC1FB.8050506@enix.org> <41EC35AC.7090006@bellard.org> In-Reply-To: <41EC35AC.7090006@bellard.org> Content-Type: multipart/mixed; boundary="------------090008020809090304090405" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------090008020809090304090405 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello, Fabrice Bellard wrote: > I would accept the "e9 hack" only if it was dynamically configurable and > if it used a generic character device (as the serial or parallel ports) > to output its results. The command line option should be '-port-e9 > stdio' or something similar. Enclosed is a first try to convert port E9 hack to use the character device framework of Qemu. I've tested vc, stdio, null and pty outputs. They all work. Some comments : - Support is limited to one port E9, so I've added a #error assertion in vl.h. I'm not sure if's the correct place, correct way to do it. - Port E9 doesn't support reading, so I have not implemented read event handlers. The purpose of the ioport_read function is only to return 0xE9. This allows the guest OS to test whether the port E9 hack is available or not. Feedback welcome. Thomas -- PETAZZONI Thomas - thomas.petazzoni@enix.org http://thomas.enix.org - Jabber: thomas.petazzoni@jabber.dk KOS: http://kos.enix.org/ - SOS: http://sos.enix.org Fingerprint : 0BE1 4CF3 CEA4 AC9D CC6E 1624 F653 CB30 98D3 F7A7 --------------090008020809090304090405 Content-Type: text/plain; name="port-e9.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="port-e9.patch" Index: Makefile.target =================================================================== RCS file: /cvsroot/qemu/qemu/Makefile.target,v retrieving revision 1.55 diff -u -u -r1.55 Makefile.target --- Makefile.target 15 Jan 2005 12:02:56 -0000 1.55 +++ Makefile.target 26 Jan 2005 22:20:17 -0000 @@ -316,7 +316,7 @@ # 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+= cirrus_vga.o mixeng.o apic.o parallel.o +VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o port-e9.o endif ifeq ($(TARGET_ARCH), ppc) VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV) Index: vl.c =================================================================== RCS file: /cvsroot/qemu/qemu/vl.c,v retrieving revision 1.117 diff -u -u -r1.117 vl.c --- vl.c 15 Jan 2005 21:50:11 -0000 1.117 +++ vl.c 26 Jan 2005 22:20:19 -0000 @@ -136,6 +136,7 @@ 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]; /***********************************************************/ @@ -2845,6 +2846,7 @@ QEMU_OPTION_monitor, QEMU_OPTION_serial, QEMU_OPTION_parallel, + QEMU_OPTION_port_e9, QEMU_OPTION_loadvm, QEMU_OPTION_full_screen, QEMU_OPTION_pidfile, @@ -2908,6 +2910,7 @@ { "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 }, @@ -2990,6 +2993,8 @@ 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; @@ -3029,7 +3034,12 @@ 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; nb_nics = 1; @@ -3349,6 +3359,15 @@ 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; @@ -3585,6 +3604,19 @@ } } + 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) Index: vl.h =================================================================== RCS file: /cvsroot/qemu/qemu/vl.h,v retrieving revision 1.66 diff -u -u -r1.66 vl.h --- vl.h 15 Jan 2005 12:02:56 -0000 1.66 +++ vl.h 26 Jan 2005 22:20:19 -0000 @@ -230,6 +230,16 @@ 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 @@ -643,6 +653,10 @@ 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); Index: hw/pc.c =================================================================== RCS file: /cvsroot/qemu/qemu/hw/pc.c,v retrieving revision 1.35 diff -u -u -r1.35 pc.c --- hw/pc.c 15 Jan 2005 12:02:56 -0000 1.35 +++ hw/pc.c 26 Jan 2005 22:20:19 -0000 @@ -547,6 +547,12 @@ } } + for(i = 0; i < MAX_PORT_E9_PORTS; i++) { + if(port_e9_hds[i]) { + port_e9_init(port_e9_hds[i]); + } + } + if (pci_enabled) { for(i = 0; i < nb_nics; i++) { pci_ne2000_init(pci_bus, &nd_table[i]); --------------090008020809090304090405 Content-Type: text/x-csrc; name="port-e9.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="port-e9.c" /* * 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 #include #include #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; } --------------090008020809090304090405--