summaryrefslogtreecommitdiff
path: root/src/libultra/io/epidma.c
blob: f2a073cb484400dd891693e2b84792aec8e8eed2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "ultra64.h"
#include "ultra64/internal.h"

s32 osEPiStartDma(OSPiHandle* handle, OSIoMesg* mb, s32 direction) {
    register s32 ret;

    if (!__osPiDevMgr.active) {
        return -1;
    }

    mb->piHandle = handle;
    if (direction == OS_READ) {
        mb->hdr.type = 0xF;
    } else {
        mb->hdr.type = 0x10;
    }

    if (mb->hdr.pri == 1) {
        ret = osJamMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK);
    } else {
        ret = osSendMesg(osPiGetCmdQueue(), (OSMesg)mb, OS_MESG_NOBLOCK);
    }

    return ret;
}