dingusppc/debugger/debugger.cpp

709 lines
23 KiB
C++
Raw Normal View History

/*
DingusPPC - The Experimental PowerPC Macintosh emulator
Copyright (C) 2018-22 divingkatae and maximum
(theweirdo) spatium
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2020-01-05 17:38:32 +00:00
2022-08-27 15:34:05 +00:00
#include <cpu/ppc/ppcdisasm.h>
#include <cpu/ppc/ppcemu.h>
#include <cpu/ppc/ppcmmu.h>
#include <devices/common/hwinterrupt.h>
#include <devices/common/ofnvram.h>
#include "memaccess.h"
#include <utils/profiler.h>
2021-01-12 14:17:30 +00:00
#include <array>
2022-08-27 15:34:05 +00:00
#include <cstring>
2020-05-12 18:55:45 +00:00
#include <fstream>
#include <iomanip>
#include <iostream>
2021-09-26 12:21:31 +00:00
#include <loguru.hpp>
2020-05-12 18:55:45 +00:00
#include <map>
#include <memory>
2020-05-12 18:55:45 +00:00
#include <sstream>
#include <stdio.h>
#include <string>
2022-08-27 15:34:05 +00:00
#ifdef DEBUG_CPU_INT
#include <machines/machinebase.h>
#include <devices/common/viacuda.h>
#endif
2019-07-17 13:24:34 +00:00
#ifdef ENABLE_68K_DEBUGGER // optionally defined in CMakeLists.txt
#include <capstone/capstone.h>
#endif
using namespace std;
2020-05-12 18:55:45 +00:00
static uint32_t str2addr(string& addr_str) {
try {
return (uint32_t)stoul(addr_str, NULL, 0);
2020-05-12 18:55:45 +00:00
} catch (invalid_argument& exc) {
throw invalid_argument(string("Cannot convert ") + addr_str);
}
}
2020-05-12 18:55:45 +00:00
static uint32_t str2num(string& num_str) {
try {
return (uint32_t)stol(num_str, NULL, 0);
2020-05-12 18:55:45 +00:00
} catch (invalid_argument& exc) {
throw invalid_argument(string("Cannot convert ") + num_str);
}
}
2020-05-12 18:55:45 +00:00
static void show_help() {
2019-07-17 13:24:34 +00:00
cout << "Debugger commands:" << endl;
2021-04-14 15:04:14 +00:00
cout << " step [N] -- execute single instruction" << endl;
cout << " N is an optional step count" << endl;
cout << " si [N] -- shortcut for step" << endl;
cout << " next -- same as step but treats subroutine calls" << endl;
cout << " as single instructions." << endl;
cout << " ni -- shortcut for next" << endl;
cout << " until X -- execute until address X is reached" << endl;
2022-02-26 11:47:51 +00:00
cout << " go -- exit debugger and continue emulator execution" << endl;
2021-04-14 15:04:14 +00:00
cout << " regs -- dump content of the GRPs" << endl;
cout << " set R=X -- assign value X to register R" << endl;
cout << " if R=loglevel, set the internal" << endl;
cout << " log level to X whose range is -2...9" << endl;
cout << " dump NT,X -- dump N memory cells of size T at address X" << endl;
cout << " T can be b(byte), w(word), d(double)," << endl;
cout << " q(quad) or c(character)." << endl;
cout << " profile C N -- run subcommand C on profile N" << endl;
cout << " supported subcommands:" << endl;
cout << " 'show' - show profile report" << endl;
cout << " 'reset' - reset profile variables" << endl;
2020-01-15 03:50:01 +00:00
#ifdef PROFILER
2021-04-14 15:04:14 +00:00
cout << " profiler -- show stats related to the processor" << endl;
2020-01-15 03:50:01 +00:00
#endif
2021-04-14 15:04:14 +00:00
cout << " disas N,X -- disassemble N instructions starting at address X" << endl;
cout << " X can be any number or a known register name" << endl;
cout << " disas with no arguments defaults to disas 1,pc" << endl;
cout << " da N,X -- shortcut for disas" << endl;
#ifdef ENABLE_68K_DEBUGGER
2021-04-14 15:04:14 +00:00
cout << " context X -- switch to the debugging context X." << endl;
cout << " X can be either 'ppc' (default) or '68k'" << endl;
cout << " Use 68k for debugging emulated 68k code only." << endl;
#endif
cout << " printenv -- print current NVRAM settings." << endl;
cout << " setenv V N -- set NVRAM variable V to value N." << endl;
2021-04-14 15:04:14 +00:00
cout << " quit -- quit the debugger" << endl << endl;
2019-07-17 13:24:34 +00:00
cout << "Pressing ENTER will repeat last command." << endl;
}
#ifdef ENABLE_68K_DEBUGGER
2020-01-22 11:28:42 +00:00
2020-07-13 21:39:31 +00:00
static void disasm_68k(uint32_t count, uint32_t address) {
csh cs_handle;
uint8_t code[10];
2020-07-13 21:39:31 +00:00
size_t code_size;
uint64_t dis_addr;
if (cs_open(CS_ARCH_M68K, CS_MODE_M68K_040, &cs_handle) != CS_ERR_OK) {
cout << "Capstone initialization error" << endl;
return;
}
cs_insn* insn = cs_malloc(cs_handle);
for (; count > 0; count--) {
/* prefetch opcode bytes (a 68k instruction can occupy 2...10 bytes) */
2020-07-13 21:39:31 +00:00
for (int i = 0; i < sizeof(code); i++) {
code[i] = mem_read_dbg(address + i, 1);
}
const uint8_t *code_ptr = code;
code_size = sizeof(code);
dis_addr = address;
// catch and handle F-Traps (Nanokernel calls) ourselves because
// Capstone will likely return no meaningful assembly for them
if ((code[0] & 0xF0) == 0xF0) {
goto print_bin;
}
2020-07-13 21:39:31 +00:00
if (cs_disasm_iter(cs_handle, &code_ptr, &code_size, &dis_addr, insn)) {
cout << uppercase << hex << insn->address << " ";
2020-07-20 16:00:04 +00:00
cout << setfill(' ');
cout << setw(10) << left << insn->mnemonic << insn->op_str << endl;
2020-07-13 21:39:31 +00:00
address = dis_addr;
} else {
print_bin:
cout << uppercase << hex << address << " ";
cout << setfill(' ');
cout << setw(10) << left << "dc.w" << "$" << hex <<
((code[0] << 8) | code[1]) << endl;
2020-07-13 21:39:31 +00:00
address += 2;
}
}
cs_free(insn, 1);
cs_close(&cs_handle);
}
/* emulator opcode table size --> 512 KB */
#define EMU_68K_TABLE_SIZE 0x80000
/** Execute one emulated 68k instruction. */
void exec_single_68k()
{
uint32_t emu_table_virt, cur_68k_pc, cur_instr_tab_entry, ppc_pc;
/* PPC r24 contains 68k PC advanced by two bytes
as part of instruction prefetching */
cur_68k_pc = get_reg(string("R24")) - 2;
/* PPC r29 contains base address of the emulator opcode table */
emu_table_virt = get_reg(string("R29")) & 0xFFF80000;
/* calculate address of the current opcode table entry as follows:
get_word(68k_PC) * entry_size + table_base */
2021-09-25 13:57:35 +00:00
cur_instr_tab_entry = mmu_read_vmem<uint16_t>(cur_68k_pc) * 8 + emu_table_virt;
/* grab the PPC PC too */
ppc_pc = get_reg(string("PC"));
//printf("cur_instr_tab_entry = %X\n", cur_instr_tab_entry);
/* because the first two PPC instructions for each emulated 68k once
are resided in the emulator opcode table, we need to execute them
one by one until the execution goes outside the opcode table. */
while (ppc_pc >= cur_instr_tab_entry && ppc_pc < cur_instr_tab_entry + 8) {
ppc_exec_single();
ppc_pc = get_reg(string("PC"));
}
/* Getting here means we're outside the emualtor opcode table.
Execute PPC code until we hit the opcode table again. */
2020-07-20 21:02:07 +00:00
ppc_exec_dbg(emu_table_virt, EMU_68K_TABLE_SIZE - 1);
}
/** Execute emulated 68k code until target_addr is reached. */
void exec_until_68k(uint32_t target_addr)
{
uint32_t emu_table_virt, ppc_pc;
emu_table_virt = get_reg(string("R29")) & 0xFFF80000;
while (target_addr != (get_reg(string("R24")) - 2)) {
ppc_pc = get_reg(string("PC"));
2020-07-20 21:02:07 +00:00
if (ppc_pc >= emu_table_virt && ppc_pc < (emu_table_virt + EMU_68K_TABLE_SIZE - 1)) {
ppc_exec_single();
} else {
2020-07-20 21:02:07 +00:00
ppc_exec_dbg(emu_table_virt, EMU_68K_TABLE_SIZE - 1);
}
}
}
void print_68k_regs()
{
int i;
string reg;
for (i = 0; i < 8; i++) {
reg = "R" + to_string(i + 8);
cout << "D" << dec << i << " : " << uppercase << hex << get_reg(reg) << endl;
}
for (i = 0; i < 7; i++) {
reg = "R" + to_string(i + 16);
cout << "A" << dec << i << " : " << uppercase << hex << get_reg(reg) << endl;
}
cout << "A7 : " << uppercase << hex << get_reg(string("R1")) << endl;
cout << "PC: " << uppercase << hex << get_reg(string("R24")) - 2 << endl;
cout << "SR: " << uppercase << hex << ((get_reg("R25") & 0xFF) << 8) << endl;
cout << "CCR: " << uppercase << hex << get_reg(string("R26")) << endl;
}
#endif // ENABLE_68K_DEBUGGER
2020-05-12 18:55:45 +00:00
static void dump_mem(string& params) {
int cell_size, chars_per_line;
bool is_char;
uint32_t count, addr;
uint64_t val;
string num_type_str, addr_str;
2020-02-28 07:58:14 +00:00
size_t separator_pos;
2020-02-28 07:58:14 +00:00
separator_pos = params.find_first_of(",");
if (separator_pos == std::string::npos) {
cout << "dump: not enough arguments specified." << endl;
return;
}
num_type_str = params.substr(0, params.find_first_of(","));
2020-05-12 18:55:45 +00:00
addr_str = params.substr(params.find_first_of(",") + 1);
is_char = false;
2020-05-12 18:55:45 +00:00
switch (num_type_str.back()) {
case 'b':
case 'B':
cell_size = 1;
break;
case 'w':
case 'W':
cell_size = 2;
break;
case 'd':
case 'D':
cell_size = 4;
break;
case 'q':
case 'Q':
cell_size = 8;
break;
case 'c':
case 'C':
cell_size = 1;
is_char = true;
break;
default:
cout << "Invalid data type " << num_type_str << endl;
return;
}
try {
num_type_str = num_type_str.substr(0, num_type_str.length() - 1);
2020-05-12 18:55:45 +00:00
count = str2addr(num_type_str);
} catch (invalid_argument& exc) {
cout << exc.what() << endl;
return;
}
try {
2020-05-12 18:55:45 +00:00
addr = str2addr(addr_str);
} catch (invalid_argument& exc) {
try {
/* number conversion failed, trying reg name */
addr = get_reg(addr_str);
2020-05-12 18:55:45 +00:00
} catch (invalid_argument& exc) {
cout << exc.what() << endl;
return;
}
}
cout << "Dumping memory at address " << hex << addr << ":" << endl;
chars_per_line = 0;
try {
for (int i = 0; i < count; addr += cell_size, i++) {
if (chars_per_line + cell_size * 2 > 80) {
cout << endl;
chars_per_line = 0;
}
val = mem_read_dbg(addr, cell_size);
if (is_char) {
cout << (char)val;
chars_per_line += cell_size;
} else {
2020-07-20 16:00:04 +00:00
cout << setw(cell_size * 2) << setfill('0') << right;
cout << uppercase << hex << val << " ";
chars_per_line += cell_size * 2 + 2;
}
}
2020-05-12 18:55:45 +00:00
} catch (invalid_argument& exc) {
cout << exc.what() << endl;
return;
}
cout << endl << endl;
}
static void disasm(uint32_t count, uint32_t address) {
PPCDisasmContext ctx;
2020-07-13 21:39:31 +00:00
ctx.instr_addr = address;
ctx.simplified = true;
2020-07-13 21:39:31 +00:00
for (int i = 0; i < count; i++) {
2021-09-26 12:21:31 +00:00
ctx.instr_code = READ_DWORD_BE_A(mmu_translate_imem(ctx.instr_addr));
cout << uppercase << hex << ctx.instr_addr;
cout << " " << disassemble_single(&ctx) << endl;
2020-07-13 21:39:31 +00:00
}
}
2021-01-12 14:17:30 +00:00
static void print_gprs() {
string reg_name;
int i;
for (i = 0; i < 32; i++) {
reg_name = "R" + to_string(i);
cout << right << std::setw(3) << setfill(' ') << reg_name << " : " <<
setw(8) << setfill('0') << right << uppercase << hex << get_reg(reg_name);
if (i & 1) {
cout << endl;
} else {
cout << "\t\t";
}
}
array<string,6> sprs = {"PC", "LR", "CR", "CTR", "XER", "MSR"};
for (auto &spr : sprs) {
cout << right << std::setw(3) << setfill(' ') << spr << " : " <<
setw(8) << setfill('0') << uppercase << hex << get_reg(spr);
if (i & 1) {
cout << endl;
} else {
cout << "\t\t";
}
i++;
}
}
#ifndef _WIN32
#include <signal.h>
#include <termios.h>
#include <unistd.h>
static struct sigaction old_act_sigint, new_act_sigint;
static struct sigaction old_act_sigterm, new_act_sigterm;
static struct termios orig_termios;
static void mysig_handler(int signum)
{
// restore original terminal state
tcsetattr(STDIN_FILENO, TCSANOW, &orig_termios);
// restore original signal handler for SIGINT
signal(SIGINT, old_act_sigint.sa_handler);
signal(SIGTERM, old_act_sigterm.sa_handler);
LOG_F(INFO, "Old terminal state restored, SIG#=%d", signum);
// re-post signal
raise(signum);
}
#endif
2020-05-12 18:55:45 +00:00
void enter_debugger() {
2021-04-13 23:27:07 +00:00
string inp, cmd, addr_str, expr_str, reg_expr, last_cmd, reg_value_str,
2021-04-14 15:04:14 +00:00
inst_string, inst_num_str, profile_name, sub_cmd;
2020-02-06 13:41:17 +00:00
uint32_t addr, inst_grab;
2019-07-17 13:24:34 +00:00
std::stringstream ss;
2020-07-13 21:39:31 +00:00
int log_level, context;
2020-02-28 07:58:14 +00:00
size_t separator_pos;
2019-07-17 13:24:34 +00:00
unique_ptr<OfConfigUtils> ofnvram = unique_ptr<OfConfigUtils>(new OfConfigUtils);
2020-07-13 21:39:31 +00:00
context = 1; /* start with the PowerPC context */
cout << "Welcome to the DingusPPC command line debugger." << endl;
2019-07-17 13:24:34 +00:00
cout << "Please enter a command or 'help'." << endl << endl;
while (1) {
cout << "dingusdbg> ";
2019-07-17 13:24:34 +00:00
/* reset string stream */
ss.str("");
ss.clear();
cmd = "";
getline(cin, inp, '\n');
ss.str(inp);
ss >> cmd;
if (cmd.empty() && !last_cmd.empty()) {
cmd = last_cmd;
cout << cmd << endl;
}
if (cmd == "help") {
show_help();
2020-05-12 18:55:45 +00:00
} else if (cmd == "quit") {
2019-07-17 13:24:34 +00:00
break;
2021-04-13 23:27:07 +00:00
} else if (cmd == "profile") {
2021-04-14 15:04:14 +00:00
ss >> sub_cmd;
2021-04-13 23:27:07 +00:00
ss >> profile_name;
2021-04-14 15:04:14 +00:00
if (sub_cmd == "show") {
gProfilerObj->print_profile(profile_name);
} else if (sub_cmd == "reset") {
gProfilerObj->reset_profile(profile_name);
} else {
cout << "Unknown/empty subcommand " << sub_cmd << endl;
}
}
else if (cmd == "regs") {
2020-07-13 21:39:31 +00:00
if (context == 2) {
#ifdef ENABLE_68K_DEBUGGER
2020-07-13 21:39:31 +00:00
print_68k_regs();
#endif
2020-07-13 21:39:31 +00:00
} else {
print_gprs();
}
2020-05-12 18:55:45 +00:00
} else if (cmd == "set") {
2020-01-16 11:29:01 +00:00
ss >> expr_str;
2020-02-28 07:58:14 +00:00
separator_pos = expr_str.find_first_of("=");
if (separator_pos == std::string::npos) {
cout << "set: not enough arguments specified." << endl;
continue;
}
try {
2020-02-28 07:58:14 +00:00
reg_expr = expr_str.substr(0, expr_str.find_first_of("="));
addr_str = expr_str.substr(expr_str.find_first_of("=") + 1);
if (reg_expr == "loglevel") {
log_level = str2num(addr_str);
if (log_level < -2 || log_level > 9) {
cout << "Log level must be in the range -2...9!" << endl;
continue;
}
loguru::g_stderr_verbosity = log_level;
2020-05-12 18:55:45 +00:00
} else {
addr = str2addr(addr_str);
set_reg(reg_expr, addr);
}
2020-05-12 18:55:45 +00:00
} catch (invalid_argument& exc) {
cout << exc.what() << endl;
2020-01-16 11:29:01 +00:00
}
2020-05-12 18:55:45 +00:00
} else if (cmd == "step" || cmd == "si") {
2021-01-12 14:17:30 +00:00
int count;
expr_str = "";
ss >> expr_str;
if (expr_str.length() > 0) {
try {
count = str2num(expr_str);
} catch (invalid_argument& exc) {
cout << exc.what() << endl;
count = 1;
}
} else {
count = 1;
}
if (context == 2) {
#ifdef ENABLE_68K_DEBUGGER
2021-01-12 14:17:30 +00:00
for (; --count >= 0;) {
exec_single_68k();
}
#endif
} else {
2021-01-12 14:17:30 +00:00
for (; --count >= 0;) {
ppc_exec_single();
}
}
2020-05-12 18:55:45 +00:00
} else if (cmd == "next" || cmd == "ni") {
addr_str = "PC";
addr = (uint32_t)get_reg(addr_str) + 4;
ppc_exec_until(addr);
2020-05-12 18:55:45 +00:00
} else if (cmd == "until") {
2019-07-17 13:24:34 +00:00
ss >> addr_str;
try {
addr = str2addr(addr_str);
if (context == 2) {
#ifdef ENABLE_68K_DEBUGGER
exec_until_68k(addr);
#endif
} else {
ppc_exec_until(addr);
}
2020-05-12 18:55:45 +00:00
} catch (invalid_argument& exc) {
cout << exc.what() << endl;
}
2022-02-26 11:47:51 +00:00
} else if (cmd == "go") {
2022-08-27 15:34:05 +00:00
power_on = true;
2022-02-26 11:47:51 +00:00
ppc_exec(); // won't return!
2021-01-12 14:17:30 +00:00
} else if (cmd == "disas" || cmd == "da") {
2020-02-06 13:41:17 +00:00
expr_str = "";
ss >> expr_str;
if (expr_str.length() > 0) {
2020-02-28 07:58:14 +00:00
separator_pos = expr_str.find_first_of(",");
if (separator_pos == std::string::npos) {
cout << "disas: not enough arguments specified." << endl;
continue;
}
2021-01-12 14:17:30 +00:00
2020-02-28 07:58:14 +00:00
inst_num_str = expr_str.substr(0, expr_str.find_first_of(","));
2021-01-12 14:17:30 +00:00
try {
inst_grab = str2num(inst_num_str);
} catch (invalid_argument& exc) {
cout << exc.what() << endl;
continue;
}
addr_str = expr_str.substr(expr_str.find_first_of(",") + 1);
try {
addr = str2addr(addr_str);
2020-05-12 18:55:45 +00:00
} catch (invalid_argument& exc) {
try {
/* number conversion failed, trying reg name */
2020-07-13 21:39:31 +00:00
if (context == 2 && (addr_str == "pc" || addr_str == "PC")) {
addr_str = "R24";
addr = get_reg(addr_str) - 2;
} else {
addr = get_reg(addr_str);
}
2020-05-12 18:55:45 +00:00
} catch (invalid_argument& exc) {
cout << exc.what() << endl;
continue;
}
}
try {
2020-07-13 21:39:31 +00:00
if (context == 2) {
#ifdef ENABLE_68K_DEBUGGER
2020-07-13 21:39:31 +00:00
disasm_68k(inst_grab, addr);
#endif
2020-07-13 21:39:31 +00:00
} else {
disasm(inst_grab, addr);
}
2020-05-12 18:55:45 +00:00
} catch (invalid_argument& exc) {
cout << exc.what() << endl;
}
2020-05-12 18:55:45 +00:00
} else {
2020-02-28 07:58:14 +00:00
/* disas without arguments defaults to disas 1,pc */
2021-09-26 12:21:31 +00:00
try {
if (context == 2) {
#ifdef ENABLE_68K_DEBUGGER
2021-09-26 12:21:31 +00:00
addr_str = "R24";
addr = get_reg(addr_str);
disasm_68k(1, addr - 2);
#endif
2021-09-26 12:21:31 +00:00
} else {
addr_str = "PC";
addr = (uint32_t)get_reg(addr_str);
2021-09-26 12:21:31 +00:00
disasm(1, addr);
}
} catch (invalid_argument& exc) {
cout << exc.what() << endl;
2020-07-13 21:39:31 +00:00
}
2020-02-06 13:41:17 +00:00
}
2020-05-12 18:55:45 +00:00
} else if (cmd == "dump") {
expr_str = "";
ss >> expr_str;
dump_mem(expr_str);
#ifdef ENABLE_68K_DEBUGGER
2020-07-13 21:39:31 +00:00
} else if (cmd == "context") {
expr_str = "";
ss >> expr_str;
if (expr_str == "ppc" || expr_str == "PPC") {
context = 1;
} else if (expr_str == "68k" || expr_str == "68K") {
context = 2;
} else {
cout << "Unknown debugging context: " << expr_str << endl;
}
#endif
} else if (cmd == "printenv") {
if (ofnvram->init())
continue;
ofnvram->printenv();
} else if (cmd == "setenv") {
string var_name, value;
ss >> var_name;
ss >> value;
if (ofnvram->init())
continue;
ofnvram->setenv(var_name, value);
#ifndef _WIN32
} else if (cmd == "nvedit") {
cout << "===== press CNTRL-C to save =====" << endl;
// save original terminal state
tcgetattr(STDIN_FILENO, &orig_termios);
struct termios new_termios = orig_termios;
new_termios.c_cflag &= ~(CSIZE | PARENB);
new_termios.c_cflag |= CS8;
new_termios.c_lflag &= ~(ISIG | NOFLSH | ICANON | ECHOCTL);
new_termios.c_lflag |= NOFLSH | ECHONL;
// new_termios.c_iflag &= ~(ICRNL | IGNCR);
// new_termios.c_iflag |= INLCR;
// new_termios.c_oflag &= ~(ONOCR | ONLCR);
// new_termios.c_oflag |= OPOST | OCRNL | ONLRET;
tcsetattr(STDIN_FILENO, TCSANOW, &new_termios);
// save original signal handler for SIGINT
// then redirect SIGINT to new handler
memset(&new_act_sigint, 0, sizeof(new_act_sigint));
new_act_sigint.sa_handler = mysig_handler;
sigaction(SIGINT, &new_act_sigint, &old_act_sigint);
// save original signal handler for SIGTERM
// then redirect SIGTERM to new handler
memset(&new_act_sigterm, 0, sizeof(new_act_sigterm));
new_act_sigterm.sa_handler = mysig_handler;
sigaction(SIGTERM, &new_act_sigterm, &old_act_sigterm);
getline(cin, inp, '\x03');
// restore original terminal state
tcsetattr(STDIN_FILENO, TCSANOW, &orig_termios);
// restore original signal handler for SIGINT
signal(SIGINT, old_act_sigint.sa_handler);
// restore original signal handler for SIGTERM
signal(SIGTERM, old_act_sigterm.sa_handler);
if (ofnvram->init())
continue;
ofnvram->setenv("nvramrc", inp);
2022-08-27 15:34:05 +00:00
#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<InterruptCtrl*>(
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<ViaCuda*>(gMachineObj->get_comp_by_name("ViaCuda"));
ppc_state.pc -= 4;
via_obj->assert_int(irq_bit);
#endif
2020-05-12 18:55:45 +00:00
} else {
2019-07-17 13:24:34 +00:00
cout << "Unknown command: " << cmd << endl;
continue;
}
last_cmd = cmd;
}
}