summaryrefslogtreecommitdiff
path: root/src/libultra/os/seteventmesg.c
blob: 2ca53b6ec2b10ddcb5e0f3639c6cfef2bd7abeb9 (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
26
27
#include "ultra64.h"
#include "PR/osint.h"
#include "stdbool.h"
#include "alignment.h"

u32 __osPreNMI = false;

__OSEventState __osEventStateTab[OS_NUM_EVENTS] ALIGNED(8);

void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg m) {
    register u32 saveMask = __osDisableInt();
    __OSEventState* es;

    es = &__osEventStateTab[e];

    es->messageQueue = mq;
    es->message = m;

    if (e == OS_EVENT_PRENMI) {
        if (__osShutdown && !__osPreNMI) {
            osSendMesg(mq, m, OS_MESG_NOBLOCK);
        }
        __osPreNMI = true;
    }

    __osRestoreInt(saveMask);
}