From 62ffeeb87842f12db2d511878996c94b69e33b59 Mon Sep 17 00:00:00 2001 From: Mittenshugg Date: Fri, 31 Jul 2020 21:09:50 -0500 Subject: [PATCH] c: osPiStartDma --- Makefile | 2 ++ include/PR/os_pi.h | 13 +++++++++++-- lib/src/osPiStartDma.c | 36 ++++++++++++++++++++++++++++++++++++ lib/src/unknown_0C9B80.c | 8 -------- 4 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 lib/src/osPiStartDma.c delete mode 100644 lib/src/unknown_0C9B80.c diff --git a/Makefile b/Makefile index aef03ee9..bf35d11b 100755 --- a/Makefile +++ b/Makefile @@ -179,6 +179,8 @@ $(BUILD_DIR)/lib/src/osSetTimer.o: OPT_FLAGS := -O1 $(BUILD_DIR)/lib/src/osTimer.o: OPT_FLAGS := -O1 $(BUILD_DIR)/lib/src/osViBlack.o: OPT_FLAGS := -O1 $(BUILD_DIR)/lib/src/osViSwapBuffer.o : OPT_FLAGS := -O1 +$(BUILD_DIR)/lib/src/osPiStartDma.o : OPT_FLAGS := -O1 + ######################## Targets ############################# diff --git a/include/PR/os_pi.h b/include/PR/os_pi.h index 9b5abd2b..e2e22644 100644 --- a/include/PR/os_pi.h +++ b/include/PR/os_pi.h @@ -60,11 +60,20 @@ typedef struct { /*0x08*/ void *dramAddr; /*0x0C*/ uintptr_t devAddr; /*0x10*/ size_t size; -#if defined(VERSION_EU) || defined(VERSION_SH) OSPiHandle *piHandle; // from the official definition -#endif } OSIoMesg; +typedef struct { + s32 active; /* Status flag */ + OSThread *thread; /* Calling thread */ + OSMesgQueue *cmdQueue; /* Command queue */ + OSMesgQueue *evtQueue; /* Event queue */ + OSMesgQueue *acsQueue; /* Access queue */ + /* Raw DMA routine */ + s32 (*dma)(s32, u32, void *, u32); + s32 (*edma)(OSPiHandle *, s32, u32, void *, u32); +} OSDevMgr; + /* Definitions */ #define OS_READ 0 // device -> RDRAM diff --git a/lib/src/osPiStartDma.c b/lib/src/osPiStartDma.c new file mode 100644 index 00000000..7a0b9186 --- /dev/null +++ b/lib/src/osPiStartDma.c @@ -0,0 +1,36 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x800C8F80 */ + +#include "types.h" +#include "macros.h" +#include "libultra_internal.h" + +//GLOBAL_ASM("lib/asm/non_matchings/unknown_0C9B80/osPiStartDma.s") + +extern OSDevMgr D_800E3740; //__osPiDevMgr; + +s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, u32 devAddr, void *dramAddr, u32 size, OSMesgQueue *mq) +{ + register s32 ret; + if (!D_800E3740.active) + return -1; + if (direction == OS_READ) + mb->hdr.type = 11; + else + mb->hdr.type = 12; + mb->hdr.pri = priority; + mb->hdr.retQueue = mq; + mb->dramAddr = dramAddr; + mb->devAddr = devAddr; + mb->size = size; + mb->piHandle = NULL; + if (priority == OS_MESG_PRI_HIGH) + { + ret = osJamMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK); + } + else + { + ret = osSendMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK); + } + return ret; +} \ No newline at end of file diff --git a/lib/src/unknown_0C9B80.c b/lib/src/unknown_0C9B80.c deleted file mode 100644 index 2ee2f3bf..00000000 --- a/lib/src/unknown_0C9B80.c +++ /dev/null @@ -1,8 +0,0 @@ -/* The comment below is needed for this file to be picked up by generate_ld */ -/* RAM_POS: 0x800C8F80 */ - -#include "types.h" -#include "macros.h" -#include "libultra_internal.h" - -GLOBAL_ASM("lib/asm/non_matchings/unknown_0C9B80/osPiStartDma.s")