From 670e4127be3144b6d2bc57c1c882a0c1aa3137dd Mon Sep 17 00:00:00 2001 From: red031000 Date: Wed, 9 Sep 2020 17:02:58 +0100 Subject: arm9 MI_dma_card --- arm9/lib/include/MI_dma.h | 3 +++ arm9/lib/include/MI_dma_card.h | 8 ++++++++ arm9/lib/src/MI_dma_card.c | 24 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 arm9/lib/include/MI_dma_card.h create mode 100644 arm9/lib/src/MI_dma_card.c (limited to 'arm9/lib') diff --git a/arm9/lib/include/MI_dma.h b/arm9/lib/include/MI_dma.h index e8938ef9..bf07129a 100644 --- a/arm9/lib/include/MI_dma.h +++ b/arm9/lib/include/MI_dma.h @@ -16,6 +16,9 @@ typedef void (*MIDmaCallback)(void *); #define MI_CNT_COPY32_IF(size) (0xc4000000 | ((size)/4)) #define MI_CNT_COPY16(size) (0x80000000 | ((size)/2)) +#define MI_DMA_SRC_FIX (2UL << 23) +#define MIi_DMA_TIMING_ANY (u32)(~0) + typedef union { u32 b32; diff --git a/arm9/lib/include/MI_dma_card.h b/arm9/lib/include/MI_dma_card.h new file mode 100644 index 00000000..efd70ba6 --- /dev/null +++ b/arm9/lib/include/MI_dma_card.h @@ -0,0 +1,8 @@ +#ifndef POKEDIAMOND_MI_DMA_CARD_H +#define POKEDIAMOND_MI_DMA_CARD_H + +#include "nitro/types.h" + +void MIi_CardDmaCopy32(u32 dmaNo, const void *src, void *dest, u32 size); + +#endif //POKEDIAMOND_MI_DMA_CARD_H diff --git a/arm9/lib/src/MI_dma_card.c b/arm9/lib/src/MI_dma_card.c new file mode 100644 index 00000000..c3b8b897 --- /dev/null +++ b/arm9/lib/src/MI_dma_card.c @@ -0,0 +1,24 @@ +#include "MI_dma_card.h" +#include "MI_dma.h" +#include "function_target.h" + +ARM_FUNC void MIi_CardDmaCopy32(u32 dmaNo, const void *src, void *dest, u32 size) +{ + MIi_CheckAnotherAutoDMA(dmaNo, MIi_DMA_TIMING_ANY); + MIi_CheckDma0SourceAddress(dmaNo, (u32)src, size, MI_DMA_SRC_FIX); + + if (size == 0) + { + return; + } + + vu32 *dmaCntp; + + do + { + dmaCntp = &((vu32 *)REG_ADDR_DMA0SAD)[dmaNo * 3 + 2]; + while (*dmaCntp & 0x80000000) {} + } while(0); + + MIi_DmaSetParams(dmaNo, (u32)src, (u32)dest, (u32)(0xaf000001)); +} -- cgit v1.2.3