qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] Port E9 hack, for debugging purposes


From: Thomas Petazzoni
Subject: Re: [Qemu-devel] [PATCH] Port E9 hack, for debugging purposes
Date: Wed, 26 Jan 2005 23:24:51 +0100
User-agent: Debian Thunderbird 1.0 (X11/20050116)

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 - address@hidden
http://thomas.enix.org - Jabber: address@hidden
KOS: http://kos.enix.org/ - SOS: http://sos.enix.org
Fingerprint : 0BE1 4CF3 CEA4 AC9D CC6E  1624 F653 CB30 98D3 F7A7
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]);
/*
 * 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;
}

reply via email to

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