osPiStartDma.c (962B)
1 #include "libultra_internal.h" 2 #include "piint.h" 3 4 s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr, 5 size_t nbytes, OSMesgQueue *mq) { 6 register s32 result; 7 register OSMesgQueue *cmdQueue; 8 if (!__osPiDevMgr.active) { 9 return -1; 10 } 11 12 // TODO: name magic constants 13 if (direction == OS_READ) { 14 mb->hdr.type = 11; 15 } else { 16 mb->hdr.type = 12; 17 } 18 19 mb->hdr.pri = priority; 20 mb->hdr.retQueue = mq; 21 mb->dramAddr = vAddr; 22 mb->devAddr = devAddr; 23 mb->size = nbytes; 24 #if defined(VERSION_EU) || defined(VERSION_SH) || defined(VERSION_CN) 25 mb->piHandle = NULL; 26 #endif 27 28 if (priority == OS_MESG_PRI_HIGH) { 29 cmdQueue = osPiGetCmdQueue(); 30 result = osJamMesg(cmdQueue, mb, OS_MESG_NOBLOCK); 31 } else { 32 cmdQueue = osPiGetCmdQueue(); 33 result = osSendMesg(cmdQueue, mb, OS_MESG_NOBLOCK); 34 } 35 return result; 36 }