All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@enix.org>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Port E9 hack, for debugging purposes
Date: Wed, 26 Jan 2005 23:24:51 +0100	[thread overview]
Message-ID: <41F818B3.1020106@enix.org> (raw)
In-Reply-To: <41EC35AC.7090006@bellard.org>

[-- Attachment #1: Type: text/plain, Size: 1086 bytes --]

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

[-- Attachment #2: port-e9.patch --]
[-- Type: text/plain, Size: 5175 bytes --]

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]);

[-- Attachment #3: port-e9.c --]
[-- Type: text/x-csrc, Size: 1673 bytes --]

/*
 * 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	other threads:[~2005-01-26 22:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-15 17:06 [Qemu-devel] [PATCH] Port E9 hack, for debugging purposes Thomas Petazzoni
2005-01-17 13:31 ` Johannes Schindelin
2005-01-17 13:47   ` Thomas Petazzoni
2005-01-17 22:01     ` Fabrice Bellard
2005-01-26 22:24       ` Thomas Petazzoni [this message]
2005-01-26 23:57         ` James Mastros
2005-01-27  8:19           ` Thomas Petazzoni
2005-02-03 12:29         ` Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41F818B3.1020106@enix.org \
    --to=thomas.petazzoni@enix.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.