x86emu now compiles with DBG_X86EMU

This commit is contained in:
Markus Fröschle
2014-01-04 09:09:20 +00:00
parent a16fec11ae
commit c9d2ed3f49
4 changed files with 108 additions and 129 deletions

View File

@@ -9,7 +9,7 @@
# can be either "Y" or "N" (without quotes). "Y" for using the m68k-elf-, "N" for using the m68k-atari-mint # can be either "Y" or "N" (without quotes). "Y" for using the m68k-elf-, "N" for using the m68k-atari-mint
# toolchain # toolchain
COMPILE_ELF=Y COMPILE_ELF=N
ifeq (Y,$(COMPILE_ELF)) ifeq (Y,$(COMPILE_ELF))
TCPREFIX=m68k-elf- TCPREFIX=m68k-elf-

View File

@@ -178,26 +178,30 @@
#endif #endif
#ifdef DBG_X86EMU #ifdef DBG_X86EMU
# define CALL_TRACE(u,v,w,x,s) \ # define CALL_TRACE(u,v,w,x,s) \
if (DEBUG_TRACECALLREGS()) \ if (DEBUG_TRACECALLREGS()) \
x86emu_dump_regs(); \ x86emu_dump_regs(); \
if (DEBUG_TRACECALL()) { \ if (DEBUG_TRACECALL()) { \
DPRINTVALHEXWORD("", u); \ xprintf("%x", u); \
DPRINTVALHEXWORD(":", v); \ xprintf(":%x", v); \
DPRINT(": CALL "); \ xprintf(": CALL "); \
DPRINT(s); \ xprintf("%x", s); \
DPRINTVALHEXWORD("", w); \ xprintf(" %x", w); \
DPRINTVALHEXWORD(":", x); \ xprintf(":%x", x); \
DPRINT("\r\n"); } xprintf("%s", "\r\n"); \
# define RETURN_TRACE(n,u,v) \ }
if (DEBUG_TRACECALLREGS()) \
x86emu_dump_regs(); \ # define RETURN_TRACE(n,u,v) \
if (DEBUG_TRACECALL()) { \ if (DEBUG_TRACECALLREGS()) \
DPRINTVALHEXWORD("", (unsigned long)u); \ x86emu_dump_regs(); \
DPRINTVALHEXWORD(":", (unsigned long)v); \ if (DEBUG_TRACECALL()) \
DPRINT(": CALL "); \ { \
DPRINT(n); \ xprintf("%x", (unsigned long)u); \
DPRINT("\r\n"); } xprintf(":%x", (unsigned long)v); \
xprintf(": CALL "); \
xprintf("%x", n); \
xprintf("\r\n"); \
}
#else #else
# define CALL_TRACE(u,v,w,x,s) # define CALL_TRACE(u,v,w,x,s)
# define RETURN_TRACE(n,u,v) # define RETURN_TRACE(n,u,v)

View File

@@ -80,8 +80,10 @@ extern unsigned decode_rmXX_address(int mod, int rm);
/* constant arrays to do several instructions in just one function */ /* constant arrays to do several instructions in just one function */
#ifdef DBG_X86EMU #ifdef DBG_X86EMU
static char *x86emu_GenOpName[8] = { static char *x86emu_GenOpName[8] =
"ADD", "OR", "ADC", "SBB", "AND", "SUB", "XOR", "CMP"}; {
"ADD", "OR", "ADC", "SBB", "AND", "SUB", "XOR", "CMP"
};
#endif #endif
/* used by several opcodes */ /* used by several opcodes */
@@ -3241,7 +3243,7 @@ void x86emuOp_ret_near_IMM(uint8_t X86EMU_UNUSED(op1))
DECODE_PRINTF("RET\t"); DECODE_PRINTF("RET\t");
imm = fetch_word_imm(); imm = fetch_word_imm();
DECODE_PRINTF2("%x\r\n", imm); DECODE_PRINTF2("%x\r\n", imm);
RETURN_TRACE("RET",M.x86.saved_cs,M.x86.saved_ip); RETURN_TRACE("RET", M.x86.saved_cs,M.x86.saved_ip);
TRACE_AND_STEP(); TRACE_AND_STEP();
M.x86.R_IP = pop_word(); M.x86.R_IP = pop_word();
M.x86.R_SP += imm; M.x86.R_SP += imm;

View File

@@ -49,11 +49,6 @@
#include "x86debug.h" #include "x86debug.h"
#include "x86prim_ops.h" #include "x86prim_ops.h"
#ifndef NULL
#define NULL ((void *)0)
#endif
extern uint8_t inb(uint16_t port); extern uint8_t inb(uint16_t port);
extern uint16_t inw(uint16_t port); extern uint16_t inw(uint16_t port);
extern uint32_t inl(uint16_t port); extern uint32_t inl(uint16_t port);
@@ -86,18 +81,18 @@ inline uint8_t X86API rdb(uint32_t addr)
if ((addr >= 0xA0000) && (addr <= 0xBFFFF)) if ((addr >= 0xA0000) && (addr <= 0xBFFFF))
{ {
val = *(uint8_t *)(offset_mem + addr); val = *(uint8_t *) (offset_mem + addr);
dbg("%s: rdb(%x) = %x\r\n", __FUNCTION__, addr, val); dbg("%s: rdb(%x) = %x\r\n", __FUNCTION__, addr, val);
} }
else else
{ {
DB(if (DEBUG_MEM_TRACE()) DB(if (DEBUG_MEM_TRACE())
{ {
dbg("%s: %p 1 -> %x\r\n", __FUNCTION__, addr, val); dbg("%s: %p 1 -> %x\r\n", __FUNCTION__, addr, val);
} ) } )
}
return val; return val;
} }
/* /*
* PARAMETERS: * PARAMETERS:
* addr - Emulator memory address to read * addr - Emulator memory address to read
@@ -108,7 +103,7 @@ inline uint8_t X86API rdb(uint32_t addr)
* REMARKS: * REMARKS:
* Reads a word value from the emulator memory. * Reads a word value from the emulator memory.
*/ */
inline uint16_t X86API rdw(uint32_t addr) uint16_t X86API rdw(uint32_t addr)
{ {
uint16_t val; uint16_t val;
@@ -124,7 +119,7 @@ inline uint16_t X86API rdw(uint32_t addr)
} }
DB(if (DEBUG_MEM_TRACE()) DB(if (DEBUG_MEM_TRACE())
{ {
dbg("%s: %p 2 -> %x\r\n", __FUNCTION__, addr, value); dbg("%s: %p 2 -> %x\r\n", __FUNCTION__, addr, val);
} ) } )
return val; return val;
} }
@@ -154,7 +149,7 @@ inline uint32_t X86API rdl(uint32_t addr)
DB(if (DEBUG_MEM_TRACE()) DB(if (DEBUG_MEM_TRACE())
{ {
dbg("%s: %p 4 -> %x\r\n", __FUNCTION__, addr, value); dbg("%s: %p 4 -> %x\r\n", __FUNCTION__, addr, val);
} ) } )
return val; return val;
} }
@@ -176,7 +171,7 @@ inline void X86API wrb(uint32_t addr, uint8_t val)
} }
else else
{ {
if(addr >= M.mem_size) if (addr >= M.mem_size)
{ {
DB( DB(
{ {
@@ -204,12 +199,12 @@ inline void X86API wrw(uint32_t addr, uint16_t val)
{ {
if ((addr >= 0xA0000) && (addr <= 0xBFFFF)) if ((addr >= 0xA0000) && (addr <= 0xBFFFF))
{ {
dbg("%s: wrw(%x) = %x\r\n", __FUNCTION_, addr, val); dbg("%s: wrw(%x) = %x\r\n", __FUNCTION__, addr, val);
*(uint16_t *)(offset_mem+addr) = swpw(val); *(uint16_t *)(offset_mem+addr) = swpw(val);
} }
else else
{ {
if(addr > M.mem_size - 2) if (addr > M.mem_size - 2)
{ {
DB( DB(
{ {
@@ -238,147 +233,125 @@ inline void X86API wrl(uint32_t addr, uint32_t val)
{ {
if ((addr >= 0xA0000) && (addr <= 0xBFFFF)) if ((addr >= 0xA0000) && (addr <= 0xBFFFF))
{ {
#ifdef DEBUG_X86EMU_PCI dbg("%s: wrl(%x) = %x\r\n", __FUNCTION__, addr, val);
DPRINTVALHEX("wrl(", addr);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
*(uint32_t *)(offset_mem+addr) = swpl(val); *(uint32_t *)(offset_mem+addr) = swpl(val);
} }
else else
{ {
if(addr > M.mem_size - 4) if (addr > M.mem_size - 4)
{ {
DB( { DPRINTVALHEX("mem_ptr: address ", addr); DB(
DPRINT(" out of range!\r\n"); } ) {
HALT_SYS(); dbg("%s: mem_ptr: address %x out of range!\r\n", __FUNCTION__, addr);
}
)
HALT_SYS();
} }
#if 0
if(addr < 0x200)
{
DPRINTVALHEXWORD("", M.x86.R_CS);
DPRINTVALHEXWORD(":", M.x86.R_IP);
DPRINTVALHEX(" updating int vector ", addr >> 2);
DPRINT("\r\n");
}
#endif
*(uint32_t *)(M.mem_base + addr) = swpl(val); *(uint32_t *)(M.mem_base + addr) = swpl(val);
// *(uint32_t *)(M.mem_base + addr) = val;
} }
DB(if (DEBUG_MEM_TRACE()) DB(if (DEBUG_MEM_TRACE())
{ {
DPRINTVALHEXLONG("", addr); dbg("%s: %p 4 <- %x\r\n", __FUNCTION__, addr, val);
DPRINTVALHEXLONG(" 4 <- ", val);
DPRINT("\r\n");
} ) } )
} }
/**************************************************************************** /*
PARAMETERS: * PARAMETERS:
addr - PIO address to read * addr - PIO address to read
RETURN: * RETURN:
0 * 0
REMARKS: * REMARKS:
Default PIO byte read function. Doesn't perform real inb. * Default PIO byte read function. Doesn't perform real inb.
****************************************************************************/ */
static uint8_t X86API p_inb(X86EMU_pioAddr addr) inline uint8_t X86API p_inb(X86EMU_pioAddr addr)
{ {
DB(if (DEBUG_IO_TRACE()) DB(if (DEBUG_IO_TRACE())
{ {
DPRINTVALHEXWORD("inb ", addr); dbg("%s: inb(%p)\r\n", __FUNCTION__);
DPRINT(" \r\n");
} ) } )
return inb(addr); return inb(addr);
} }
/**************************************************************************** /*
PARAMETERS: * PARAMETERS:
addr - PIO address to read * addr - PIO address to read
RETURN: * RETURN:
0 * 0
REMARKS: * REMARKS:
Default PIO word read function. Doesn't perform real inw. * Default PIO word read function. Doesn't perform real inw.
****************************************************************************/ */
static uint16_t X86API p_inw(X86EMU_pioAddr addr) inline uint16_t X86API p_inw(X86EMU_pioAddr addr)
{ {
DB(if (DEBUG_IO_TRACE()) DB(if (DEBUG_IO_TRACE())
{ {
DPRINTVALHEXWORD("inw ", addr); dbg("%s: inw(%p)\r\n", __FUNCTION__, addr);
DPRINT(" \r\n");
} ) } )
return inw(addr); return inw(addr);
} }
/**************************************************************************** /*
PARAMETERS: * PARAMETERS:
addr - PIO address to read * addr - PIO address to read
RETURN: * RETURN:
0 * 0
REMARKS: * REMARKS:
Default PIO long read function. Doesn't perform real inl. * Default PIO long read function. Doesn't perform real inl.
****************************************************************************/ */
static uint32_t X86API p_inl(X86EMU_pioAddr addr) inline uint32_t X86API p_inl(X86EMU_pioAddr addr)
{ {
DB(if (DEBUG_IO_TRACE()) DB(if (DEBUG_IO_TRACE())
{ {
DPRINTVALHEXWORD("inl ", addr); dbg("%s: inl %p\r\n", __FUNCTION__, addr);
DPRINT(" \r\n");
} ) } )
return inl(addr); return inl(addr);
} }
/**************************************************************************** /*
PARAMETERS: * PARAMETERS:
addr - PIO address to write * addr - PIO address to write
val - Value to store * val - Value to store
REMARKS: * REMARKS:
Default PIO byte write function. Doesn't perform real outb. * Default PIO byte write function. Doesn't perform real outb.
****************************************************************************/ */
static void X86API p_outb(X86EMU_pioAddr addr, uint8_t val) inline void X86API p_outb(X86EMU_pioAddr addr, uint8_t val)
{ {
DB(if (DEBUG_IO_TRACE()) DB(if (DEBUG_IO_TRACE())
{ {
DPRINTVALHEXBYTE("outb ", val); dbg("%s: outb %x -> %x\r\n", __FUNCTION__, val, addr);
DPRINTVALHEXWORD(" -> ", addr);
DPRINT(" \r\n");
} ) } )
outb(val, addr); outb(val, addr);
return; return;
} }
/**************************************************************************** /*
PARAMETERS: * PARAMETERS:
addr - PIO address to write * addr - PIO address to write
val - Value to store * val - Value to store
REMARKS: * REMARKS:
Default PIO word write function. Doesn't perform real outw. * Default PIO word write function. Doesn't perform real outw.
****************************************************************************/ */
static void X86API p_outw(X86EMU_pioAddr addr, uint16_t val) inline void X86API p_outw(X86EMU_pioAddr addr, uint16_t val)
{ {
DB(if (DEBUG_IO_TRACE()) DB(if (DEBUG_IO_TRACE())
{ {
DPRINTVALHEXWORD("outw ", (unsigned long)val); dbg("outw %x -> %x\r\n", __FUNCTION__, val, addr);
DPRINTVALHEXWORD(" -> ", addr);
DPRINT(" \r\n");
} ) } )
outw(val, addr); outw(val, addr);
return; return;
} }
/**************************************************************************** /*
PARAMETERS: * PARAMETERS:
addr - PIO address to write * addr - PIO address to write
val - Value to store * val - Value to store
REMARKS: * REMARKS:
Default PIO ;ong write function. Doesn't perform real outl. * Default PIO ;ong write function. Doesn't perform real outl.
****************************************************************************/ */
static void X86API p_outl(X86EMU_pioAddr addr, uint32_t val) inline void X86API p_outl(X86EMU_pioAddr addr, uint32_t val)
{ {
DB(if (DEBUG_IO_TRACE()) DB(if (DEBUG_IO_TRACE())
{ {
DPRINTVALHEXLONG("outl ", val); dbg("%s: outl %x -> %x\r\n", __FUNCTION__, val, addr);
DPRINTVALHEXWORD(" -> ", addr);
DPRINT(" \r\n");
} ) } )
outl(val, addr); outl(val, addr);
return; return;