sm64/lib/src/osPiStartDma.c
2023-08-17 08:56:02 -04:00

37 lines
962 B
C

#include "libultra_internal.h"
#include "piint.h"
s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr,
size_t nbytes, OSMesgQueue *mq) {
register s32 result;
register OSMesgQueue *cmdQueue;
if (!__osPiDevMgr.active) {
return -1;
}
// TODO: name magic constants
if (direction == OS_READ) {
mb->hdr.type = 11;
} else {
mb->hdr.type = 12;
}
mb->hdr.pri = priority;
mb->hdr.retQueue = mq;
mb->dramAddr = vAddr;
mb->devAddr = devAddr;
mb->size = nbytes;
#if defined(VERSION_EU) || defined(VERSION_SH) || defined(VERSION_CN)
mb->piHandle = NULL;
#endif
if (priority == OS_MESG_PRI_HIGH) {
cmdQueue = osPiGetCmdQueue();
result = osJamMesg(cmdQueue, mb, OS_MESG_NOBLOCK);
} else {
cmdQueue = osPiGetCmdQueue();
result = osSendMesg(cmdQueue, mb, OS_MESG_NOBLOCK);
}
return result;
}