jak-project/game/system/vm/dmac.cpp
ManDude 8cc63ff35c
Add a debug PS2 VM to the runtime (#401)
* update VS launch target params

* remove redundant VS launch option

* Add a debug PS2 VM to the runtime, currently only for the DMAC

* Formatting

* remove broken assert

* Avoid weird buffer overflow bug

* Test on `VIF0_DMA_BANK`!

* Add a docstring

* patch pointers for the other dma channels

* patch DMAC pointer

* remove dead leftover code

* Change default return value for `get_vm_ptr`
2021-05-01 00:32:19 -04:00

30 lines
759 B
C++

/*!
* @file dmac.cpp
* DMAC implementation for the "PS2 virtual machine".
* Not meant to work as a full DMAC emulator, just enough to inspect DMA packets.
*/
#include "dmac.h"
#include "vm.h"
#include "game/runtime.h"
#include "game/kernel/kmalloc.h"
#include "common/log/log.h"
namespace VM {
Ptr<DmaCommonRegisters> dmac;
Ptr<DmaChannelRegisters> dmac_ch[10];
void dmac_init_globals() {
dmac = kmalloc(kdebugheap, sizeof(DmaCommonRegisters), KMALLOC_ALIGN_16 | KMALLOC_MEMSET, "dmac")
.cast<DmaCommonRegisters>();
for (int i = 0; i < 10; ++i) {
dmac_ch[i] =
kmalloc(kdebugheap, sizeof(DmaChannelRegisters), KMALLOC_ALIGN_16 | KMALLOC_MEMSET, "dmach")
.cast<DmaChannelRegisters>();
}
}
} // namespace VM