wut  v1.5.0
Wii U Toolchain
smd.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include <coreinit/mutex.h>
4 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 typedef struct SmdVectorSpec SmdVectorSpec;
18 typedef struct SmdVector SmdVector;
19 typedef struct SmdElement SmdElement;
20 typedef struct SmdReceiveData SmdReceiveData;
21 typedef struct SmdInterface SmdInterface;
22 typedef struct SmdCtrlTable SmdCtrlTable;
24 typedef struct SmdPpc SmdPpc;
25 typedef struct SmdSimpleBufPool SmdSimpleBufPool;
26 
27 typedef enum SmdLockType
28 {
36 
37 typedef enum SmdPpcState
38 {
44 
45 typedef enum SmdInterfaceState
46 {
50 
51 typedef enum SmdElementType
52 {
57 
59 {
60  void *ptr;
61  uint32_t size;
62 };
63 WUT_CHECK_OFFSET(SmdVectorSpec, 0x00, ptr);
64 WUT_CHECK_OFFSET(SmdVectorSpec, 0x04, size);
65 WUT_CHECK_SIZE(SmdVectorSpec, 0x8);
66 
67 struct SmdVector
68 {
69  uint32_t command;
70  int32_t count;
72 };
73 WUT_CHECK_OFFSET(SmdVector, 0x00, command);
74 WUT_CHECK_OFFSET(SmdVector, 0x04, count);
75 WUT_CHECK_OFFSET(SmdVector, 0x08, vecs);
76 WUT_CHECK_SIZE(SmdVector, 0x28);
77 
78 struct SmdElement
79 {
81  uint32_t size;
82  union {
83  uint8_t data[0xf8];
84  SmdVector spec;
85  uint32_t vectorPaddr;
86  };
87 };
88 WUT_CHECK_OFFSET(SmdElement, 0x00, type);
89 WUT_CHECK_OFFSET(SmdElement, 0x04, size);
90 WUT_CHECK_OFFSET(SmdElement, 0x08, data);
91 WUT_CHECK_OFFSET(SmdElement, 0x08, spec);
92 WUT_CHECK_OFFSET(SmdElement, 0x08, vectorPaddr);
93 WUT_CHECK_SIZE(SmdElement, 0x100);
94 
96 {
98  uint32_t size;
99  union {
100  uint8_t message[0x80];
101  SmdVector spec;
102  SmdVector *vector;
103  };
104 };
105 WUT_CHECK_OFFSET(SmdReceiveData, 0x00, type);
106 WUT_CHECK_OFFSET(SmdReceiveData, 0x04, size);
107 WUT_CHECK_OFFSET(SmdReceiveData, 0x08, message);
108 WUT_CHECK_OFFSET(SmdReceiveData, 0x08, spec);
109 WUT_CHECK_OFFSET(SmdReceiveData, 0x08, vector);
110 WUT_CHECK_SIZE(SmdReceiveData, 0x88);
111 
113 {
115  WUT_PADDING_BYTES(0x7C);
116  uint32_t elementCount;
117  WUT_PADDING_BYTES(0x7C);
118  int32_t readOffset;
119  WUT_PADDING_BYTES(0x7C);
120  int32_t writeOffset;
121  WUT_PADDING_BYTES(0x7C);
122  uint32_t bufPaddr;
123  WUT_PADDING_BYTES(0x7C);
124 };
125 WUT_CHECK_OFFSET(SmdInterface, 0x000, state);
126 WUT_CHECK_OFFSET(SmdInterface, 0x080, elementCount);
127 WUT_CHECK_OFFSET(SmdInterface, 0x100, readOffset);
128 WUT_CHECK_OFFSET(SmdInterface, 0x180, writeOffset);
129 WUT_CHECK_OFFSET(SmdInterface, 0x200, bufPaddr);
130 WUT_CHECK_SIZE(SmdInterface, 0x280);
131 
133 {
134  char name[0x10];
135  uint32_t reusedCount;
136  WUT_PADDING_BYTES(0x6C);
138  WUT_PADDING_BYTES(0x40);
140  WUT_PADDING_BYTES(0x40);
141 };
142 WUT_CHECK_OFFSET(SmdCtrlTable, 0x000, name);
143 WUT_CHECK_OFFSET(SmdCtrlTable, 0x010, reusedCount);
144 WUT_CHECK_OFFSET(SmdCtrlTable, 0x080, iopInterface);
145 WUT_CHECK_OFFSET(SmdCtrlTable, 0x340, ppcInterface);
146 WUT_CHECK_SIZE(SmdCtrlTable, 0x600);
147 
149 {
151  uint32_t ctrlTableSize;
153  uint32_t writeBufSize;
155  uint32_t readBufSize;
156 };
157 WUT_CHECK_OFFSET(SmdPpcCtrlTableVectors, 0x00, ctrlTable);
158 WUT_CHECK_OFFSET(SmdPpcCtrlTableVectors, 0x04, ctrlTableSize);
159 WUT_CHECK_OFFSET(SmdPpcCtrlTableVectors, 0x08, writeBuf);
160 WUT_CHECK_OFFSET(SmdPpcCtrlTableVectors, 0x0C, writeBufSize);
161 WUT_CHECK_OFFSET(SmdPpcCtrlTableVectors, 0x10, readBuf);
162 WUT_CHECK_OFFSET(SmdPpcCtrlTableVectors, 0x14, readBufSize);
163 WUT_CHECK_SIZE(SmdPpcCtrlTableVectors, 0x18);
164 
165 struct SmdPpc
166 {
167  SmdPpc *self;
171  uint32_t messageCount;
175  WUT_PADDING_BYTES(0x38);
176 };
177 WUT_CHECK_OFFSET(SmdPpc, 0x00, self);
178 WUT_CHECK_OFFSET(SmdPpc, 0x04, ctrlTable);
179 WUT_CHECK_OFFSET(SmdPpc, 0x08, lockType);
180 WUT_CHECK_OFFSET(SmdPpc, 0x0C, mutex);
181 WUT_CHECK_OFFSET(SmdPpc, 0x38, messageCount);
182 WUT_CHECK_OFFSET(SmdPpc, 0x3C, writeBuf);
183 WUT_CHECK_OFFSET(SmdPpc, 0x40, readBuf);
184 WUT_CHECK_OFFSET(SmdPpc, 0x44, state);
185 WUT_CHECK_SIZE(SmdPpc, 0x80);
186 
188 {
191  void *poolData;
192  uint32_t poolDataSize;
194  uint32_t allocSize;
195  uint32_t realAllocSize;
196  uint32_t maxAllocCount;
199  uint32_t elementsIn;
200  uint32_t freeErrorCount;
201  WUT_PADDING_BYTES(0x28);
202 };
203 WUT_CHECK_OFFSET(SmdSimpleBufPool, 0x00, self);
204 WUT_CHECK_OFFSET(SmdSimpleBufPool, 0x04, mutex);
205 WUT_CHECK_OFFSET(SmdSimpleBufPool, 0x30, poolData);
206 WUT_CHECK_OFFSET(SmdSimpleBufPool, 0x34, poolDataSize);
207 WUT_CHECK_OFFSET(SmdSimpleBufPool, 0x38, lockType);
208 WUT_CHECK_OFFSET(SmdSimpleBufPool, 0x3C, allocSize);
209 WUT_CHECK_OFFSET(SmdSimpleBufPool, 0x40, realAllocSize);
210 WUT_CHECK_OFFSET(SmdSimpleBufPool, 0x44, maxAllocCount);
211 WUT_CHECK_OFFSET(SmdSimpleBufPool, 0x48, allocPoolStart);
212 WUT_CHECK_OFFSET(SmdSimpleBufPool, 0x4C, allocPoolEnd);
213 WUT_CHECK_OFFSET(SmdSimpleBufPool, 0x50, elementsIn);
214 WUT_CHECK_OFFSET(SmdSimpleBufPool, 0x54, freeErrorCount);
215 WUT_CHECK_SIZE(SmdSimpleBufPool, 0x80);
216 
217 SmdPpc *
218 smdPpcInit(void *buf,
219  uint32_t bufSize,
220  uint32_t messageCount,
221  const char *name,
222  SmdLockType lockType);
223 
224 int32_t
226  SmdPpcCtrlTableVectors *outVectors);
227 
228 int32_t
230 
231 int32_t
233 
234 int32_t
236  SmdInterfaceState *outPpcState,
237  SmdInterfaceState *outIopState);
238 
239 int32_t
241  SmdReceiveData *data);
242 
243 int32_t
245  void *message,
246  uint32_t messageSize);
247 
248 int32_t
250  uint32_t command,
251  SmdVectorSpec *specs,
252  int32_t specsCount);
253 
254 int32_t
256  SmdVector *vector);
257 
259 smdSimpleBufPoolCreate(void *poolData,
260  uint32_t poolDataSize,
261  uint32_t allocSize,
262  uint32_t allocCount,
263  SmdLockType lockType);
264 
265 int32_t
267  void **outAlloc);
268 
269 int32_t
271  void *alloc);
272 
273 int32_t
275  uint32_t *allocCount,
276  uint32_t *freeErrorCount);
277 
278 #ifdef __cplusplus
279 }
280 #endif
281 
Definition: mutex.h:36
void * allocPoolEnd
Definition: smd.h:198
SmdElementType type
Definition: smd.h:80
uint32_t poolDataSize
Definition: smd.h:192
int32_t count
Definition: smd.h:70
uint32_t ctrlTableSize
Definition: smd.h:151
uint32_t reusedCount
Definition: smd.h:135
SmdCtrlTable * ctrlTable
Definition: smd.h:150
SmdVectorSpec vecs[4]
Definition: smd.h:71
uint32_t bufPaddr
Definition: smd.h:121
SmdElement * readBuf
Definition: smd.h:154
uint32_t freeErrorCount
Definition: smd.h:200
SmdInterface ppcInterface
Definition: smd.h:138
SmdPpcState state
Definition: smd.h:174
uint32_t writeBufSize
Definition: smd.h:153
uint32_t realAllocSize
Definition: smd.h:195
void * poolData
Definition: smd.h:191
uint32_t allocSize
Definition: smd.h:194
int32_t writeOffset
Definition: smd.h:119
char name[0x10]
Definition: smd.h:134
SmdLockType lockType
Definition: smd.h:169
uint32_t size
Definition: smd.h:61
int32_t readOffset
Definition: smd.h:117
OSMutex mutex
Definition: smd.h:170
uint32_t elementsIn
Definition: smd.h:199
uint32_t readBufSize
Definition: smd.h:155
void * allocPoolStart
Definition: smd.h:197
void * ptr
Definition: smd.h:60
SmdElement * writeBuf
Definition: smd.h:152
uint32_t elementCount
Definition: smd.h:115
uint32_t messageCount
Definition: smd.h:171
uint32_t command
Definition: smd.h:69
SmdInterfaceState state
Definition: smd.h:114
SmdInterface iopInterface
Definition: smd.h:136
uint32_t maxAllocCount
Definition: smd.h:196
SmdSimpleBufPool * smdSimpleBufPoolCreate(void *poolData, uint32_t poolDataSize, uint32_t allocSize, uint32_t allocCount, SmdLockType lockType)
SmdPpcState
Definition: smd.h:38
int32_t smdPpcGetInterfaceState(SmdPpc *smd, SmdInterfaceState *outPpcState, SmdInterfaceState *outIopState)
int32_t smdPpcSendMessage(SmdPpc *smd, void *message, uint32_t messageSize)
SmdPpc * smdPpcInit(void *buf, uint32_t bufSize, uint32_t messageCount, const char *name, SmdLockType lockType)
int32_t smdPpcClose(SmdPpc *smd)
int32_t smdPpcSendVector(SmdPpc *smd, SmdVector *vector)
int32_t smdSimpleBufFree(SmdSimpleBufPool *pool, void *alloc)
int32_t smdSimpleBufAlloc(SmdSimpleBufPool *pool, void **outAlloc)
SmdInterfaceState
Definition: smd.h:46
SmdElementType
Definition: smd.h:52
int32_t smdSimpleBufGetStatistics(SmdSimpleBufPool *pool, uint32_t *allocCount, uint32_t *freeErrorCount)
int32_t smdPpcOpen(SmdPpc *smd)
int32_t smdPpcSendVectorSpec(SmdPpc *smd, uint32_t command, SmdVectorSpec *specs, int32_t specsCount)
int32_t smdPpcReceive(SmdPpc *smd, SmdReceiveData *data)
SmdLockType
Definition: smd.h:28
int32_t smdPpcGetCtrlTableVectors(SmdPpc *smd, SmdPpcCtrlTableVectors *outVectors)
@ SMD_PPC_STATE_INVALID
Definition: smd.h:39
@ SMD_PPC_STATE_CLOSED
Definition: smd.h:41
@ SMD_PPC_STATE_OPENED
Definition: smd.h:42
@ SMD_PPC_STATE_INITIALIZED
Definition: smd.h:40
@ SMD_INTERFACE_STATE_OPENED
Definition: smd.h:47
@ SMD_INTERFACE_STATE_CLOSED
Definition: smd.h:48
@ SMD_ELEMENT_TYPE_VECTOR_SPEC
Definition: smd.h:54
@ SMD_ELEMENT_TYPE_VECTOR
Definition: smd.h:55
@ SMD_ELEMENT_TYPE_MESSAGE
Definition: smd.h:53
@ SMD_LOCK_TYPE_NONE
No locking is done.
Definition: smd.h:34
@ SMD_LOCK_TYPE_DISABLE_INTERRUPTS
Locking is done by disabling interrupts.
Definition: smd.h:32
@ SMD_LOCK_TYPE_MUTEX
Locking is done with a mutex.
Definition: smd.h:30
Definition: smd.h:79
Definition: smd.h:166
Definition: smd.h:68