summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@benzedrine.nwnk.net>2007-07-02 18:41:55 -0400
committerAdam Jackson <ajax@benzedrine.nwnk.net>2007-07-02 18:41:55 -0400
commit028a00bc518dc6908839e8ce7c50ab1837100945 (patch)
treeb1887f777d96391e038dfedac3b5e1d25cae8586
parent00e8295b7e0c7c0ba97707903004272818e3d87d (diff)
Make x86emu's I/O cycle tracing more useful.
Print debug messages only when the appropriate debug bit is set in the 8086 state vector, so you can focus in on the call you're actually interested in.
-rw-r--r--hw/xfree86/int10/helper_exec.c117
-rw-r--r--hw/xfree86/x86emu/debug.c2
2 files changed, 61 insertions, 58 deletions
diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index d80de89cc..6e5cff923 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -8,7 +8,7 @@
*/
/*
- * To debug port accesses define PRINT_PORT.
+ * To debug port accesses define PRINT_PORT to 1.
* Note! You also have to comment out ioperm()
* in xf86EnableIO(). Otherwise we won't trap
* on PIO.
@@ -18,6 +18,8 @@
#include <xorg-config.h>
#endif
+#define PRINT_PORT 0
+
#include <unistd.h>
#include <X11/Xos.h>
@@ -27,6 +29,7 @@
#define _INT10_PRIVATE
#include "int10Defines.h"
#include "xf86int10.h"
+#include "x86emu/x86emui.h"
static int pciCfg1in(CARD16 addr, CARD32 *val);
static int pciCfg1out(CARD16 addr, CARD32 val);
@@ -40,6 +43,8 @@ static void SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set);
#define REG pInt
+static int pci_config_cycle = 0;
+
int
setup_int(xf86Int10InfoPtr pInt)
{
@@ -209,10 +214,9 @@ port_rep_inb(xf86Int10InfoPtr pInt,
{
register int inc = d_f ? -1 : 1;
CARD32 dst = base;
-#ifdef PRINT_PORT
- ErrorF(" rep_insb(%#x) %d bytes at %p %s\n",
- port, count, base, d_f ? "up" : "down");
-#endif
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" rep_insb(%#x) %d bytes at %8.8x %s\n",
+ port, count, base, d_f ? "up" : "down");
while (count--) {
MEM_WB(pInt, dst, x_inb(port));
dst += inc;
@@ -226,10 +230,9 @@ port_rep_inw(xf86Int10InfoPtr pInt,
{
register int inc = d_f ? -2 : 2;
CARD32 dst = base;
-#ifdef PRINT_PORT
- ErrorF(" rep_insw(%#x) %d bytes at %p %s\n",
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" rep_insw(%#x) %d bytes at %8.8x %s\n",
port, count, base, d_f ? "up" : "down");
-#endif
while (count--) {
MEM_WW(pInt, dst, x_inw(port));
dst += inc;
@@ -243,10 +246,9 @@ port_rep_inl(xf86Int10InfoPtr pInt,
{
register int inc = d_f ? -4 : 4;
CARD32 dst = base;
-#ifdef PRINT_PORT
- ErrorF(" rep_insl(%#x) %d bytes at %p %s\n",
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" rep_insl(%#x) %d bytes at %8.8x %s\n",
port, count, base, d_f ? "up" : "down");
-#endif
while (count--) {
MEM_WL(pInt, dst, x_inl(port));
dst += inc;
@@ -260,10 +262,9 @@ port_rep_outb(xf86Int10InfoPtr pInt,
{
register int inc = d_f ? -1 : 1;
CARD32 dst = base;
-#ifdef PRINT_PORT
- ErrorF(" rep_outb(%#x) %d bytes at %p %s\n",
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" rep_outb(%#x) %d bytes at %8.8x %s\n",
port, count, base, d_f ? "up" : "down");
-#endif
while (count--) {
x_outb(port, MEM_RB(pInt, dst));
dst += inc;
@@ -277,10 +278,9 @@ port_rep_outw(xf86Int10InfoPtr pInt,
{
register int inc = d_f ? -2 : 2;
CARD32 dst = base;
-#ifdef PRINT_PORT
- ErrorF(" rep_outw(%#x) %d bytes at %p %s\n",
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" rep_outw(%#x) %d bytes at %8.8x %s\n",
port, count, base, d_f ? "up" : "down");
-#endif
while (count--) {
x_outw(port, MEM_RW(pInt, dst));
dst += inc;
@@ -294,10 +294,9 @@ port_rep_outl(xf86Int10InfoPtr pInt,
{
register int inc = d_f ? -4 : 4;
CARD32 dst = base;
-#ifdef PRINT_PORT
- ErrorF(" rep_outl(%#x) %d bytes at %p %s\n",
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" rep_outl(%#x) %d bytes at %8.8x %s\n",
port, count, base, d_f ? "up" : "down");
-#endif
while (count--) {
x_outl(port, MEM_RL(pInt, dst));
dst += inc;
@@ -314,9 +313,8 @@ x_inb(CARD16 port)
Int10Current->inb40time++;
val = (CARD8)(Int10Current->inb40time >>
((Int10Current->inb40time & 1) << 3));
-#ifdef PRINT_PORT
- ErrorF(" inb(%#x) = %2.2x\n", port, val);
-#endif
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" inb(%#x) = %2.2x\n", port, val);
#ifdef __NOT_YET__
} else if (port < 0x0100) { /* Don't interfere with mainboard */
val = 0;
@@ -327,12 +325,10 @@ x_inb(CARD16 port)
stack_trace(Int10Current);
}
#endif /* __NOT_YET__ */
- } else {
- if (!pciCfg1inb(port, &val))
- val = inb(Int10Current->ioBase + port);
-#ifdef PRINT_PORT
- ErrorF(" inb(%#x) = %2.2x\n", port, val);
-#endif
+ } else if (!pciCfg1inb(port, &val)) {
+ val = inb(Int10Current->ioBase + port);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" inb(%#x) = %2.2x\n", port, val);
}
return val;
}
@@ -351,13 +347,11 @@ x_inw(CARD16 port)
*/
X_GETTIMEOFDAY(&tv);
val = (CARD16)(tv.tv_usec / 3);
- } else {
- if (!pciCfg1inw(port, &val))
- val = inw(Int10Current->ioBase + port);
+ } else if (!pciCfg1inw(port, &val)) {
+ val = inw(Int10Current->ioBase + port);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" inw(%#x) = %4.4x\n", port, val);
}
-#ifdef PRINT_PORT
- ErrorF(" inw(%#x) = %4.4x\n", port, val);
-#endif
return val;
}
@@ -374,9 +368,8 @@ x_outb(CARD16 port, CARD8 val)
*/
X_GETTIMEOFDAY(&tv);
Int10Current->inb40time = (CARD16)(tv.tv_usec | 1);
-#ifdef PRINT_PORT
- ErrorF(" outb(%#x, %2.2x)\n", port, val);
-#endif
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" outb(%#x, %2.2x)\n", port, val);
#ifdef __NOT_YET__
} else if (port < 0x0100) { /* Don't interfere with mainboard */
xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2,
@@ -386,24 +379,22 @@ x_outb(CARD16 port, CARD8 val)
stack_trace(Int10Current);
}
#endif /* __NOT_YET__ */
- } else {
-#ifdef PRINT_PORT
- ErrorF(" outb(%#x, %2.2x)\n", port, val);
-#endif
- if (!pciCfg1outb(port, val))
- outb(Int10Current->ioBase + port, val);
+ } else if (!pciCfg1outb(port, val)) {
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" outb(%#x, %2.2x)\n", port, val);
+ outb(Int10Current->ioBase + port, val);
}
}
void
x_outw(CARD16 port, CARD16 val)
{
-#ifdef PRINT_PORT
- ErrorF(" outw(%#x, %4.4x)\n", port, val);
-#endif
- if (!pciCfg1outw(port, val))
+ if (!pciCfg1outw(port, val)) {
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" outw(%#x, %4.4x)\n", port, val);
outw(Int10Current->ioBase + port, val);
+ }
}
CARD32
@@ -411,24 +402,22 @@ x_inl(CARD16 port)
{
CARD32 val;
- if (!pciCfg1in(port, &val))
+ if (!pciCfg1in(port, &val)) {
val = inl(Int10Current->ioBase + port);
-
-#ifdef PRINT_PORT
- ErrorF(" inl(%#x) = %8.8x\n", port, val);
-#endif
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" inl(%#x) = %8.8x\n", port, val);
+ }
return val;
}
void
x_outl(CARD16 port, CARD32 val)
{
-#ifdef PRINT_PORT
- ErrorF(" outl(%#x, %8.8x)\n", port, val);
-#endif
-
- if (!pciCfg1out(port, val))
+ if (!pciCfg1out(port, val)) {
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" outl(%#x, %8.8x)\n", port, val);
outl(Int10Current->ioBase + port, val);
+ }
}
CARD8
@@ -480,6 +469,8 @@ pciCfg1in(CARD16 addr, CARD32 *val)
}
if (addr == 0xCFC) {
*val = pciReadLong(Int10Current->Tag, OFFSET(PciCfg1Addr));
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_inl(%#x) = %8.8x\n", PciCfg1Addr, *val);
return 1;
}
return 0;
@@ -493,6 +484,8 @@ pciCfg1out(CARD16 addr, CARD32 val)
return 1;
}
if (addr == 0xCFC) {
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_outl(%#x, %8.8x)\n", PciCfg1Addr, val);
pciWriteLong(Int10Current->Tag, OFFSET(PciCfg1Addr), val);
return 1;
}
@@ -512,6 +505,8 @@ pciCfg1inw(CARD16 addr, CARD16 *val)
if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
offset = addr - 0xCFC;
*val = pciReadWord(Int10Current->Tag, OFFSET(PciCfg1Addr) + offset);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_inw(%#x) = %4.4x\n", PciCfg1Addr + offset, *val);
return 1;
}
return 0;
@@ -530,6 +525,8 @@ pciCfg1outw(CARD16 addr, CARD16 val)
}
if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
offset = addr - 0xCFC;
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_outw(%#x, %4.4x)\n", PciCfg1Addr + offset, val);
pciWriteWord(Int10Current->Tag, OFFSET(PciCfg1Addr) + offset, val);
return 1;
}
@@ -549,6 +546,8 @@ pciCfg1inb(CARD16 addr, CARD8 *val)
if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
offset = addr - 0xCFC;
*val = pciReadByte(Int10Current->Tag, OFFSET(PciCfg1Addr) + offset);
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_inb(%#x) = %2.2x\n", PciCfg1Addr + offset, *val);
return 1;
}
return 0;
@@ -567,6 +566,8 @@ pciCfg1outb(CARD16 addr, CARD8 val)
}
if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
offset = addr - 0xCFC;
+ if (PRINT_PORT && DEBUG_IO_TRACE())
+ ErrorF(" cfg_outb(%#x, %2.2x)\n", PciCfg1Addr + offset, val);
pciWriteByte(Int10Current->Tag, OFFSET(PciCfg1Addr) + offset, val);
return 1;
}
diff --git a/hw/xfree86/x86emu/debug.c b/hw/xfree86/x86emu/debug.c
index 6fd7f11cf..5eda90805 100644
--- a/hw/xfree86/x86emu/debug.c
+++ b/hw/xfree86/x86emu/debug.c
@@ -38,6 +38,8 @@
****************************************************************************/
#include "x86emu/x86emui.h"
+#include <stdio.h>
+#include <string.h>
#ifndef NO_SYS_HEADERS
#include <stdarg.h>
#include <stdlib.h>