mirror of https://github.com/mgba-emu/mgba.git
GBA DMA: Enhanced logging (closes #2454)
This commit is contained in:
parent
a1945cb57a
commit
cf06497456
1
CHANGES
1
CHANGES
|
@ -44,6 +44,7 @@ Misc:
|
||||||
- Core: Suspend runloop when a core crashes
|
- Core: Suspend runloop when a core crashes
|
||||||
- GB Video: Add default SGB border
|
- GB Video: Add default SGB border
|
||||||
- GBA: Automatically skip BIOS if ROM has invalid logo
|
- GBA: Automatically skip BIOS if ROM has invalid logo
|
||||||
|
- GBA DMA: Enhanced logging (closes mgba.io/i/2454)
|
||||||
- mGUI: Add margin to right-aligned menu text (fixes mgba.io/i/871)
|
- mGUI: Add margin to right-aligned menu text (fixes mgba.io/i/871)
|
||||||
- Qt: Rearrange menus some
|
- Qt: Rearrange menus some
|
||||||
- Qt: Clean up cheats dialog
|
- Qt: Clean up cheats dialog
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
CXX_GUARD_START
|
CXX_GUARD_START
|
||||||
|
|
||||||
|
#include <mgba/core/log.h>
|
||||||
|
|
||||||
enum GBADMAControl {
|
enum GBADMAControl {
|
||||||
GBA_DMA_INCREMENT = 0,
|
GBA_DMA_INCREMENT = 0,
|
||||||
GBA_DMA_DECREMENT = 1,
|
GBA_DMA_DECREMENT = 1,
|
||||||
|
@ -34,6 +36,8 @@ DECL_BITS(GBADMARegister, Timing, 12, 2);
|
||||||
DECL_BIT(GBADMARegister, DoIRQ, 14);
|
DECL_BIT(GBADMARegister, DoIRQ, 14);
|
||||||
DECL_BIT(GBADMARegister, Enable, 15);
|
DECL_BIT(GBADMARegister, Enable, 15);
|
||||||
|
|
||||||
|
mLOG_DECLARE_CATEGORY(GBA_DMA);
|
||||||
|
|
||||||
struct GBADMA {
|
struct GBADMA {
|
||||||
GBADMARegister reg;
|
GBADMARegister reg;
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <mgba/internal/gba/gba.h>
|
#include <mgba/internal/gba/gba.h>
|
||||||
#include <mgba/internal/gba/io.h>
|
#include <mgba/internal/gba/io.h>
|
||||||
|
|
||||||
|
mLOG_DEFINE_CATEGORY(GBA_DMA, "GBA DMA", "gba.dma");
|
||||||
|
|
||||||
static void _dmaEvent(struct mTiming* timing, void* context, uint32_t cyclesLate);
|
static void _dmaEvent(struct mTiming* timing, void* context, uint32_t cyclesLate);
|
||||||
|
|
||||||
static void GBADMAService(struct GBA* gba, int number, struct GBADMA* info);
|
static void GBADMAService(struct GBA* gba, int number, struct GBADMA* info);
|
||||||
|
@ -43,10 +45,10 @@ static bool _isValidDMADAD(int dma, uint32_t address) {
|
||||||
|
|
||||||
uint32_t GBADMAWriteSAD(struct GBA* gba, int dma, uint32_t address) {
|
uint32_t GBADMAWriteSAD(struct GBA* gba, int dma, uint32_t address) {
|
||||||
struct GBAMemory* memory = &gba->memory;
|
struct GBAMemory* memory = &gba->memory;
|
||||||
address &= 0x0FFFFFFE;
|
|
||||||
if (_isValidDMASAD(dma, address)) {
|
if (_isValidDMASAD(dma, address)) {
|
||||||
memory->dma[dma].source = address;
|
memory->dma[dma].source = address & 0x0FFFFFFE;
|
||||||
} else {
|
} else {
|
||||||
|
mLOG(GBA_DMA, GAME_ERROR, "Invalid DMA source address: 0x%08X", address);
|
||||||
memory->dma[dma].source = 0;
|
memory->dma[dma].source = 0;
|
||||||
}
|
}
|
||||||
return memory->dma[dma].source;
|
return memory->dma[dma].source;
|
||||||
|
@ -57,6 +59,8 @@ uint32_t GBADMAWriteDAD(struct GBA* gba, int dma, uint32_t address) {
|
||||||
address &= 0x0FFFFFFE;
|
address &= 0x0FFFFFFE;
|
||||||
if (_isValidDMADAD(dma, address)) {
|
if (_isValidDMADAD(dma, address)) {
|
||||||
memory->dma[dma].dest = address;
|
memory->dma[dma].dest = address;
|
||||||
|
} else {
|
||||||
|
mLOG(GBA_DMA, GAME_ERROR, "Invalid DMA destination address: 0x%08X", address);
|
||||||
}
|
}
|
||||||
return memory->dma[dma].dest;
|
return memory->dma[dma].dest;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +82,7 @@ uint16_t GBADMAWriteCNT_HI(struct GBA* gba, int dma, uint16_t control) {
|
||||||
currentDma->reg = control;
|
currentDma->reg = control;
|
||||||
|
|
||||||
if (GBADMARegisterIsDRQ(currentDma->reg)) {
|
if (GBADMARegisterIsDRQ(currentDma->reg)) {
|
||||||
mLOG(GBA_MEM, STUB, "DRQ not implemented");
|
mLOG(GBA_DMA, STUB, "DRQ not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wasEnabled && GBADMARegisterIsEnable(currentDma->reg)) {
|
if (!wasEnabled && GBADMARegisterIsEnable(currentDma->reg)) {
|
||||||
|
@ -87,11 +91,15 @@ uint16_t GBADMAWriteCNT_HI(struct GBA* gba, int dma, uint16_t control) {
|
||||||
|
|
||||||
uint32_t width = 2 << GBADMARegisterGetWidth(currentDma->reg);
|
uint32_t width = 2 << GBADMARegisterGetWidth(currentDma->reg);
|
||||||
if (currentDma->nextSource & (width - 1)) {
|
if (currentDma->nextSource & (width - 1)) {
|
||||||
mLOG(GBA_MEM, GAME_ERROR, "Misaligned DMA source address: 0x%08X", currentDma->nextSource);
|
mLOG(GBA_DMA, GAME_ERROR, "Misaligned DMA source address: 0x%08X", currentDma->nextSource);
|
||||||
}
|
}
|
||||||
if (currentDma->nextDest & (width - 1)) {
|
if (currentDma->nextDest & (width - 1)) {
|
||||||
mLOG(GBA_MEM, GAME_ERROR, "Misaligned DMA destination address: 0x%08X", currentDma->nextDest);
|
mLOG(GBA_DMA, GAME_ERROR, "Misaligned DMA destination address: 0x%08X", currentDma->nextDest);
|
||||||
}
|
}
|
||||||
|
mLOG(GBA_DMA, INFO, "Starting DMA %i 0x%08X -> 0x%08X (%04X:%04X)", dma,
|
||||||
|
currentDma->nextSource, currentDma->nextDest,
|
||||||
|
currentDma->reg, currentDma->count & 0xFFFF);
|
||||||
|
|
||||||
currentDma->nextSource &= -width;
|
currentDma->nextSource &= -width;
|
||||||
currentDma->nextDest &= -width;
|
currentDma->nextDest &= -width;
|
||||||
|
|
||||||
|
@ -114,7 +122,7 @@ void GBADMASchedule(struct GBA* gba, int number, struct GBADMA* info) {
|
||||||
case GBA_DMA_TIMING_CUSTOM:
|
case GBA_DMA_TIMING_CUSTOM:
|
||||||
switch (number) {
|
switch (number) {
|
||||||
case 0:
|
case 0:
|
||||||
mLOG(GBA_MEM, WARN, "Discarding invalid DMA0 scheduling");
|
mLOG(GBA_DMA, WARN, "Discarding invalid DMA0 scheduling");
|
||||||
return;
|
return;
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
|
|
Loading…
Reference in New Issue