x86emu now compiles with DBG_X86EMU
This commit is contained in:
2
Makefile
2
Makefile
@@ -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-
|
||||||
|
|||||||
@@ -182,22 +182,26 @@
|
|||||||
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) \
|
# define RETURN_TRACE(n,u,v) \
|
||||||
if (DEBUG_TRACECALLREGS()) \
|
if (DEBUG_TRACECALLREGS()) \
|
||||||
x86emu_dump_regs(); \
|
x86emu_dump_regs(); \
|
||||||
if (DEBUG_TRACECALL()) { \
|
if (DEBUG_TRACECALL()) \
|
||||||
DPRINTVALHEXWORD("", (unsigned long)u); \
|
{ \
|
||||||
DPRINTVALHEXWORD(":", (unsigned long)v); \
|
xprintf("%x", (unsigned long)u); \
|
||||||
DPRINT(": CALL "); \
|
xprintf(":%x", (unsigned long)v); \
|
||||||
DPRINT(n); \
|
xprintf(": CALL "); \
|
||||||
DPRINT("\r\n"); }
|
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)
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|||||||
165
x86emu/x86sys.c
165
x86emu/x86sys.c
@@ -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);
|
||||||
@@ -95,9 +90,9 @@ inline uint8_t X86API rdb(uint32_t addr)
|
|||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -204,7 +199,7 @@ 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
|
||||||
@@ -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"); } )
|
{
|
||||||
|
dbg("%s: mem_ptr: address %x out of range!\r\n", __FUNCTION__, addr);
|
||||||
|
}
|
||||||
|
)
|
||||||
HALT_SYS();
|
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user