DS IPC: Add logging

This commit is contained in:
Vicki Pfau 2017-02-20 16:24:13 -08:00
parent a4f3c99faf
commit dfdc2b3edd
2 changed files with 9 additions and 1 deletions

View File

@ -10,6 +10,10 @@
CXX_GUARD_START CXX_GUARD_START
#include <mgba/core/log.h>
mLOG_DECLARE_CATEGORY(DS_IPC);
DECL_BITFIELD(DSIPCFIFOCNT, int16_t); DECL_BITFIELD(DSIPCFIFOCNT, int16_t);
DECL_BIT(DSIPCFIFOCNT, SendEmpty, 0); DECL_BIT(DSIPCFIFOCNT, SendEmpty, 0);
DECL_BIT(DSIPCFIFOCNT, SendFull, 1); DECL_BIT(DSIPCFIFOCNT, SendFull, 1);

View File

@ -8,11 +8,13 @@
#include <mgba/internal/ds/ds.h> #include <mgba/internal/ds/ds.h>
#include <mgba/internal/ds/io.h> #include <mgba/internal/ds/io.h>
mLOG_DEFINE_CATEGORY(DS_IPC, "DS IPC");
void DSIPCWriteSYNC(struct ARMCore* remoteCpu, uint16_t* remoteIo, int16_t value) { void DSIPCWriteSYNC(struct ARMCore* remoteCpu, uint16_t* remoteIo, int16_t value) {
remoteIo[DS_REG_IPCSYNC >> 1] &= 0xFFF0; remoteIo[DS_REG_IPCSYNC >> 1] &= 0xFFF0;
remoteIo[DS_REG_IPCSYNC >> 1] |= (value >> 8) & 0x0F; remoteIo[DS_REG_IPCSYNC >> 1] |= (value >> 8) & 0x0F;
if (value & 0x2000 && remoteIo[DS_REG_IPCSYNC >> 1] & 0x4000) { if (value & 0x2000 && remoteIo[DS_REG_IPCSYNC >> 1] & 0x4000) {
mLOG(DS_IO, STUB, "Unimplemented IPC IRQ"); mLOG(DS_IPC, STUB, "Unimplemented IRQ");
UNUSED(remoteCpu); UNUSED(remoteCpu);
} }
} }
@ -38,6 +40,7 @@ void DSIPCWriteFIFO(struct DSCommon* dscore, int32_t value) {
if (!DSIPCFIFOCNTIsEnable(dscore->memory.io[DS_REG_IPCFIFOCNT >> 1])) { if (!DSIPCFIFOCNTIsEnable(dscore->memory.io[DS_REG_IPCFIFOCNT >> 1])) {
return; return;
} }
mLOG(DS_IPC, DEBUG, "Written from ARM%c: %08X", (dscore == &dscore->p->ds7) ? '7' : '9', value);
CircleBufferWrite32(&dscore->ipc->fifo, value); CircleBufferWrite32(&dscore->ipc->fifo, value);
size_t fullness = CircleBufferSize(&dscore->ipc->fifo); size_t fullness = CircleBufferSize(&dscore->ipc->fifo);
if (fullness == 4) { if (fullness == 4) {
@ -59,6 +62,7 @@ int32_t DSIPCReadFIFO(struct DSCommon* dscore) {
} }
int32_t value = ((int32_t*) dscore->ipc->memory.io)[DS_REG_IPCFIFOSEND_LO >> 2]; // TODO: actual last value int32_t value = ((int32_t*) dscore->ipc->memory.io)[DS_REG_IPCFIFOSEND_LO >> 2]; // TODO: actual last value
CircleBufferRead32(&dscore->fifo, &value); CircleBufferRead32(&dscore->fifo, &value);
mLOG(DS_IPC, DEBUG, "Read from ARM%c: %08X", (dscore == &dscore->p->ds7) ? '7' : '9', value);
size_t fullness = CircleBufferSize(&dscore->fifo); size_t fullness = CircleBufferSize(&dscore->fifo);
dscore->memory.io[DS_REG_IPCFIFOCNT >> 1] = DSIPCFIFOCNTClearRecvFull(dscore->memory.io[DS_REG_IPCFIFOCNT >> 1]); dscore->memory.io[DS_REG_IPCFIFOCNT >> 1] = DSIPCFIFOCNTClearRecvFull(dscore->memory.io[DS_REG_IPCFIFOCNT >> 1]);
dscore->ipc->memory.io[DS_REG_IPCFIFOCNT >> 1] = DSIPCFIFOCNTClearSendFull(dscore->ipc->memory.io[DS_REG_IPCFIFOCNT >> 1]); dscore->ipc->memory.io[DS_REG_IPCFIFOCNT >> 1] = DSIPCFIFOCNTClearSendFull(dscore->ipc->memory.io[DS_REG_IPCFIFOCNT >> 1]);