mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
xbox.cpp: parametrize constants used in debug command routines to support different bios/kernel versions (nw)
This commit is contained in:
parent
2939d6df87
commit
da667b3881
@ -696,7 +696,6 @@ void chihiro_state::jamtable_disasm_command(int ref, int params, const char **pa
|
||||
|
||||
void chihiro_state::threadlist_command(int ref, int params, const char **param)
|
||||
{
|
||||
const uint32_t thlists = 0x8003aae0; // magic address
|
||||
address_space &space = m_maincpu->space();
|
||||
debugger_cpu &cpu = machine().debugger().cpu();
|
||||
debugger_console &con = machine().debugger().console();
|
||||
@ -705,19 +704,19 @@ void chihiro_state::threadlist_command(int ref, int params, const char **param)
|
||||
con.printf("-------------------------------\n");
|
||||
for (int pri=0;pri < 16;pri++)
|
||||
{
|
||||
uint32_t curr = thlists + pri * 8;
|
||||
uint32_t curr = debugc_bios->parameter[1-1] + pri * 8;
|
||||
uint32_t next = cpu.read_dword(space, curr, true);
|
||||
|
||||
while (next != curr)
|
||||
{
|
||||
uint32_t kthrd = next - 0x5c;
|
||||
uint32_t topstack = cpu.read_dword(space, kthrd + 0x1c, true);
|
||||
uint32_t tlsdata = cpu.read_dword(space, kthrd + 0x28, true);
|
||||
uint32_t kthrd = next - debugc_bios->parameter[2-1];
|
||||
uint32_t topstack = cpu.read_dword(space, kthrd + debugc_bios->parameter[3-1], true);
|
||||
uint32_t tlsdata = cpu.read_dword(space, kthrd + debugc_bios->parameter[4-1], true);
|
||||
uint32_t function;
|
||||
if (tlsdata == 0)
|
||||
function = cpu.read_dword(space, topstack - 0x210 - 8, true);
|
||||
function = cpu.read_dword(space, topstack - debugc_bios->parameter[5-1] - debugc_bios->parameter[6-1], true);
|
||||
else
|
||||
function = cpu.read_dword(space, tlsdata - 8, true);
|
||||
function = cpu.read_dword(space, tlsdata - debugc_bios->parameter[6-1], true);
|
||||
con.printf(" %02d %08x %08x %08x\n", pri, kthrd, topstack, function);
|
||||
next = cpu.read_dword(space, next, true);
|
||||
}
|
||||
@ -756,7 +755,8 @@ void chihiro_state::hack_eeprom()
|
||||
}
|
||||
|
||||
#define HACK_ITEMS 5
|
||||
static const struct {
|
||||
static const struct
|
||||
{
|
||||
const char *game_name;
|
||||
const bool disable_usb;
|
||||
struct {
|
||||
|
@ -115,6 +115,12 @@ public:
|
||||
bool usb_hack_enabled;
|
||||
required_device<cpu_device> m_maincpu;
|
||||
ohci_usb_controller *ohci_usb;
|
||||
static const struct debugger_constants
|
||||
{
|
||||
uint32_t id;
|
||||
uint32_t parameter[8]; // c c c ? ? ? x x
|
||||
} debugp[];
|
||||
const debugger_constants *debugc_bios;
|
||||
|
||||
private:
|
||||
void dump_string_command(int ref, int params, const char **param);
|
||||
@ -131,6 +137,9 @@ private:
|
||||
void vprogdis_command(int ref, int params, const char **param);
|
||||
void help_command(int ref, int params, const char **param);
|
||||
void xbox_debug_commands(int ref, int params, const char **param);
|
||||
int find_bios_index(running_machine &mach);
|
||||
bool find_bios_hash(running_machine &mach, int bios, uint32_t &crc32);
|
||||
void find_debug_params(running_machine &mach);
|
||||
};
|
||||
|
||||
ADDRESS_MAP_EXTERN(xbox_base_map, 32);
|
||||
|
@ -21,6 +21,59 @@
|
||||
#define LOG_PCI
|
||||
//#define LOG_AUDIO
|
||||
|
||||
const xbox_base_state::debugger_constants xbox_base_state::debugp[] = {
|
||||
{ 0x66232714, {0x8003aae0, 0x5c, 0x1c, 0x28, 0x210, 8, 0x28, 0x1c} },
|
||||
{ 0x49d8055a, {0x8003aae0, 0x5c, 0x1c, 0x28, 0x210, 8, 0x28, 0x1c} }
|
||||
};
|
||||
|
||||
int xbox_base_state::find_bios_index(running_machine &mach)
|
||||
{
|
||||
u8 sb = mach.driver_data()->system_bios();
|
||||
return sb;
|
||||
}
|
||||
|
||||
bool xbox_base_state::find_bios_hash(running_machine &mach, int bios, uint32_t &crc32)
|
||||
{
|
||||
uint32_t crc = 0;
|
||||
const std::vector<rom_entry> &rev = mach.root_device().rom_region_vector();
|
||||
|
||||
for (rom_entry re : rev)
|
||||
{
|
||||
if ((re.flags() & ROMENTRY_TYPEMASK) == ROMENTRYTYPE_ROM)
|
||||
{
|
||||
if ((re.flags() & ROM_BIOSFLAGSMASK) == ROM_BIOS(bios + 1))
|
||||
{
|
||||
const std::string &h = re.hashdata();
|
||||
util::hash_collection hc(h.c_str());
|
||||
if (hc.crc(crc) == true)
|
||||
{
|
||||
crc32 = crc;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void xbox_base_state::find_debug_params(running_machine &mach)
|
||||
{
|
||||
uint32_t crc;
|
||||
int sb;
|
||||
|
||||
sb = (int)find_bios_index(machine());
|
||||
debugc_bios = debugp;
|
||||
if (find_bios_hash(machine(), sb - 1, crc) == true)
|
||||
{
|
||||
for (int n = 0; n < 2; n++)
|
||||
if (debugp[n].id == crc)
|
||||
{
|
||||
debugc_bios = &debugp[n];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void xbox_base_state::dump_string_command(int ref, int params, const char **param)
|
||||
{
|
||||
debugger_cpu &cpu = machine().debugger().cpu();
|
||||
@ -50,6 +103,7 @@ void xbox_base_state::dump_string_command(int ref, int params, const char **para
|
||||
con.printf("MaximumLength %d word\n", maximumlength);
|
||||
con.printf("Buffer %08X byte* ", buffer);
|
||||
|
||||
// limit the number of characters to avoid flooding
|
||||
if (length > 256)
|
||||
length = 256;
|
||||
|
||||
@ -221,25 +275,25 @@ void xbox_base_state::curthread_command(int ref, int params, const char **param)
|
||||
offs_t address;
|
||||
|
||||
uint64_t fsbase = m_maincpu->state_int(44); // base of FS register
|
||||
address = (offs_t)fsbase + 0x28;
|
||||
address = (offs_t)fsbase + (offs_t)debugc_bios->parameter[7-1];
|
||||
if (!m_maincpu->translate(AS_PROGRAM, TRANSLATE_READ_DEBUG, address))
|
||||
{
|
||||
con.printf("Address is unmapped.\n");
|
||||
return;
|
||||
}
|
||||
address = (offs_t)fsbase + 0x28;
|
||||
address = (offs_t)fsbase + (offs_t)debugc_bios->parameter[7-1];
|
||||
|
||||
uint32_t kthrd = cpu.read_dword(space, address, true);
|
||||
con.printf("Current thread is %08X\n", kthrd);
|
||||
address = (offs_t)kthrd + 0x1c;
|
||||
address = (offs_t)(kthrd + debugc_bios->parameter[8-1]);
|
||||
uint32_t topstack = cpu.read_dword(space, address, true);
|
||||
con.printf("Current thread stack top is %08X\n", topstack);
|
||||
address = (offs_t)kthrd + 0x28;
|
||||
address = (offs_t)(kthrd + debugc_bios->parameter[4-1]);
|
||||
uint32_t tlsdata = cpu.read_dword(space, address, true);
|
||||
if (tlsdata == 0)
|
||||
address = (offs_t)topstack - 0x210 - 8;
|
||||
address = (offs_t)(topstack - debugc_bios->parameter[5-1] - debugc_bios->parameter[6-1]);
|
||||
else
|
||||
address = (offs_t)tlsdata - 8;
|
||||
address = (offs_t)(tlsdata - debugc_bios->parameter[6-1]);
|
||||
con.printf("Current thread function is %08X\n", cpu.read_dword(space, address, true));
|
||||
}
|
||||
|
||||
@ -1114,6 +1168,7 @@ ADDRESS_MAP_END
|
||||
|
||||
void xbox_base_state::machine_start()
|
||||
{
|
||||
find_debug_params(machine());
|
||||
nvidia_nv2a = std::make_unique<nv2a_renderer>(machine());
|
||||
memset(pic16lc_buffer, 0, sizeof(pic16lc_buffer));
|
||||
pic16lc_buffer[0] = 'B';
|
||||
|
Loading…
Reference in New Issue
Block a user