mirror of https://github.com/bochs-emu/Bochs
added support for the debugger, it now returns to the debugger prompt
This commit is contained in:
parent
b3ad392c65
commit
f89d1e6f01
|
@ -1,5 +1,7 @@
|
|||
#include "bochs.h"
|
||||
|
||||
|
||||
|
||||
bx_iodebug_c bx_iodebug;
|
||||
bx_iodebug_c *bx_iodebug_ptr;
|
||||
|
||||
|
@ -43,7 +45,7 @@ int bx_iodebug_c::init( bx_devices_c *d )
|
|||
BX_IODEBUG_THIS devices->register_io_read_handler(this, read_handler, 0x8A00,"BOCHS IODEBUG");
|
||||
BX_IODEBUG_THIS devices->register_io_write_handler(this, write_handler, 0x8A00,"BOCHS IODEBUG");
|
||||
BX_IODEBUG_THIS devices->register_io_write_handler(this, write_handler, 0x8A01,"BOCHS IODEBUG");
|
||||
fprintf( stderr, "IODEBUG initialized\n");
|
||||
// fprintf( stderr, "IODEBUG initialized\n");
|
||||
|
||||
bx_iodebug_s.enabled = 0;
|
||||
bx_iodebug_s.register_select = 0;
|
||||
|
@ -100,7 +102,7 @@ void bx_iodebug_c::write( Bit32u addr, Bit32u dvalue, unsigned int io_len )
|
|||
{
|
||||
|
||||
|
||||
fprintf(stderr, "IODEBUG addr: %4x\tdvalue: %8x\tio_len: %8x\n", (unsigned int)addr, (unsigned int)dvalue, io_len);
|
||||
// fprintf(stderr, "IODEBUG addr: %4x\tdvalue: %8x\tio_len: %8x\n", (unsigned int)addr, (unsigned int)dvalue, io_len);
|
||||
|
||||
if( addr == 0x8A01 && io_len == 2 )
|
||||
{
|
||||
|
@ -116,7 +118,7 @@ void bx_iodebug_c::write( Bit32u addr, Bit32u dvalue, unsigned int io_len )
|
|||
if( dvalue == 0x8A00 )
|
||||
{
|
||||
bx_iodebug_s.enabled = 1;
|
||||
fprintf(stderr, "IODEBUG enabled\n");
|
||||
// fprintf(stderr, "IODEBUG enabled\n");
|
||||
bx_iodebug_s.registers[0] = 0;
|
||||
bx_iodebug_s.registers[1] = 0;
|
||||
}
|
||||
|
@ -127,12 +129,12 @@ void bx_iodebug_c::write( Bit32u addr, Bit32u dvalue, unsigned int io_len )
|
|||
{
|
||||
case( 0x8A01 ):
|
||||
bx_iodebug_s.register_select = 0;
|
||||
fprintf( stderr, "IODEBUG register 0 selected\n");
|
||||
// fprintf( stderr, "IODEBUG register 0 selected\n");
|
||||
break;
|
||||
|
||||
case( 0x8A02 ):
|
||||
bx_iodebug_s.register_select = 1;
|
||||
fprintf( stderr, "IODEBUG register 1 selected\n");
|
||||
// fprintf( stderr, "IODEBUG register 1 selected\n");
|
||||
break;
|
||||
|
||||
case( 0x8A80 ):
|
||||
|
@ -146,11 +148,11 @@ void bx_iodebug_c::write( Bit32u addr, Bit32u dvalue, unsigned int io_len )
|
|||
|
||||
case( 0x8AFF ):
|
||||
bx_iodebug_s.enabled = 0;
|
||||
fprintf( stderr, "IODEBUG device deactivated\n");
|
||||
break;
|
||||
// fprintf( stderr, "IODEBUG device deactivated\n");
|
||||
// break;
|
||||
|
||||
default:
|
||||
fprintf(stderr,"IODEBUG unsupported register code\n");
|
||||
// default:
|
||||
// fprintf(stderr,"IODEBUG unsupported register code\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,10 +178,72 @@ void bx_iodebug_c::mem_write( BX_CPU_C *cpu, Bit32u addr, unsigned len, void *da
|
|||
if( area )
|
||||
{
|
||||
area--;
|
||||
#if BX_DEBUGGER
|
||||
fprintf( stdout, "%s @ eip: %8X wrote at monitored memory location %8X\n", cpu->name, cpu->eip, addr);
|
||||
bx_guard.interrupt_requested=1;
|
||||
#else
|
||||
fprintf( stderr,
|
||||
"IODEBUG write to monitored memory area: %2i\tby EIP:\t\t%08X\n\trange start: \t\t%08X\trange end:\t%08X\n\taddress accessed:\t%08X\tdata written:\t",
|
||||
area,
|
||||
bx_cpu.eip,
|
||||
cpu->eip,
|
||||
bx_iodebug_s.monitored_mem_areas_start[area],
|
||||
bx_iodebug_s.monitored_mem_areas_end[area],
|
||||
(unsigned int)addr);
|
||||
|
||||
data32 = * (Bit32u *)data;
|
||||
data16 = (Bit16u)data32;
|
||||
data8 = (Bit8u)data32;
|
||||
|
||||
switch(len)
|
||||
{
|
||||
case(1):
|
||||
fprintf(stderr,"%02X\n", (unsigned int)data8);
|
||||
break;
|
||||
|
||||
case(2):
|
||||
fprintf(stderr,"%04X\n", (unsigned int)data16);
|
||||
break;
|
||||
|
||||
case(4):
|
||||
fprintf(stderr,"%08X\n", (unsigned int)data32);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "unsupported write size\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void bx_iodebug_c::mem_read( BX_CPU_C *cpu, Bit32u addr, unsigned len, void *data)
|
||||
{
|
||||
Bit32u data32;
|
||||
Bit16u data16;
|
||||
Bit8u data8;
|
||||
|
||||
unsigned int area;
|
||||
if( !bx_iodebug_s.enabled ) return;
|
||||
|
||||
area = bx_iodebug_c::range_test( addr, len );
|
||||
// Device is enabled, testing address ranges
|
||||
if( area )
|
||||
{
|
||||
area--;
|
||||
#if BX_DEBUGGER
|
||||
fprintf( stdout, "%s @ eip: %8X wrote at monitored memory location %8X\n", cpu->name, cpu->eip, addr);
|
||||
bx_guard.interrupt_requested=1;
|
||||
#else
|
||||
fprintf( stderr,
|
||||
"IODEBUG read to monitored memory area: %2i\tby EIP:\t\t%08X\n\trange start: \t\t%08X\trange end:\t%08X\n\taddress accessed:\t%08X\tdata written:\t",
|
||||
area,
|
||||
cpu->eip,
|
||||
bx_iodebug_s.monitored_mem_areas_start[area],
|
||||
bx_iodebug_s.monitored_mem_areas_end[area],
|
||||
(unsigned int)addr);
|
||||
|
@ -204,6 +268,7 @@ void bx_iodebug_c::mem_write( BX_CPU_C *cpu, Bit32u addr, unsigned len, void *da
|
|||
default:
|
||||
fprintf(stderr, "unsupported write size\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,20 +278,6 @@ void bx_iodebug_c::mem_write( BX_CPU_C *cpu, Bit32u addr, unsigned len, void *da
|
|||
|
||||
|
||||
|
||||
|
||||
void bx_iodebug_c::mem_read( BX_CPU_C *cpu, Bit32u addr, unsigned len, void *data)
|
||||
{
|
||||
if( !bx_iodebug_s.enabled ) return;
|
||||
|
||||
// Device is enabled, testing address range
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned int bx_iodebug_c::range_test( Bit32u addr, unsigned int len )
|
||||
{
|
||||
unsigned int i;
|
||||
|
@ -262,9 +313,9 @@ void bx_iodebug_c::add_range( Bit32u addr_start, Bit32u addr_end )
|
|||
{
|
||||
bx_iodebug_s.monitored_mem_areas_start[i] = addr_start;
|
||||
bx_iodebug_s.monitored_mem_areas_end[i] = addr_end;
|
||||
fprintf(stderr, "IODEBUG added range successfully in slot: %i\n",i);
|
||||
// fprintf(stderr, "IODEBUG added range successfully in slot: %i\n",i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "IODEBUG unable to register memory range, all slots taken\n");
|
||||
// fprintf(stderr, "IODEBUG unable to register memory range, all slots taken\n");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue