sm64pc/lib/src/osPiStartDma.c

38 lines
922 B
C
Raw Normal View History

2019-08-25 04:46:40 +00:00
#include "libultra_internal.h"
extern OSMgrArgs piMgrArgs;
2020-02-03 05:51:26 +00:00
s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr,
size_t nbytes, OSMesgQueue *mq) {
2019-08-25 04:46:40 +00:00
register s32 result;
register OSMesgQueue *cmdQueue;
2019-09-01 19:50:50 +00:00
if (!piMgrArgs.initialized) {
2019-08-25 04:46:40 +00:00
return -1;
2019-09-01 19:50:50 +00:00
}
2019-08-25 04:46:40 +00:00
// 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;
2020-02-03 05:51:26 +00:00
#ifdef VERSION_EU
mb->piHandle = NULL;
#endif
2019-08-25 04:46:40 +00:00
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;
}