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.
This commit is contained in:
Adam Jackson 2007-07-02 18:41:55 -04:00
parent 00e8295b7e
commit 028a00bc51
2 changed files with 61 additions and 58 deletions

View File

@ -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() * Note! You also have to comment out ioperm()
* in xf86EnableIO(). Otherwise we won't trap * in xf86EnableIO(). Otherwise we won't trap
* on PIO. * on PIO.
@ -18,6 +18,8 @@
#include <xorg-config.h> #include <xorg-config.h>
#endif #endif
#define PRINT_PORT 0
#include <unistd.h> #include <unistd.h>
#include <X11/Xos.h> #include <X11/Xos.h>
@ -27,6 +29,7 @@
#define _INT10_PRIVATE #define _INT10_PRIVATE
#include "int10Defines.h" #include "int10Defines.h"
#include "xf86int10.h" #include "xf86int10.h"
#include "x86emu/x86emui.h"
static int pciCfg1in(CARD16 addr, CARD32 *val); static int pciCfg1in(CARD16 addr, CARD32 *val);
static int pciCfg1out(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 #define REG pInt
static int pci_config_cycle = 0;
int int
setup_int(xf86Int10InfoPtr pInt) setup_int(xf86Int10InfoPtr pInt)
{ {
@ -209,10 +214,9 @@ port_rep_inb(xf86Int10InfoPtr pInt,
{ {
register int inc = d_f ? -1 : 1; register int inc = d_f ? -1 : 1;
CARD32 dst = base; CARD32 dst = base;
#ifdef PRINT_PORT if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" rep_insb(%#x) %d bytes at %p %s\n", ErrorF(" rep_insb(%#x) %d bytes at %8.8x %s\n",
port, count, base, d_f ? "up" : "down"); port, count, base, d_f ? "up" : "down");
#endif
while (count--) { while (count--) {
MEM_WB(pInt, dst, x_inb(port)); MEM_WB(pInt, dst, x_inb(port));
dst += inc; dst += inc;
@ -226,10 +230,9 @@ port_rep_inw(xf86Int10InfoPtr pInt,
{ {
register int inc = d_f ? -2 : 2; register int inc = d_f ? -2 : 2;
CARD32 dst = base; CARD32 dst = base;
#ifdef PRINT_PORT if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" rep_insw(%#x) %d bytes at %p %s\n", ErrorF(" rep_insw(%#x) %d bytes at %8.8x %s\n",
port, count, base, d_f ? "up" : "down"); port, count, base, d_f ? "up" : "down");
#endif
while (count--) { while (count--) {
MEM_WW(pInt, dst, x_inw(port)); MEM_WW(pInt, dst, x_inw(port));
dst += inc; dst += inc;
@ -243,10 +246,9 @@ port_rep_inl(xf86Int10InfoPtr pInt,
{ {
register int inc = d_f ? -4 : 4; register int inc = d_f ? -4 : 4;
CARD32 dst = base; CARD32 dst = base;
#ifdef PRINT_PORT if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" rep_insl(%#x) %d bytes at %p %s\n", ErrorF(" rep_insl(%#x) %d bytes at %8.8x %s\n",
port, count, base, d_f ? "up" : "down"); port, count, base, d_f ? "up" : "down");
#endif
while (count--) { while (count--) {
MEM_WL(pInt, dst, x_inl(port)); MEM_WL(pInt, dst, x_inl(port));
dst += inc; dst += inc;
@ -260,10 +262,9 @@ port_rep_outb(xf86Int10InfoPtr pInt,
{ {
register int inc = d_f ? -1 : 1; register int inc = d_f ? -1 : 1;
CARD32 dst = base; CARD32 dst = base;
#ifdef PRINT_PORT if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" rep_outb(%#x) %d bytes at %p %s\n", ErrorF(" rep_outb(%#x) %d bytes at %8.8x %s\n",
port, count, base, d_f ? "up" : "down"); port, count, base, d_f ? "up" : "down");
#endif
while (count--) { while (count--) {
x_outb(port, MEM_RB(pInt, dst)); x_outb(port, MEM_RB(pInt, dst));
dst += inc; dst += inc;
@ -277,10 +278,9 @@ port_rep_outw(xf86Int10InfoPtr pInt,
{ {
register int inc = d_f ? -2 : 2; register int inc = d_f ? -2 : 2;
CARD32 dst = base; CARD32 dst = base;
#ifdef PRINT_PORT if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" rep_outw(%#x) %d bytes at %p %s\n", ErrorF(" rep_outw(%#x) %d bytes at %8.8x %s\n",
port, count, base, d_f ? "up" : "down"); port, count, base, d_f ? "up" : "down");
#endif
while (count--) { while (count--) {
x_outw(port, MEM_RW(pInt, dst)); x_outw(port, MEM_RW(pInt, dst));
dst += inc; dst += inc;
@ -294,10 +294,9 @@ port_rep_outl(xf86Int10InfoPtr pInt,
{ {
register int inc = d_f ? -4 : 4; register int inc = d_f ? -4 : 4;
CARD32 dst = base; CARD32 dst = base;
#ifdef PRINT_PORT if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" rep_outl(%#x) %d bytes at %p %s\n", ErrorF(" rep_outl(%#x) %d bytes at %8.8x %s\n",
port, count, base, d_f ? "up" : "down"); port, count, base, d_f ? "up" : "down");
#endif
while (count--) { while (count--) {
x_outl(port, MEM_RL(pInt, dst)); x_outl(port, MEM_RL(pInt, dst));
dst += inc; dst += inc;
@ -314,9 +313,8 @@ x_inb(CARD16 port)
Int10Current->inb40time++; Int10Current->inb40time++;
val = (CARD8)(Int10Current->inb40time >> val = (CARD8)(Int10Current->inb40time >>
((Int10Current->inb40time & 1) << 3)); ((Int10Current->inb40time & 1) << 3));
#ifdef PRINT_PORT if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" inb(%#x) = %2.2x\n", port, val); ErrorF(" inb(%#x) = %2.2x\n", port, val);
#endif
#ifdef __NOT_YET__ #ifdef __NOT_YET__
} else if (port < 0x0100) { /* Don't interfere with mainboard */ } else if (port < 0x0100) { /* Don't interfere with mainboard */
val = 0; val = 0;
@ -327,12 +325,10 @@ x_inb(CARD16 port)
stack_trace(Int10Current); stack_trace(Int10Current);
} }
#endif /* __NOT_YET__ */ #endif /* __NOT_YET__ */
} else { } else if (!pciCfg1inb(port, &val)) {
if (!pciCfg1inb(port, &val)) val = inb(Int10Current->ioBase + port);
val = inb(Int10Current->ioBase + port); if (PRINT_PORT && DEBUG_IO_TRACE())
#ifdef PRINT_PORT ErrorF(" inb(%#x) = %2.2x\n", port, val);
ErrorF(" inb(%#x) = %2.2x\n", port, val);
#endif
} }
return val; return val;
} }
@ -351,13 +347,11 @@ x_inw(CARD16 port)
*/ */
X_GETTIMEOFDAY(&tv); X_GETTIMEOFDAY(&tv);
val = (CARD16)(tv.tv_usec / 3); val = (CARD16)(tv.tv_usec / 3);
} else { } else if (!pciCfg1inw(port, &val)) {
if (!pciCfg1inw(port, &val)) val = inw(Int10Current->ioBase + port);
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; return val;
} }
@ -374,9 +368,8 @@ x_outb(CARD16 port, CARD8 val)
*/ */
X_GETTIMEOFDAY(&tv); X_GETTIMEOFDAY(&tv);
Int10Current->inb40time = (CARD16)(tv.tv_usec | 1); Int10Current->inb40time = (CARD16)(tv.tv_usec | 1);
#ifdef PRINT_PORT if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" outb(%#x, %2.2x)\n", port, val); ErrorF(" outb(%#x, %2.2x)\n", port, val);
#endif
#ifdef __NOT_YET__ #ifdef __NOT_YET__
} else if (port < 0x0100) { /* Don't interfere with mainboard */ } else if (port < 0x0100) { /* Don't interfere with mainboard */
xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2, xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2,
@ -386,24 +379,22 @@ x_outb(CARD16 port, CARD8 val)
stack_trace(Int10Current); stack_trace(Int10Current);
} }
#endif /* __NOT_YET__ */ #endif /* __NOT_YET__ */
} else { } else if (!pciCfg1outb(port, val)) {
#ifdef PRINT_PORT if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" outb(%#x, %2.2x)\n", port, val); ErrorF(" outb(%#x, %2.2x)\n", port, val);
#endif outb(Int10Current->ioBase + port, val);
if (!pciCfg1outb(port, val))
outb(Int10Current->ioBase + port, val);
} }
} }
void void
x_outw(CARD16 port, CARD16 val) 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); outw(Int10Current->ioBase + port, val);
}
} }
CARD32 CARD32
@ -411,24 +402,22 @@ x_inl(CARD16 port)
{ {
CARD32 val; CARD32 val;
if (!pciCfg1in(port, &val)) if (!pciCfg1in(port, &val)) {
val = inl(Int10Current->ioBase + port); val = inl(Int10Current->ioBase + port);
if (PRINT_PORT && DEBUG_IO_TRACE())
#ifdef PRINT_PORT ErrorF(" inl(%#x) = %8.8x\n", port, val);
ErrorF(" inl(%#x) = %8.8x\n", port, val); }
#endif
return val; return val;
} }
void void
x_outl(CARD16 port, CARD32 val) x_outl(CARD16 port, CARD32 val)
{ {
#ifdef PRINT_PORT if (!pciCfg1out(port, val)) {
ErrorF(" outl(%#x, %8.8x)\n", port, val); if (PRINT_PORT && DEBUG_IO_TRACE())
#endif ErrorF(" outl(%#x, %8.8x)\n", port, val);
if (!pciCfg1out(port, val))
outl(Int10Current->ioBase + port, val); outl(Int10Current->ioBase + port, val);
}
} }
CARD8 CARD8
@ -480,6 +469,8 @@ pciCfg1in(CARD16 addr, CARD32 *val)
} }
if (addr == 0xCFC) { if (addr == 0xCFC) {
*val = pciReadLong(Int10Current->Tag, OFFSET(PciCfg1Addr)); *val = pciReadLong(Int10Current->Tag, OFFSET(PciCfg1Addr));
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" cfg_inl(%#x) = %8.8x\n", PciCfg1Addr, *val);
return 1; return 1;
} }
return 0; return 0;
@ -493,6 +484,8 @@ pciCfg1out(CARD16 addr, CARD32 val)
return 1; return 1;
} }
if (addr == 0xCFC) { if (addr == 0xCFC) {
if (PRINT_PORT && DEBUG_IO_TRACE())
ErrorF(" cfg_outl(%#x, %8.8x)\n", PciCfg1Addr, val);
pciWriteLong(Int10Current->Tag, OFFSET(PciCfg1Addr), val); pciWriteLong(Int10Current->Tag, OFFSET(PciCfg1Addr), val);
return 1; return 1;
} }
@ -512,6 +505,8 @@ pciCfg1inw(CARD16 addr, CARD16 *val)
if ((addr >= 0xCFC) && (addr <= 0xCFF)) { if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
offset = addr - 0xCFC; offset = addr - 0xCFC;
*val = pciReadWord(Int10Current->Tag, OFFSET(PciCfg1Addr) + offset); *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 1;
} }
return 0; return 0;
@ -530,6 +525,8 @@ pciCfg1outw(CARD16 addr, CARD16 val)
} }
if ((addr >= 0xCFC) && (addr <= 0xCFF)) { if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
offset = addr - 0xCFC; 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); pciWriteWord(Int10Current->Tag, OFFSET(PciCfg1Addr) + offset, val);
return 1; return 1;
} }
@ -549,6 +546,8 @@ pciCfg1inb(CARD16 addr, CARD8 *val)
if ((addr >= 0xCFC) && (addr <= 0xCFF)) { if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
offset = addr - 0xCFC; offset = addr - 0xCFC;
*val = pciReadByte(Int10Current->Tag, OFFSET(PciCfg1Addr) + offset); *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 1;
} }
return 0; return 0;
@ -567,6 +566,8 @@ pciCfg1outb(CARD16 addr, CARD8 val)
} }
if ((addr >= 0xCFC) && (addr <= 0xCFF)) { if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
offset = addr - 0xCFC; 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); pciWriteByte(Int10Current->Tag, OFFSET(PciCfg1Addr) + offset, val);
return 1; return 1;
} }

View File

@ -38,6 +38,8 @@
****************************************************************************/ ****************************************************************************/
#include "x86emu/x86emui.h" #include "x86emu/x86emui.h"
#include <stdio.h>
#include <string.h>
#ifndef NO_SYS_HEADERS #ifndef NO_SYS_HEADERS
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>