wut  v1.7.0
Wii U Toolchain
alarm.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include "threadqueue.h"
4 #include "time.h"
5 #include "context.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 {
35  uint32_t tag;
36 
38  const char *name;
39  WUT_UNKNOWN_BYTES(4);
40 
44 };
45 WUT_CHECK_OFFSET(OSAlarmQueue, 0x00, tag);
46 WUT_CHECK_OFFSET(OSAlarmQueue, 0x04, name);
47 WUT_CHECK_OFFSET(OSAlarmQueue, 0x0c, threadQueue);
48 WUT_CHECK_OFFSET(OSAlarmQueue, 0x1c, head);
49 WUT_CHECK_OFFSET(OSAlarmQueue, 0x20, tail);
50 WUT_CHECK_SIZE(OSAlarmQueue, 0x24);
51 
53 {
56 };
57 WUT_CHECK_OFFSET(OSAlarmLink, 0x00, prev);
58 WUT_CHECK_OFFSET(OSAlarmLink, 0x04, next);
59 WUT_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  WUT_UNKNOWN_BYTES(4);
71 
74 
76  uint32_t group;
77 
78  WUT_UNKNOWN_BYTES(4);
79 
82 
85 
88 
91 
93  void *userData;
94 
96  uint32_t state;
97 
100 
103 
106 };
107 WUT_CHECK_OFFSET(OSAlarm, 0x00, tag);
108 WUT_CHECK_OFFSET(OSAlarm, 0x04, name);
109 WUT_CHECK_OFFSET(OSAlarm, 0x0c, callback);
110 WUT_CHECK_OFFSET(OSAlarm, 0x10, group);
111 WUT_CHECK_OFFSET(OSAlarm, 0x18, nextFire);
112 WUT_CHECK_OFFSET(OSAlarm, 0x20, link);
113 WUT_CHECK_OFFSET(OSAlarm, 0x28, period);
114 WUT_CHECK_OFFSET(OSAlarm, 0x30, start);
115 WUT_CHECK_OFFSET(OSAlarm, 0x38, userData);
116 WUT_CHECK_OFFSET(OSAlarm, 0x3c, state);
117 WUT_CHECK_OFFSET(OSAlarm, 0x40, threadQueue);
118 WUT_CHECK_OFFSET(OSAlarm, 0x50, alarmQueue);
119 WUT_CHECK_OFFSET(OSAlarm, 0x54, context);
120 WUT_CHECK_SIZE(OSAlarm, 0x58);
121 
122 
126 BOOL
128 
129 
135 void
136 OSCancelAlarms(uint32_t group);
137 
138 
142 void
144 
145 
149 void
151  const char *name);
152 
153 
157 void *
159 
160 
164 void
166 
167 
171 void
173  const char *name);
174 
175 
183 BOOL
185  OSTime time,
186  OSAlarmCallback callback);
187 
188 
197 BOOL
199  OSTime start,
200  OSTime interval,
201  OSAlarmCallback callback);
202 
203 
207 void
209  uint32_t group);
210 
211 
215 void
217  void *data);
218 
219 
223 BOOL
225 
226 #ifdef __cplusplus
227 }
228 #endif
229 
uint32_t group
Used with OSCancelAlarms for bulk cancellation of alarms.
Definition: alarm.h:76
OSTime nextFire
The time when the alarm will next be triggered.
Definition: alarm.h:78
uint32_t state
The current state of the alarm, internal values.
Definition: alarm.h:96
uint32_t tag
Should always be set to the value OS_ALARM_QUEUE_TAG.
Definition: alarm.h:35
OSTime start
The time the alarm was started.
Definition: alarm.h:90
OSAlarm * tail
Definition: alarm.h:43
void * userData
User data set with OSSetAlarmUserData and retrieved with OSGetAlarmUserData.
Definition: alarm.h:93
OSAlarmLink link
Link used for when this OSAlarm object is inside an OSAlarmQueue.
Definition: alarm.h:84
OSAlarm * next
Definition: alarm.h:55
OSThreadQueue threadQueue
Definition: alarm.h:39
OSTime period
The period between alarm triggers, this is only set for periodic alarms.
Definition: alarm.h:87
OSContext * context
The context the alarm was triggered on.
Definition: alarm.h:105
OSAlarmCallback callback
The callback to execute once the alarm is triggered.
Definition: alarm.h:70
OSAlarm * head
Definition: alarm.h:42
OSAlarm * prev
Definition: alarm.h:54
const char * name
Name set by OSInitAlarmQueueEx.
Definition: alarm.h:38
OSAlarmQueue * alarmQueue
The queue that this alarm is currently in.
Definition: alarm.h:102
BOOL OSSetPeriodicAlarm(OSAlarm *alarm, OSTime start, OSTime interval, OSAlarmCallback callback)
Set a repeated alarm to execute a callback every interval from start.
void OSInitAlarmQueueEx(OSAlarmQueue *queue, const char *name)
Initialise an alarm queue structure with a name.
void OSCreateAlarmEx(OSAlarm *alarm, const char *name)
Initialise an alarm structure with a name.
void OSSetAlarmTag(OSAlarm *alarm, uint32_t group)
Set an alarm tag which is used in OSCancelAlarms for bulk cancellation.
BOOL OSSetAlarm(OSAlarm *alarm, OSTime time, OSAlarmCallback callback)
Set a one shot alarm to perform a callback after a set amount of time.
void OSCancelAlarms(uint32_t group)
Cancel all alarms which have a matching tag set by OSSetAlarmTag.
void OSCreateAlarm(OSAlarm *alarm)
Initialise an alarm structure.
void * OSGetAlarmUserData(OSAlarm *alarm)
Return user data set by OSSetAlarmUserData.
void OSSetAlarmUserData(OSAlarm *alarm, void *data)
Set alarm user data which is returned by OSGetAlarmUserData.
void OSInitAlarmQueue(OSAlarmQueue *queue)
Initialise an alarm queue structure.
BOOL OSWaitAlarm(OSAlarm *alarm)
Sleep the current thread until the alarm has been triggered or cancelled.
void(* OSAlarmCallback)(OSAlarm *, OSContext *)
Definition: alarm.h:28
BOOL OSCancelAlarm(OSAlarm *alarm)
Cancel an alarm.
Definition: alarm.h:63
int64_t OSTime
Definition: time.h:18
int32_t BOOL
Definition: wut_types.h:7