summaryrefslogtreecommitdiff
path: root/Source/Plugins
diff options
context:
space:
mode:
authorhrydgard <hrydgard@gmail.com>2009-06-07 11:06:40 +0000
committerhrydgard <hrydgard@gmail.com>2009-06-07 11:06:40 +0000
commitbb06a53e28ee3403e92e42aeba303ac69aecf3d6 (patch)
tree2621a68067ad0a6b29653c2b6f62c339ab579442 /Source/Plugins
parent89cd1a4a76b02f24a9477c4c5b5db84d6565b9b2 (diff)
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
Diffstat (limited to 'Source/Plugins')
-rw-r--r--Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj8
-rw-r--r--Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp183
-rw-r--r--Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.h32
-rw-r--r--Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.cpp3
-rw-r--r--Source/Plugins/Plugin_DSP_LLE/Src/Tools.cpp3
-rw-r--r--Source/Plugins/Plugin_DSP_LLE/Src/main.cpp23
6 files changed, 233 insertions, 19 deletions
diff --git a/Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj b/Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj
index f39699d234..9b83e612e2 100644
--- a/Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj
+++ b/Source/Plugins/Plugin_DSP_LLE/Plugin_DSP_LLE.vcproj
@@ -811,6 +811,14 @@
>
</File>
<File
+ RelativePath=".\Src\DSPDebugInterface.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Src\DSPDebugInterface.h"
+ >
+ </File>
+ <File
RelativePath=".\Src\Debugger\DSPRegisterView.cpp"
>
</File>
diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp
new file mode 100644
index 0000000000..540add418d
--- /dev/null
+++ b/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp
@@ -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()
+{
+
+}
diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.h b/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.h
new file mode 100644
index 0000000000..e542bfe0a9
--- /dev/null
+++ b/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.h
@@ -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
diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.cpp
index 112ea29807..baed853928 100644
--- a/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.cpp
+++ b/Source/Plugins/Plugin_DSP_LLE/Src/Debugger/Debugger.cpp
@@ -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;
diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/Tools.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/Tools.cpp
index adefc11e41..50252937b2 100644
--- a/Source/Plugins/Plugin_DSP_LLE/Src/Tools.cpp
+++ b/Source/Plugins/Plugin_DSP_LLE/Src/Tools.cpp
@@ -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);
diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp
index b42e3ea1f6..f3c9f3f204 100644
--- a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp
+++ b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp
@@ -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)