qemu-devel
[Top][All Lists]
Advanced

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

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


From: Thomas Petazzoni
Subject: [Qemu-devel] [PATCH] Port E9 hack, for debugging purposes
Date: Sat, 15 Jan 2005 18:06:45 +0100
User-agent: Mozilla Thunderbird 0.9 (X11/20041124)

Hello,

Enclosed you'll find a patch that adds port E9 hack support for Qemu. Port E9 hack is a feature available in the Bochs emulator, which is very nice for OS developers working on their own toy OS.

It simply adds a device on the I/O port 0xE9. Every character written to this device is written to the console in which Qemu is running. This allows the application running inside Qemu to output tons of debugging messages without the need to have a powerful console driver.

The device also answers 0xE9 to every read on this port. This allows the application running inside Qemu to test whether the port E9 hack is enabled or not.

The port E9 hack features can be enabled/disabled at compile time using the configure script. By default, it's set to off.

Enclosed are :
- port-e9-hack.patch, which touches Makefile.target, configure, vl.h and hw/pc.c - port-e9.c, the implementation of the port E9 device, which should be placed inside the hw/ directory.

Is it possible to include this feature in Qemu ?

Thanks,

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     15 Jan 2005 17:00:17 -0000
@@ -339,6 +339,9 @@
 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
 endif
+ifdef CONFIG_PORT_E9_HACK
+VL_OBJS+=port-e9.o
+endif
 
 VL_LDFLAGS=
 # specific flags are needed for non soft mmu emulator
Index: configure
===================================================================
RCS file: /cvsroot/qemu/qemu/configure,v
retrieving revision 1.51
diff -u -u -r1.51 configure
--- configure   10 Jan 2005 23:18:50 -0000      1.51
+++ configure   15 Jan 2005 17:00:20 -0000
@@ -76,6 +76,7 @@
 gdbstub="yes"
 slirp="yes"
 adlib="no"
+port_e9_hack="no"
 oss="no"
 fmod="no"
 fmod_lib=""
@@ -168,7 +169,9 @@
   --disable-slirp) slirp="no"
   ;; 
   --enable-adlib) adlib="yes"
-  ;; 
+  ;;
+  --enable-port-e9-hack) port_e9_hack="yes"
+  ;;
   esac
 done
 
@@ -310,6 +313,7 @@
 echo "  --enable-fmod            enable FMOD audio output driver"
 echo "  --fmod-lib               path to FMOD library"
 echo "  --fmod-inc               path to FMOD includes"
+echo "  --enable-port-e9-hack    enable port E9 hack"
 echo ""
 echo "NOTE: The object files are build at the place where configure is 
launched"
 exit 1
@@ -352,6 +356,7 @@
 echo "SDL static link   $sdl_static"
 echo "mingw32 support   $mingw32"
 echo "Adlib support     $adlib"
+echo "Port E9 hack      $port_e9_hack"
 echo -n "FMOD support      $fmod"
 if test $fmod = "yes"; then
     echo -n " (lib='$fmod_lib' include='$fmod_inc')"
@@ -464,6 +469,10 @@
   echo "CONFIG_ADLIB=yes" >> $config_mak
   echo "#define CONFIG_ADLIB 1" >> $config_h
 fi
+if test "$port_e9_hack" = "yes" ; then
+  echo "CONFIG_PORT_E9_HACK=yes" >> $config_mak
+  echo "#define CONFIG_PORT_E9_HACK 1" >> $config_h
+fi
 if test "$oss" = "yes" ; then
   echo "CONFIG_OSS=yes" >> $config_mak
   echo "#define CONFIG_OSS 1" >> $config_h
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        15 Jan 2005 17:00:20 -0000
@@ -828,4 +828,9 @@
 
 int gdbserver_start(int port);
 
+#ifdef CONFIG_PORT_E9_HACK
+/* port-e9.c */
+void port_e9_init(void);
+#endif /* CONFIG_PORT_E9_HACK */
+
 #endif /* VL_H */
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     15 Jan 2005 17:00:20 -0000
@@ -586,7 +586,9 @@
     }
 
     floppy_controller = fdctrl_init(6, 2, 0, 0x3f0, fd_table);
-
+#ifdef CONFIG_PORT_E9_HACK
+    port_e9_init();
+#endif
     cmos_init(ram_size, boot_device, bs_table);
 
     /* must be done after all PCI devices are instanciated */
/*
 * 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 bochs_e9_write(void *opaque, uint32_t address, uint32_t data)
{
  write(fileno(stdout), &data, 1);
}

static uint32_t bochs_e9_read(void *opaque, uint32_t address)
{
  return 0xE9;
}

void port_e9_init ()
{
  register_ioport_write(0xe9, 1, 1, bochs_e9_write, NULL);
  register_ioport_read (0xe9, 1, 1, bochs_e9_read,  NULL);
}

reply via email to

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