DSP LLE: Just some renaming and cleanup. Prepared for proper base address support in disassembly. Added a "DebugInterface" for the DSP which would allow us to hook up a CodeView .. although CoreView currently doesn't have any support for variable-length instructions.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3351 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2009-06-07 11:06:40 +00:00
parent 89cd1a4a76
commit bb06a53e28
15 changed files with 309 additions and 123 deletions

View File

@ -0,0 +1,183 @@
// Copyright (C) 2003-2009 Dolphin Project.
// 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, version 2.0.
// 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 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "DSPDebugInterface.h"
#include "DSPCore.h"
#include "disassemble.h"
void DSPDebugInterface::disasm(unsigned int address, char *dest, int max_size)
{
AssemblerSettings settings;
settings.print_tabs = true;
u16 pc = address;
DSPDisassembler dis(settings);
u16 base = 0;
const u16 *binbuf = g_dsp.iram;
if (pc & 0x8000)
{
binbuf = g_dsp.irom;
base = 0x8000;
}
std::string text;
dis.DisOpcode(binbuf, base, 2, &pc, text);
strncpy(dest, text.c_str(), max_size);
dest[max_size - 1] = '\0';
/*
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
if (Memory::IsRAMAddress(address, true))
{
u32 op = Memory::Read_Instruction(address);
DisassembleGekko(op, address, dest, max_size);
UGeckoInstruction inst;
inst.hex = Memory::ReadUnchecked_U32(address);
if (inst.OPCD == 1) {
strcat(dest, " (hle)");
}
}
else
{
strcpy(dest, "(No RAM here)");
}
}
else
{
strcpy(dest, "<unknown>");
}*/
}
void DSPDebugInterface::getRawMemoryString(unsigned int address, char *dest, int max_size)
{
/*
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
if (Memory::IsRAMAddress(address, true))
{
snprintf(dest, max_size, "%08X", readMemory(address));
}
else
{
strcpy(dest, "--------");
}
}
else
{
strcpy(dest, "<unknwn>"); // bad spelling - 8 chars
}*/
}
unsigned int DSPDebugInterface::readMemory(unsigned int address)
{
return 0; //Memory::ReadUnchecked_U32(address);
}
unsigned int DSPDebugInterface::readInstruction(unsigned int address)
{
return 0; //Memory::Read_Instruction(address);
}
bool DSPDebugInterface::isAlive()
{
return true; //Core::GetState() != Core::CORE_UNINITIALIZED;
}
bool DSPDebugInterface::isBreakpoint(unsigned int address)
{
return false; //BreakPoints::IsAddressBreakPoint(address);
}
void DSPDebugInterface::setBreakpoint(unsigned int address)
{
//if (BreakPoints::Add(address))
// jit.NotifyBreakpoint(address, true);
}
void DSPDebugInterface::clearBreakpoint(unsigned int address)
{
//if (BreakPoints::Remove(address))
// jit.NotifyBreakpoint(address, false);
}
void DSPDebugInterface::clearAllBreakpoints() {}
void DSPDebugInterface::toggleBreakpoint(unsigned int address)
{
//if (BreakPoints::IsAddressBreakPoint(address))
// BreakPoints::Remove(address);
//else
// BreakPoints::Add(address);
}
void DSPDebugInterface::insertBLR(unsigned int address)
{
// Memory::Write_U32(0x4e800020, address);
}
// =======================================================
// Separate the blocks with colors.
// -------------
int DSPDebugInterface::getColor(unsigned int address)
{
return 0xEEEEEE;
/*
if (!Memory::IsRAMAddress(address, true))
return 0xeeeeee;
static const int colors[6] =
{
0xd0FFFF, // light cyan
0xFFd0d0, // light red
0xd8d8FF, // light blue
0xFFd0FF, // light purple
0xd0FFd0, // light green
0xFFFFd0, // light yellow
};
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(address);
if (!symbol)
return 0xFFFFFF;
if (symbol->type != Symbol::SYMBOL_FUNCTION)
return 0xEEEEFF;
return colors[symbol->index % 6];*/
}
// =============
std::string DSPDebugInterface::getDescription(unsigned int address)
{
return "asdf"; // g_symbolDB.GetDescription(address);
}
unsigned int DSPDebugInterface::getPC()
{
return 0;
}
void DSPDebugInterface::setPC(unsigned int address)
{
//PowerPC::ppcState.pc = address;
}
void DSPDebugInterface::runToBreakpoint()
{
}

View File

@ -0,0 +1,32 @@
#ifndef _DSPDEBUGINTERFACE_H
#define _DSPDEBUGINTERFACE_H
#include <string>
#include "../../../Core/Core/Src/Debugger/DebugInterface.h"
class DSPDebugInterface : public DebugInterface
{
public:
DSPDebugInterface(){}
virtual void disasm(unsigned int address, char *dest, int max_size);
virtual void getRawMemoryString(unsigned int address, char *dest, int max_size);
virtual int getInstructionSize(int instruction) {return 2;}
virtual bool isAlive();
virtual bool isBreakpoint(unsigned int address);
virtual void setBreakpoint(unsigned int address);
virtual void clearBreakpoint(unsigned int address);
virtual void clearAllBreakpoints();
virtual void toggleBreakpoint(unsigned int address);
virtual unsigned int readMemory(unsigned int address);
virtual unsigned int readInstruction(unsigned int address);
virtual unsigned int getPC();
virtual void setPC(unsigned int address);
virtual void step() {}
virtual void runToBreakpoint();
virtual void insertBLR(unsigned int address);
virtual int getColor(unsigned int address);
virtual std::string getDescription(unsigned int address);
};
#endif // _DSPDEBUGINTERFACE_H

View File

@ -219,7 +219,8 @@ void DSPDebuggerLLE::RebuildDisAsmListView()
DSPDisassembler disasm(settings);
std::string op_str;
disasm.DisOpcode(binbuf, 2, &settings.pc, op_str);
disasm.DisOpcode(binbuf, settings.pc & 0x8000, 2, &settings.pc, op_str);
const char* pParameter = NULL;
const char* pExtension = NULL;

View File

@ -60,7 +60,8 @@ bool DumpDSPCode(const u8 *code_be, int size_in_bytes, u32 crc)
std::string text;
DSPDisassembler disasm(settings);
if (!disasm.Disassemble(0, code, text))
if (!disasm.Disassemble(0, code, 0x0000, text))
return false;
return File::WriteStringToFile(true, text, txtFile);

View File

@ -206,28 +206,17 @@ void Initialize(void *init)
g_Config.Load();
gdsp_init();
g_dsp.step_counter = 0;
std::string irom_filename = File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + DSP_IROM;
std::string coef_filename = File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + DSP_COEF;
bCanWork = DSPCore_Init(irom_filename.c_str(), coef_filename.c_str());
g_dsp.cpu_ram = g_dspInitialize.pGetMemoryPointer(0);
g_dsp.irq_request = dspi_req_dsp_irq;
// g_dsp.exception_in_progress_hack = false;
gdsp_reset();
if (!gdsp_load_irom((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + DSP_IROM).c_str()))
{
bCanWork = false;
PanicAlert("Failed loading DSP ROM from " DSP_IROM_FILE);
}
if (!gdsp_load_coef((File::GetSysDirectory() + GC_SYS_DIR + DIR_SEP + DSP_COEF).c_str()))
{
bCanWork = false;
PanicAlert("Failed loading DSP COEF from " DSP_COEF_FILE);
}
DSPCore_Reset();
if (!bCanWork)
{
gdsp_shutdown();
DSPCore_Shutdown();
return;
}
@ -261,7 +250,7 @@ void DSP_StopSoundStream()
void Shutdown()
{
AudioCommon::ShutdownSoundStream();
gdsp_shutdown();
DSPCore_Shutdown();
}
u16 DSP_WriteControlRegister(u16 _uFlag)