aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxetc
diff options
context:
space:
mode:
authorspicyjpeg <thatspicyjpeg@gmail.com>2022-12-28 12:18:29 +0100
committerspicyjpeg <thatspicyjpeg@gmail.com>2022-12-28 12:18:29 +0100
commit7e350980d5c09bbc81a0de01bf016a87ecfc4feb (patch)
tree26b403d12eea34a4644b3d147f00e1d1455e7f52 /libpsn00b/psxetc
parenteaec942f56ceec9c14de5c4185a02602abadd50a (diff)
downloadpsn00bsdk-7e350980d5c09bbc81a0de01bf016a87ecfc4feb.tar.gz
Add CdUnlock() and DMA priority API
Diffstat (limited to 'libpsn00b/psxetc')
-rw-r--r--libpsn00b/psxetc/interrupts.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libpsn00b/psxetc/interrupts.c b/libpsn00b/psxetc/interrupts.c
index f2a273c..7c8b206 100644
--- a/libpsn00b/psxetc/interrupts.c
+++ b/libpsn00b/psxetc/interrupts.c
@@ -157,6 +157,31 @@ void *GetDMACallback(DMA_Channel dma) {
return _dma_handlers[dma];
}
+/* DMA channel priority API */
+
+int SetDMAPriority(DMA_Channel dma, int priority) {
+ if ((dma < 0) || (dma >= NUM_DMA_CHANNELS))
+ return -1;
+
+ uint32_t dpcr = DMA_DPCR;
+ uint32_t channel = dpcr >> (dma * 4);
+
+ dpcr &= ~(0xf << (dma * 4));
+ if (priority >= 0)
+ dpcr |= ((priority & 7) | 8) << (dma * 4);
+
+ DMA_DPCR = dpcr;
+ return (channel & 8) ? (channel & 7) : -1;
+}
+
+int GetDMAPriority(DMA_Channel dma) {
+ if ((dma < 0) || (dma >= NUM_DMA_CHANNELS))
+ return -1;
+
+ uint32_t channel = DMA_DPCR >> (dma * 4);
+ return (channel & 8) ? (channel & 7) : -1;
+}
+
/* Hook installation/removal API */
int ResetCallback(void) {