summaryrefslogtreecommitdiff
path: root/include/dolphin/os/OSAlarm.h
blob: 9bdb4f2f10ce8190ef7ee0a6fbc5ff920dd9ddc2 (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
40
41
42
43
44
45
46
#ifndef OSALARM_H
#define OSALARM_H

#include "dolphin/os/OSError.h"
#include "dolphin/os/OSTime.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct OSAlarmLink {
    /* 0x0 */ struct OSAlarm* prev;
    /* 0x4 */ struct OSAlarm* next;
} OSAlarmLink;

typedef struct OSAlarm OSAlarm;
typedef void (*OSAlarmHandler)(struct OSAlarm* alarm, OSContext* context);

typedef struct OSAlarm {
    /* 0x00 */ OSAlarmHandler handler;
    /* 0x04 */ u32 tag;
    /* 0x08 */ OSTime fire_time;
    /* 0x10 */ OSAlarmLink link;
    /* 0x18 */ OSTime period_time;
    /* 0x20 */ OSTime start_time;
} OSAlarm;  // Size: 0x28

typedef struct OSAlarmQueue {
    OSAlarm* head;
    OSAlarm* tail;
} OSAlarmQueue;

void OSInitAlarm(void);
void OSCreateAlarm(OSAlarm* alarm);
static void InsertAlarm(OSAlarm* alarm, s64 time, OSAlarmHandler handler);
void OSSetAlarm(OSAlarm* alarm, s64 time, OSAlarmHandler handler);
void OSSetPeriodicAlarm(OSAlarm* alarm, s64 start, s64 period, OSAlarmHandler handler);
void OSCancelAlarm(OSAlarm* alarm);
static void DecrementerExceptionCallback(__OSException exception, OSContext* context);
static void DecrementerExceptionHandler(__OSException exception, OSContext* context);

#ifdef __cplusplus
};
#endif

#endif /* OSALARM_H */