forgot file. Only half way finished.

This commit is contained in:
Markus Fröschle
2014-01-03 21:04:12 +00:00
parent 47d7e8e965
commit 64b24ba73c

View File

@@ -70,278 +70,173 @@ extern uint32_t offset_mem;
/*----------------------------- Implementation ----------------------------*/
/****************************************************************************
PARAMETERS:
addr - Emulator memory address to read
RETURNS:
Byte value read from emulator memory.
REMARKS:
Reads a byte value from the emulator memory.
****************************************************************************/
uint8_t X86API rdb(uint32_t addr)
/*
* PARAMETERS:
* addr - Emulator memory address to read
*
* RETURNS:
* Byte value read from emulator memory.
*
* REMARKS:
* Reads a byte value from the emulator memory.
*/
inline uint8_t X86API rdb(uint32_t addr)
{
uint8_t val;
if((addr >= 0xA0000) && (addr <= 0xBFFFF))
if ((addr >= 0xA0000) && (addr <= 0xBFFFF))
{
#ifdef DEBUG_X86EMU_PCI
DPRINTVALHEX("rdb(", addr);
#endif
val = *(uint8_t *)(offset_mem+addr);
#ifdef DEBUG_X86EMU_PCI
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
val = *(uint8_t *)(offset_mem + addr);
dbg("%s: rdb(%x) = %x\r\n", __FUNCTION__, addr, val);
}
else
{
#if 0
if(addr >= M.mem_size)
{
DB( { DPRINTVALHEX("mem_ptr: address ", addr);
DPRINT(" out of range!\r\n"); } )
HALT_SYS();
}
#endif
#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
val = *(uint8_t *)(M.mem_base + addr);
}
DB(if (DEBUG_MEM_TRACE())
{
DPRINTVALHEXLONG("", addr);
DPRINTVALHEXBYTE(" 1 -> ", val);
DPRINT("\r\n");
dbg("%s: %p 1 -> %x\r\n", __FUNCTION__, addr, val);
} )
return val;
}
/****************************************************************************
PARAMETERS:
addr - Emulator memory address to read
RETURNS:
Word value read from emulator memory.
REMARKS:
Reads a word value from the emulator memory.
****************************************************************************/
uint16_t X86API rdw(uint32_t addr)
/*
* PARAMETERS:
* addr - Emulator memory address to read
*
* RETURNS:
* Word value read from emulator memory.
*
* REMARKS:
* Reads a word value from the emulator memory.
*/
inline uint16_t X86API rdw(uint32_t addr)
{
uint16_t val;
if((addr >= 0xA0000) && (addr <= 0xBFFFF))
if ((addr >= 0xA0000) && (addr <= 0xBFFFF))
{
#ifdef DEBUG_X86EMU_PCI
DPRINTVALHEX("rdw(", addr);
#endif
val = swpw(*(uint16_t *)(offset_mem+addr));
#ifdef DEBUG_X86EMU_PCI
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
dbg("%s: rdw(%x) = %x\r\n", __FUNCTION__, addr, val);
}
else
{
#if 0
if(addr > M.mem_size - 2)
{
DB( { DPRINTVALHEX("mem_ptr: address ", addr);
DPRINT(" out of range!\r\n"); } )
HALT_SYS();
}
#endif
#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
val = (uint16_t)(*(uint8_t *)(M.mem_base + addr));
val = (uint16_t) (* (uint8_t *)(M.mem_base + addr));
val |= (((uint16_t)( *(uint8_t *)(M.mem_base + addr + 1))) << 8);
// val = *(uint16_t *)(M.mem_base + addr);
}
DB(if (DEBUG_MEM_TRACE())
{
DPRINTVALHEXLONG("", addr);
DPRINTVALHEXWORD(" 2 -> ", val);
DPRINT("\r\n");
dbg("%s: %p 2 -> %x\r\n", __FUNCTION__, addr, value);
} )
return val;
}
/****************************************************************************
PARAMETERS:
addr - Emulator memory address to read
RETURNS:
Long value read from emulator memory.
REMARKS:
Reads a long value from the emulator memory.
****************************************************************************/
uint32_t X86API rdl(uint32_t addr)
/*
* PARAMETERS:
* addr - Emulator memory address to read
*
* RETURNS:
* Long value read from emulator memory.
* REMARKS:
* Reads a long value from the emulator memory.
*/
inline uint32_t X86API rdl(uint32_t addr)
{
uint32_t val;
if((addr >= 0xA0000) && (addr <= 0xBFFFF))
if ((addr >= 0xA0000) && (addr <= 0xBFFFF))
{
#ifdef DEBUG_X86EMU_PCI
DPRINTVALHEX("rdl(", addr);
#endif
val = swpl(*(uint32_t *)(offset_mem+addr));
#ifdef DEBUG_X86EMU_PCI
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
val = swpl(*(uint32_t *)(offset_mem + addr));
dbg("%s: rdl(%x) = %x\r\n", __FUNCTION__, addr, val);
}
else
{
#if 0
if(addr > M.mem_size - 4)
{
DB( { DPRINTVALHEX("mem_ptr: address ", addr);
DPRINT(" out of range!\r\n"); } )
HALT_SYS();
}
#endif
#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
val = swpl(*(uint32_t *)(M.mem_base + addr));
// val = *(uint32_t *)(M.mem_base + addr);
}
DB(if (DEBUG_MEM_TRACE())
{
DPRINTVALHEXLONG("", addr);
DPRINTVALHEXLONG(" 4 -> ", val);
DPRINT("\r\n");
dbg("%s: %p 4 -> %x\r\n", __FUNCTION__, addr, value);
} )
return val;
}
/****************************************************************************
PARAMETERS:
addr - Emulator memory address to read
val - Value to store
REMARKS:
Writes a byte value to emulator memory.
****************************************************************************/
void X86API wrb(uint32_t addr, uint8_t val)
/*
* PARAMETERS:
* addr - Emulator memory address to read
* val - Value to store
*
* REMARKS:
* Writes a byte value to emulator memory.
*/
inline void X86API wrb(uint32_t addr, uint8_t val)
{
if((addr >= 0xA0000) && (addr <= 0xBFFFF))
if ((addr >= 0xA0000) && (addr <= 0xBFFFF))
{
#ifdef DEBUG_X86EMU_PCI
DPRINTVALHEX("wrb(", addr);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
*(uint8_t *)(offset_mem+addr) = val;
*(uint8_t *)(offset_mem + addr) = val;
dbg("%s: wrb(%x) = %x\r\n", __FUNCTION__, addr, val);
}
else
{
if(addr >= M.mem_size)
{
DB( { DPRINTVALHEX("mem_ptr: address ", addr);
DPRINT(" out of range!\r\n"); } )
HALT_SYS();
DB(
{
dbg("%s: mem_ptr: %p 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
*(uint8_t *)(M.mem_base + addr) = val;
}
DB(if (DEBUG_MEM_TRACE())
{
DPRINTVALHEXLONG("", addr);
DPRINTVALHEXBYTE(" 1 <- ", val);
DPRINT("\r\n");
dbg("%s: %p 1 < %x\r\n", __FUNCTION__, addr, val);
} )
}
/****************************************************************************
PARAMETERS:
addr - Emulator memory address to read
val - Value to store
REMARKS:
Writes a word value to emulator memory.
****************************************************************************/
void X86API wrw(uint32_t addr, uint16_t val)
/*
* PARAMETERS:
* addr - Emulator memory address to read
* val - Value to store
*
* REMARKS:
* Writes a word value to emulator memory.
*/
inline void X86API wrw(uint32_t addr, uint16_t val)
{
if((addr >= 0xA0000) && (addr <= 0xBFFFF))
if ((addr >= 0xA0000) && (addr <= 0xBFFFF))
{
#ifdef DEBUG_X86EMU_PCI
DPRINTVALHEX("wrw(", addr);
DPRINTVALHEX(") = ", val);
DPRINT("\r\n");
#endif
dbg("%s: wrw(%x) = %x\r\n", __FUNCTION_, addr, val);
*(uint16_t *)(offset_mem+addr) = swpw(val);
}
else
{
if(addr > M.mem_size - 2)
{
DB( { DPRINTVALHEX("mem_ptr: address ", addr);
DPRINT(" out of range!\r\n"); } )
HALT_SYS();
DB(
{
dbg("%s: mem_ptr: %p 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
*(uint8_t *)(M.mem_base + addr) = (uint8_t)val;
*(uint8_t *)(M.mem_base + addr + 1) = (uint8_t)(val >> 8);
// *(uint16_t *)(M.mem_base + addr) = val;
*(uint8_t *)(M.mem_base + addr) = (uint8_t) val;
*(uint8_t *)(M.mem_base + addr + 1) = (uint8_t) (val >> 8);
}
DB(if (DEBUG_MEM_TRACE())
{
DPRINTVALHEXLONG("", addr);
DPRINTVALHEXWORD(" 2 <- ", val);
DPRINT("\r\n");
dbg("%s: %p 2 <- %x\r\n", __FUNCTION__, addr, val);
} )
}
/****************************************************************************
PARAMETERS:
addr - Emulator memory address to read
val - Value to store
REMARKS:
Writes a long value to emulator memory.
****************************************************************************/
void X86API wrl(uint32_t addr, uint32_t val)
/*
* PARAMETERS:
* addr - Emulator memory address to read
* val - Value to store
*
* REMARKS:
* Writes a long value to emulator memory.
*/
inline void X86API wrl(uint32_t addr, uint32_t val)
{
if((addr >= 0xA0000) && (addr <= 0xBFFFF))
if ((addr >= 0xA0000) && (addr <= 0xBFFFF))
{
#ifdef DEBUG_X86EMU_PCI
DPRINTVALHEX("wrl(", addr);