From 948f59dde0f8a3d6e7fc6fa2d60939c4dc785303 Mon Sep 17 00:00:00 2001 From: Jaby Date: Sat, 9 Mar 2024 23:37:07 -0600 Subject: [PATCH] Set DMA in defined state --- include/PSX/System/IOPorts/dma_io.hpp | 4 ++++ src/Library/src/BootLoader/dma_boot.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/PSX/System/IOPorts/dma_io.hpp b/include/PSX/System/IOPorts/dma_io.hpp index 4f165905..8d41f267 100644 --- a/include/PSX/System/IOPorts/dma_io.hpp +++ b/include/PSX/System/IOPorts/dma_io.hpp @@ -161,6 +161,10 @@ namespace JabyEngine { static constexpr auto MasterEnableDPCR = Bit(23); static constexpr auto EnableDPCR = BitRange::from_to(16, 22); static constexpr auto ForceIRQ = Bit(15); + + static constexpr DICR empty() { + return DICR{0}; + } }; __declare_value_at(, Registers, MDECin, 0x1F801080); diff --git a/src/Library/src/BootLoader/dma_boot.cpp b/src/Library/src/BootLoader/dma_boot.cpp index b12fed47..79e9419a 100644 --- a/src/Library/src/BootLoader/dma_boot.cpp +++ b/src/Library/src/BootLoader/dma_boot.cpp @@ -1,12 +1,24 @@ #include +#include +#include +#include namespace JabyEngine { namespace boot { namespace DMA { + // TODO: Do we want all of this? So far it didn't help void setup() { static constexpr auto EnableDMA = DMA_IO::DPCR::from(DMA_IO::DPCR::SPU.turn_on(3), DMA_IO::DPCR::GPU.turn_on(3), DMA_IO::DPCR::CDROM.turn_on(3)); DMA_IO::DPCR.write(EnableDMA); + DMA_IO::DICR.write(DMA_IO::DICR::empty()); + + DMA_IO::DICR.write(DMA_IO::DICR.read()); + + SysCall::EnterCriticalSection(); + Interrupt::disable_irq(Interrupt::DMA); + Interrupt::ack_irq(Interrupt::DMA); + SysCall::ExitCriticalSection(); } } }