summaryrefslogtreecommitdiff
path: root/lib/ultralib/src/os/seteventmesg.c
blob: aa5f6690ab18cf606aa64e1e547b5aca0f8b0dcb (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
28
29
30
31
32
33
34
35
36
37
38
39
#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PRinternal/osint.h"

__OSEventState __osEventStateTab[OS_NUM_EVENTS] ALIGNED(0x8);
#if BUILD_VERSION >= VERSION_J
u32 __osPreNMI = FALSE;
#endif

void osSetEventMesg(OSEvent event, OSMesgQueue* mq, OSMesg msg) {
    register u32 saveMask;
    __OSEventState* es;

#ifdef _DEBUG
    if (event >= OS_NUM_EVENTS) {
        __osError(ERR_OSSETEVENTMESG, 1, event);
        return;
    }
#endif

    saveMask = __osDisableInt();

    es = &__osEventStateTab[event];

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

#if BUILD_VERSION >= VERSION_J
    if (event == OS_EVENT_PRENMI) {
        if (__osShutdown && !__osPreNMI) {
            osSendMesg(mq, msg, OS_MESG_NOBLOCK);
        }
        __osPreNMI = TRUE;
    }
#endif

    __osRestoreInt(saveMask);
}