WUT  0.1
Wii U Toolchain
alarm.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include "thread.h"
4 #include "threadqueue.h"
5 #include "time.h"
6 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 typedef struct OSAlarm OSAlarm;
25 typedef struct OSAlarmLink OSAlarmLink;
26 typedef struct OSAlarmQueue OSAlarmQueue;
27 
28 typedef void (*OSAlarmCallback)(OSAlarm *, OSContext *);
29 
30 #define OS_ALARM_QUEUE_TAG 0x614C6D51u
31 
33 {
34  // OS_ALARM_QUEUE_TAG
35  uint32_t tag;
36 
37  // Name set by OSInitAlarmQueueEx
38  const char *name;
39  UNKNOWN(4);
40 
42  OSAlarm *head;
43  OSAlarm *tail;
44 };
45 CHECK_OFFSET(OSAlarmQueue, 0x00, tag);
46 CHECK_OFFSET(OSAlarmQueue, 0x04, name);
47 CHECK_OFFSET(OSAlarmQueue, 0x0c, threadQueue);
48 CHECK_OFFSET(OSAlarmQueue, 0x1c, head);
49 CHECK_OFFSET(OSAlarmQueue, 0x20, tail);
50 CHECK_SIZE(OSAlarmQueue, 0x24);
51 
53 {
54  OSAlarm *prev;
55  OSAlarm *next;
56 };
57 CHECK_OFFSET(OSAlarmLink, 0x00, prev);
58 CHECK_OFFSET(OSAlarmLink, 0x04, next);
59 CHECK_SIZE(OSAlarmLink, 0x08);
60 
61 #define OS_ALARM_TAG 0x614C724Du
62 struct OSAlarm
63 {
65  uint32_t tag;
66 
68  const char *name;
69 
70  UNKNOWN(4);
71 
74 
76  uint32_t group;
77 
78  UNKNOWN(4);
79 
82 
85 
88 
91 
93  void *userData;
94 
96  uint32_t state;
97 
100 
103 
106 };
107 CHECK_OFFSET(OSAlarm, 0x00, tag);
108 CHECK_OFFSET(OSAlarm, 0x04, name);
109 CHECK_OFFSET(OSAlarm, 0x0c, callback);
110 CHECK_OFFSET(OSAlarm, 0x10, group);
111 CHECK_OFFSET(OSAlarm, 0x18, nextFire);
112 CHECK_OFFSET(OSAlarm, 0x20, link);
113 CHECK_OFFSET(OSAlarm, 0x28, period);
114 CHECK_OFFSET(OSAlarm, 0x30, start);
115 CHECK_OFFSET(OSAlarm, 0x38, userData);
116 CHECK_OFFSET(OSAlarm, 0x3c, state);
117 CHECK_OFFSET(OSAlarm, 0x40, threadQueue);
118 CHECK_OFFSET(OSAlarm, 0x50, alarmQueue);
119 CHECK_OFFSET(OSAlarm, 0x54, context);
120 CHECK_SIZE(OSAlarm, 0x58);
121 
122 
126 BOOL
127 OSCancelAlarm(OSAlarm *alarm);
128 
129 
135 void
136 OSCancelAlarms(uint32_t group);
137 
138 
142 void
143 OSCreateAlarm(OSAlarm *alarm);
144 
145 
149 void
150 OSCreateAlarmEx(OSAlarm *alarm,
151  const char *name);
152 
153 
157 void *
158 OSGetAlarmUserData(OSAlarm *alarm);
159 
160 
164 void
166 
167 
171 void
173  const char *name);
174 
175 
183 BOOL
184 OSSetAlarm(OSAlarm *alarm,
185  OSTime time,
186  OSAlarmCallback callback);
187 
188 
197 BOOL
198 OSSetPeriodicAlarm(OSAlarm *alarm,
199  OSTime start,
200  OSTime interval,
201  OSAlarmCallback callback);
202 
203 
207 void
208 OSSetAlarmTag(OSAlarm *alarm,
209  uint32_t group);
210 
211 
215 void
216 OSSetAlarmUserData(OSAlarm *alarm,
217  void *data);
218 
219 
223 BOOL
224 OSWaitAlarm(OSAlarm *alarm);
225 
226 #ifdef __cplusplus
227 }
228 #endif
229 
uint32_t tag
Definition: alarm.h:35
OSAlarmQueue * alarmQueue
The queue that this alarm is currently in.
Definition: alarm.h:102
void(* OSAlarmCallback)(OSAlarm *, OSContext *)
Definition: alarm.h:28
const char * name
Definition: alarm.h:38
Definition: alarm.h:62
const char * name
Name set from OSCreateAlarmEx.
Definition: alarm.h:68
int64_t OSTime
Definition: time.h:17
BOOL OSSetAlarm(OSAlarm *alarm, OSTime time, OSAlarmCallback callback)
uint32_t group
Used with OSCancelAlarms for bulk cancellation of alarms.
Definition: alarm.h:76
OSAlarm * tail
Definition: alarm.h:43
OSThreadQueue threadQueue
Definition: alarm.h:41
BOOL OSCancelAlarm(OSAlarm *alarm)
void OSCreateAlarmEx(OSAlarm *alarm, const char *name)
OSTime nextFire
The time when the alarm will next be triggered.
Definition: alarm.h:81
OSAlarm * head
Definition: alarm.h:42
void OSInitAlarmQueueEx(OSAlarmQueue *queue, const char *name)
OSTime period
The period between alarm triggers, this is only set for periodic alarms.
Definition: alarm.h:87
void * OSGetAlarmUserData(OSAlarm *alarm)
OSAlarmLink link
Link used for when this OSAlarm object is inside an OSAlarmQueue.
Definition: alarm.h:84
uint32_t tag
Should always be set to the value OS_ALARM_TAG.
Definition: alarm.h:65
BOOL OSWaitAlarm(OSAlarm *alarm)
void * userData
User data set with OSSetAlarmUserData and retrieved with OSGetAlarmUserData.
Definition: alarm.h:93
int BOOL
Definition: wut_types.h:4
void OSSetAlarmUserData(OSAlarm *alarm, void *data)
void OSInitAlarmQueue(OSAlarmQueue *queue)
OSContext * context
The context the alarm was triggered on.
Definition: alarm.h:105
uint32_t state
The current state of the alarm, internal values.
Definition: alarm.h:96
BOOL OSSetPeriodicAlarm(OSAlarm *alarm, OSTime start, OSTime interval, OSAlarmCallback callback)
OSTime start
The time the alarm was started.
Definition: alarm.h:90
void OSCreateAlarm(OSAlarm *alarm)
OSAlarmCallback callback
The callback to execute once the alarm is triggered.
Definition: alarm.h:73
OSThreadQueue threadQueue
Queue of threads currently waiting for the alarm to trigger with OSWaitAlarm.
Definition: alarm.h:99
void OSSetAlarmTag(OSAlarm *alarm, uint32_t group)
void OSCancelAlarms(uint32_t group)