GBA: Add identifier lookup for GBA registers
Jeffrey Pfau jeffrey@endrift.com
Thu, 27 Nov 2014 10:36:19 -0800
4 files changed,
200 insertions(+),
2 deletions(-)
M
CMakeLists.txt
→
CMakeLists.txt
@@ -123,6 +123,7 @@ if(USE_CLI_DEBUGGER)
add_definitions(-DUSE_CLI_DEBUGGER) list(APPEND DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/debugger/cli-debugger.c) list(APPEND DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/debugger/parser.c) + list(APPEND DEBUGGER_SRC ${CMAKE_SOURCE_DIR}/src/gba/gba-cli.c) include_directories(AFTER ${LIBEDIT_INCLUDE_DIRS}) link_directories(${LIBEDIT_LIBRARY_DIRS}) set(DEBUGGER_LIB ${LIBEDIT_LIBRARIES})
M
src/gba/gba-cli.c
→
src/gba/gba-cli.c
@@ -1,5 +1,6 @@
#include "gba-cli.h" +#include "gba-io.h" #include "gba-thread.h" static void _GBACLIDebuggerInit(struct CLIDebuggerSystem*);@@ -33,8 +34,14 @@ UNUSED(debugger);
} static uint32_t _GBACLIDebuggerLookupIdentifier(struct CLIDebuggerSystem* debugger, const char* name, struct CLIDebugVector* dv) { - UNUSED(debugger); - UNUSED(name); + struct GBACLIDebugger* gbaDebugger = (struct GBACLIDebugger*) debugger; + int i; + for (i = 0; i < REG_MAX; i += 2) { + const char* reg = GBAIORegisterNames[i >> 1]; + if (reg && strcasecmp(reg, name) == 0) { + return GBALoad16(gbaDebugger->context->gba->cpu, BASE_IO | i, 0); + } + } dv->type = CLIDV_ERROR_TYPE; return 0; }
M
src/gba/gba-io.c
→
src/gba/gba-io.c
@@ -5,6 +5,194 @@ #include "gba-serialize.h"
#include "gba-sio.h" #include "gba-video.h" +const char* GBAIORegisterNames[] = { + // Video + "DISPCNT", + 0, + "DISPSTAT", + "VCOUNT", + "BG0CNT", + "BG1CNT", + "BG2CNT", + "BG3CNT", + "BG0HOFS", + "BG0VOFS", + "BG1HOFS", + "BG1VOFS", + "BG2HOFS", + "BG2VOFS", + "BG3HOFS", + "BG3VOFS", + "BG2PA", + "BG2PB", + "BG2PC", + "BG2PD", + "BG2X_LO", + "BG2X_HI", + "BG2Y_LO", + "BG2Y_HI", + "BG3PA", + "BG3PB", + "BG3PC", + "BG3PD", + "BG3X_LO", + "BG3X_HI", + "BG3Y_LO", + "BG3Y_HI", + "WIN0H", + "WIN1H", + "WIN0V", + "WIN1V", + "WININ", + "WINOUT", + "MOSAIC", + 0, + "BLDCNT", + "BLDALPHA", + "BLDY", + 0, + 0, + 0, + 0, + 0, + + // Sound + "SOUND1CNT_LO", + "SOUND1CNT_HI", + "SOUND1CNT_X", + 0, + "SOUND2CNT_LO", + 0, + "SOUND2CNT_HI", + 0, + "SOUND3CNT_LO", + "SOUND3CNT_HI", + "SOUND3CNT_X", + 0, + "SOUND4CNT_LO", + 0, + "SOUND4CNT_HI", + 0, + "SOUNDCNT_LO", + "SOUNDCNT_HI", + "SOUNDCNT_X", + 0, + "SOUNDBIAS", + 0, + 0, + 0, + "WAVE_RAM0_LO" + "WAVE_RAM0_HI", + "WAVE_RAM1_LO", + "WAVE_RAM1_HI", + "WAVE_RAM2_LO", + "WAVE_RAM2_HI", + "WAVE_RAM3_LO", + "WAVE_RAM3_HI", + "FIFO_A_LO", + "FIFO_A_HI", + "FIFO_B_LO", + "FIFO_B_HI", + 0, + 0, + 0, + 0, + + // DMA + "DMA0SAD_LO", + "DMA0SAD_HI", + "DMA0DAD_LO", + "DMA0DAD_HI", + "DMA0CNT_LO", + "DMA0CNT_HI", + "DMA1SAD_LO", + "DMA1SAD_HI", + "DMA1DAD_LO", + "DMA1DAD_HI", + "DMA1CNT_LO", + "DMA1CNT_HI", + "DMA2SAD_LO", + "DMA2SAD_HI", + "DMA2DAD_LO", + "DMA2DAD_HI", + "DMA2CNT_LO", + "DMA2CNT_HI", + "DMA3SAD_LO", + "DMA3SAD_HI", + "DMA3DAD_LO", + "DMA3DAD_HI", + "DMA3CNT_LO", + "DMA3CNT_HI", + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + // Timers + "TM0CNT_LO", + "TM0CNT_HI", + "TM1CNT_LO", + "TM1CNT_HI", + "TM2CNT_LO", + "TM2CNT_HI", + "TM3CNT_LO", + "TM3CNT_HI", + 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + + // SIO + "SIOMULTI0", + "SIOMULTI1", + "SIOMULTI2", + "SIOMULTI3", + "SIOCNT", + "SIOMLT_SEND", + 0, + 0, + "KEYINPUT", + "KEYCNT", + "RCNT", + 0, + 0, + 0, + 0, + 0, + "JOYCNT", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + "JOY_RECV_LO", + "JOY_RECV_HI", + "JOY_TRANS_LO", + "JOY_RECV_HI", + "JOYSTAT", + 0, + 0, + 0, + + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + + // Interrupts, etc + "IE", + "IF", + "WAITCNT", + 0, + "IME" +}; + static const int _isValidRegister[REG_MAX >> 1] = { // Video 1, 0, 1, 1, 1, 1, 1, 1,
M
src/gba/gba-io.h
→
src/gba/gba-io.h
@@ -146,6 +146,8 @@ REG_POSTFLG = 0x300,
REG_HALTCNT = 0x301 }; +extern const char* GBAIORegisterNames[]; + void GBAIOInit(struct GBA* gba); void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value); void GBAIOWrite8(struct GBA* gba, uint32_t address, uint8_t value);