From fe72e4b63380c83980b48d609da9ca4ec6617c08 Mon Sep 17 00:00:00 2001 From: yz70s Date: Sat, 3 Dec 2016 18:29:25 +0100 Subject: [PATCH] chihiro.cpp: move threadlist debug command to xbox (nw) --- src/mame/drivers/chihiro.cpp | 33 --------------------------------- src/mame/includes/xbox.h | 1 + src/mame/machine/xbox.cpp | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/mame/drivers/chihiro.cpp b/src/mame/drivers/chihiro.cpp index bec4f4b016e..4e06ebb2dff 100644 --- a/src/mame/drivers/chihiro.cpp +++ b/src/mame/drivers/chihiro.cpp @@ -562,7 +562,6 @@ public: private: void jamtable_disasm(address_space &space, uint32_t address, uint32_t size); void jamtable_disasm_command(int ref, int params, const char **param); - void threadlist_command(int ref, int params, const char **param); void chihiro_help_command(int ref, int params, const char **param); void debug_commands(int ref, int params, const char **param); }; @@ -694,42 +693,12 @@ void chihiro_state::jamtable_disasm_command(int ref, int params, const char **pa jamtable_disasm(space, (uint32_t)addr, (uint32_t)size); } -void chihiro_state::threadlist_command(int ref, int params, const char **param) -{ - address_space &space = m_maincpu->space(); - debugger_cpu &cpu = machine().debugger().cpu(); - debugger_console &con = machine().debugger().console(); - - con.printf("Pri. _KTHREAD Stack Function\n"); - con.printf("-------------------------------\n"); - for (int pri=0;pri < 16;pri++) - { - 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 - 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 - debugc_bios->parameter[5-1] - debugc_bios->parameter[6-1], true); - else - 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); - } - } -} - void chihiro_state::chihiro_help_command(int ref, int params, const char **param) { debugger_console &con = machine().debugger().console(); con.printf("Available Chihiro commands:\n"); con.printf(" chihiro jamdis,, -- Disassemble bytes of JamTable instructions starting at \n"); - con.printf(" chihiro threadlist -- list of currently active threads\n"); con.printf(" chihiro help -- this list\n"); } @@ -739,8 +708,6 @@ void chihiro_state::debug_commands(int ref, int params, const char **param) return; if (strcmp("jamdis", param[0]) == 0) jamtable_disasm_command(ref, params - 1, param + 1); - else if (strcmp("threadlist", param[0]) == 0) - threadlist_command(ref, params - 1, param + 1); else chihiro_help_command(ref, params - 1, param + 1); } diff --git a/src/mame/includes/xbox.h b/src/mame/includes/xbox.h index 97ec9b7a670..6bd4a9cbac0 100644 --- a/src/mame/includes/xbox.h +++ b/src/mame/includes/xbox.h @@ -129,6 +129,7 @@ private: void dump_dpc_command(int ref, int params, const char **param); void dump_timer_command(int ref, int params, const char **param); void curthread_command(int ref, int params, const char **param); + void threadlist_command(int ref, int params, const char **param); void generate_irq_command(int ref, int params, const char **param); void nv2a_combiners_command(int ref, int params, const char **param); void waitvblank_command(int ref, int params, const char **param); diff --git a/src/mame/machine/xbox.cpp b/src/mame/machine/xbox.cpp index 9e2c613edbb..b65c2512392 100644 --- a/src/mame/machine/xbox.cpp +++ b/src/mame/machine/xbox.cpp @@ -297,6 +297,35 @@ void xbox_base_state::curthread_command(int ref, int params, const char **param) con.printf("Current thread function is %08X\n", cpu.read_dword(space, address, true)); } +void xbox_base_state::threadlist_command(int ref, int params, const char **param) +{ + address_space &space = m_maincpu->space(); + debugger_cpu &cpu = machine().debugger().cpu(); + debugger_console &con = machine().debugger().console(); + + con.printf("Pri. _KTHREAD Stack Function\n"); + con.printf("-------------------------------\n"); + for (int pri = 0; pri < 16; pri++) + { + uint32_t curr = debugc_bios->parameter[1 - 1] + pri * 8; + uint32_t next = cpu.read_dword(space, curr, true); + + while ((next != curr) && (next != 0)) + { + 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 - debugc_bios->parameter[5 - 1] - debugc_bios->parameter[6 - 1], true); + else + 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); + } + } +} + void xbox_base_state::generate_irq_command(int ref, int params, const char **param) { uint64_t irq; @@ -426,6 +455,7 @@ void xbox_base_state::help_command(int ref, int params, const char **param) con.printf(" xbox dump_dpc,
-- Dump _KDPC object at
\n"); con.printf(" xbox dump_timer,
-- Dump _KTIMER object at
\n"); con.printf(" xbox curthread -- Print information about current thread\n"); + con.printf(" xbox threadlist -- list of currently active threads\n"); con.printf(" xbox irq, -- Generate interrupt with irq number 0-15\n"); con.printf(" xbox nv2a_combiners -- Toggle use of register combiners\n"); con.printf(" xbox waitvblank -- Toggle support for wait vblank method\n"); @@ -451,6 +481,8 @@ void xbox_base_state::xbox_debug_commands(int ref, int params, const char **para dump_timer_command(ref, params - 1, param + 1); else if (strcmp("curthread", param[0]) == 0) curthread_command(ref, params - 1, param + 1); + else if (strcmp("threadlist", param[0]) == 0) + threadlist_command(ref, params - 1, param + 1); else if (strcmp("irq", param[0]) == 0) generate_irq_command(ref, params - 1, param + 1); else if (strcmp("nv2a_combiners", param[0]) == 0)