From 5b08f283e53613e96852b480c8dcbd01b185254f Mon Sep 17 00:00:00 2001 From: Maxim Poliakovski Date: Sat, 27 Aug 2022 17:34:05 +0200 Subject: [PATCH] Hacks for debugging HW interrupts. --- debugger/debugger.cpp | 50 +++++++++++++++++++++++++++++++----- devices/common/hwinterrupt.h | 2 ++ devices/common/viacuda.cpp | 7 +++++ devices/common/viacuda.h | 4 +++ 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/debugger/debugger.cpp b/debugger/debugger.cpp index 9258f97..acdb9f8 100644 --- a/debugger/debugger.cpp +++ b/debugger/debugger.cpp @@ -19,7 +19,16 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include +#include +#include +#include +#include +#include "memaccess.h" +#include + #include +#include #include #include #include @@ -27,15 +36,13 @@ along with this program. If not, see . #include #include #include -#include #include #include -#include "../cpu/ppc/ppcdisasm.h" -#include "../cpu/ppc/ppcemu.h" -#include "../cpu/ppc/ppcmmu.h" -#include -#include "memaccess.h" -#include "utils/profiler.h" + +#ifdef DEBUG_CPU_INT +#include +#include +#endif #ifdef ENABLE_68K_DEBUGGER // optionally defined in CMakeLists.txt #include @@ -522,6 +529,7 @@ void enter_debugger() { cout << exc.what() << endl; } } else if (cmd == "go") { + power_on = true; ppc_exec(); // won't return! } else if (cmd == "disas" || cmd == "da") { expr_str = ""; @@ -662,6 +670,34 @@ void enter_debugger() { if (ofnvram->init()) continue; ofnvram->setenv("nvramrc", inp); +#endif +#ifdef DEBUG_CPU_INT + } else if (cmd == "amicint") { + string value; + int irq_id; + ss >> value; + try { + irq_id = str2num(value); + } catch (invalid_argument& exc) { + cout << exc.what() << endl; + continue; + } + InterruptCtrl* int_ctrl = dynamic_cast( + gMachineObj->get_comp_by_type(HWCompType::INT_CTRL)); + int_ctrl->ack_int(irq_id, 1); + } else if (cmd == "viaint") { + string value; + int irq_bit; + ss >> value; + try { + irq_bit = str2num(value); + } catch (invalid_argument& exc) { + cout << exc.what() << endl; + continue; + } + ViaCuda* via_obj = dynamic_cast(gMachineObj->get_comp_by_name("ViaCuda")); + ppc_state.pc -= 4; + via_obj->assert_int(irq_bit); #endif } else { cout << "Unknown command: " << cmd << endl; diff --git a/devices/common/hwinterrupt.h b/devices/common/hwinterrupt.h index b451af7..b2c83ce 100644 --- a/devices/common/hwinterrupt.h +++ b/devices/common/hwinterrupt.h @@ -24,6 +24,8 @@ along with this program. If not, see . #include +//#define DEBUG_CPU_INT // uncomment this to enable hacks for debugging HW interrupts + /** Enumerator for various interrupt sources. */ enum IntSrc : int { VIA_CUDA = 1, diff --git a/devices/common/viacuda.cpp b/devices/common/viacuda.cpp index 4e0ed69..b1206c3 100644 --- a/devices/common/viacuda.cpp +++ b/devices/common/viacuda.cpp @@ -282,6 +282,13 @@ void ViaCuda::assert_t2_int() { update_irq(); } +#ifdef DEBUG_CPU_INT +void ViaCuda::assert_int(uint8_t flags) { + this->_via_ifr |= (flags & 0x7F); + update_irq(); +} +#endif + void ViaCuda::assert_ctrl_line(ViaLine line) { switch (line) { diff --git a/devices/common/viacuda.h b/devices/common/viacuda.h index 0bf971b..22e3c7b 100644 --- a/devices/common/viacuda.h +++ b/devices/common/viacuda.h @@ -168,6 +168,10 @@ public: void assert_ctrl_line(ViaLine line); +#ifdef DEBUG_CPU_INT + void assert_int(uint8_t flags); +#endif + private: // VIA virtual HW registers uint8_t via_regs[16];