WUT  0.1
Wii U Toolchain
taskqueue.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include "time.h"
4 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 typedef struct MPTask MPTask;
16 typedef struct MPTaskInfo MPTaskInfo;
17 typedef struct MPTaskQueue MPTaskQueue;
19 
20 typedef uint32_t MPTaskState;
21 
22 typedef uint32_t (*MPTaskFunc)(uint32_t, uint32_t);
23 
24 enum MPTaskState
25 {
30 };
31 
32 struct MPTaskInfo
33 {
34  MPTaskState state;
35  uint32_t result;
36  uint32_t coreID;
38 };
39 CHECK_OFFSET(MPTaskInfo, 0x00, state);
40 CHECK_OFFSET(MPTaskInfo, 0x04, result);
41 CHECK_OFFSET(MPTaskInfo, 0x08, coreID);
42 CHECK_OFFSET(MPTaskInfo, 0x0C, duration);
43 CHECK_SIZE(MPTaskInfo, 0x14);
44 
45 struct MPTask
46 {
47  MPTask *self;
49  MPTaskState state;
51  uint32_t userArg1;
52  uint32_t userArg2;
53  uint32_t result;
54  uint32_t coreID;
56  void *userData;
57 };
58 CHECK_OFFSET(MPTask, 0x00, self);
59 CHECK_OFFSET(MPTask, 0x04, queue);
60 CHECK_OFFSET(MPTask, 0x08, state);
61 CHECK_OFFSET(MPTask, 0x0C, func);
62 CHECK_OFFSET(MPTask, 0x10, userArg1);
63 CHECK_OFFSET(MPTask, 0x14, userArg2);
64 CHECK_OFFSET(MPTask, 0x18, result);
65 CHECK_OFFSET(MPTask, 0x1C, coreID);
66 CHECK_OFFSET(MPTask, 0x20, duration);
67 CHECK_OFFSET(MPTask, 0x28, userData);
68 CHECK_SIZE(MPTask, 0x2C);
69 
71 {
72  MPTaskQueueState state;
73  uint32_t tasks;
74  uint32_t tasksReady;
75  uint32_t tasksRunning;
76  uint32_t tasksFinished;
77 };
78 CHECK_OFFSET(MPTaskQueueInfo, 0x00, state);
79 CHECK_OFFSET(MPTaskQueueInfo, 0x04, tasks);
80 CHECK_OFFSET(MPTaskQueueInfo, 0x08, tasksReady);
81 CHECK_OFFSET(MPTaskQueueInfo, 0x0C, tasksRunning);
82 CHECK_OFFSET(MPTaskQueueInfo, 0x10, tasksFinished);
83 CHECK_SIZE(MPTaskQueueInfo, 0x14);
84 
86 {
87  MPTaskQueue *self;
88  MPTaskQueueState state;
89  uint32_t tasks;
90  uint32_t tasksReady;
91  uint32_t tasksRunning;
92  UNKNOWN(4);
93  uint32_t tasksFinished;
94  UNKNOWN(8);
95  uint32_t queueIndex;
96  UNKNOWN(8);
97  uint32_t queueSize;
98  UNKNOWN(4);
100  uint32_t queueMaxSize;
102 };
103 CHECK_OFFSET(MPTaskQueue, 0x00, self);
104 CHECK_OFFSET(MPTaskQueue, 0x04, state);
105 CHECK_OFFSET(MPTaskQueue, 0x08, tasks);
106 CHECK_OFFSET(MPTaskQueue, 0x0C, tasksReady);
107 CHECK_OFFSET(MPTaskQueue, 0x10, tasksRunning);
108 CHECK_OFFSET(MPTaskQueue, 0x18, tasksFinished);
109 CHECK_OFFSET(MPTaskQueue, 0x24, queueIndex);
110 CHECK_OFFSET(MPTaskQueue, 0x30, queueSize);
111 CHECK_OFFSET(MPTaskQueue, 0x38, queue);
112 CHECK_OFFSET(MPTaskQueue, 0x3C, queueMaxSize);
113 CHECK_OFFSET(MPTaskQueue, 0x40, lock);
114 CHECK_SIZE(MPTaskQueue, 0x50);
115 
116 void
117 MPInitTaskQ(MPTaskQueue *queue,
118  MPTask **queueBuffer,
119  uint32_t queueBufferLen);
120 
121 BOOL
122 MPTermTaskQ(MPTaskQueue *queue);
123 
124 BOOL
126  MPTaskQueueInfo *info);
127 
128 BOOL
129 MPStartTaskQ(MPTaskQueue *queue);
130 
131 BOOL
132 MPStopTaskQ(MPTaskQueue *queue);
133 
134 BOOL
135 MPResetTaskQ(MPTaskQueue *queue);
136 
137 BOOL
138 MPEnqueTask(MPTaskQueue *queue,
139  MPTask *task);
140 
141 MPTask *
142 MPDequeTask(MPTaskQueue *queue);
143 
144 uint32_t
146  MPTask **queueBuffer,
147  uint32_t queueBufferLen);
148 
149 BOOL
150 MPWaitTaskQ(MPTaskQueue *queue,
151  MPTaskQueueState mask);
152 
153 BOOL
155  MPTaskQueueState wmask,
156  OSTime timeout);
157 
158 BOOL
160  uint32_t unk);
161 
162 void
163 MPInitTask(MPTask *task,
164  MPTaskFunc func,
165  uint32_t userArg1,
166  uint32_t userArg2);
167 
168 BOOL
169 MPTermTask(MPTask* task);
170 
171 BOOL
172 MPGetTaskInfo(MPTask *task,
173  MPTaskInfo *info);
174 
175 void *
177 
178 void
180  void *userData);
181 
182 BOOL
184  uint32_t count);
185 
186 BOOL
187 MPRunTask(MPTask *task);
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 
MPTaskState
Definition: taskqueue.h:24
BOOL MPEnqueTask(MPTaskQueue *queue, MPTask *task)
uint32_t tasksFinished
Definition: taskqueue.h:76
void MPInitTaskQ(MPTaskQueue *queue, MPTask **queueBuffer, uint32_t queueBufferLen)
uint32_t MPDequeTasks(MPTaskQueue *queue, MPTask **queueBuffer, uint32_t queueBufferLen)
BOOL MPStartTaskQ(MPTaskQueue *queue)
MPTask * MPDequeTask(MPTaskQueue *queue)
uint32_t tasks
Definition: taskqueue.h:89
void * MPGetTaskUserData(MPTask *task)
int64_t OSTime
Definition: time.h:17
MPTaskQueueState state
Definition: taskqueue.h:72
uint32_t tasksRunning
Definition: taskqueue.h:91
uint32_t tasksFinished
Definition: taskqueue.h:93
BOOL MPWaitTaskQ(MPTaskQueue *queue, MPTaskQueueState mask)
uint32_t tasksRunning
Definition: taskqueue.h:75
BOOL MPTermTask(MPTask *task)
BOOL MPRunTask(MPTask *task)
BOOL MPPrintTaskQStats(MPTaskQueue *queue, uint32_t unk)
uint32_t queueMaxSize
Definition: taskqueue.h:100
void * userData
Definition: taskqueue.h:56
BOOL MPResetTaskQ(MPTaskQueue *queue)
BOOL MPGetTaskQInfo(MPTaskQueue *queue, MPTaskQueueInfo *info)
BOOL MPStopTaskQ(MPTaskQueue *queue)
uint32_t tasksReady
Definition: taskqueue.h:90
BOOL MPRunTasksFromTaskQ(MPTaskQueue *queue, uint32_t count)
uint32_t coreID
Definition: taskqueue.h:36
BOOL MPGetTaskInfo(MPTask *task, MPTaskInfo *info)
OSSpinLock lock
Definition: taskqueue.h:101
uint32_t result
Definition: taskqueue.h:35
uint32_t userArg2
Definition: taskqueue.h:52
BOOL MPTermTaskQ(MPTaskQueue *queue)
MPTaskFunc func
Definition: taskqueue.h:50
uint32_t queueSize
Definition: taskqueue.h:97
uint32_t tasksReady
Definition: taskqueue.h:74
uint32_t result
Definition: taskqueue.h:53
MPTaskState state
Definition: taskqueue.h:34
OSTime duration
Definition: taskqueue.h:55
int BOOL
Definition: wut_types.h:4
void MPSetTaskUserData(MPTask *task, void *userData)
uint32_t tasks
Definition: taskqueue.h:73
uint32_t queueIndex
Definition: taskqueue.h:95
MPTaskState state
Definition: taskqueue.h:49
MPTaskQueueState state
Definition: taskqueue.h:88
uint32_t coreID
Definition: taskqueue.h:54
void MPInitTask(MPTask *task, MPTaskFunc func, uint32_t userArg1, uint32_t userArg2)
MPTask ** queue
Definition: taskqueue.h:99
uint32_t(* MPTaskFunc)(uint32_t, uint32_t)
Definition: taskqueue.h:22
BOOL MPWaitTaskQWithTimeout(MPTaskQueue *queue, MPTaskQueueState wmask, OSTime timeout)
MPTaskQueue * queue
Definition: taskqueue.h:48
OSTime duration
Definition: taskqueue.h:37
uint32_t userArg1
Definition: taskqueue.h:51