File: | obj-scan-build/boot/deviceServer.c |
Location: | line 72, column 2 |
Description: | Assigned value is garbage or undefined |
1 | /* Module device */ |
2 | |
3 | #ifndef _GNU_SOURCE1 |
4 | #define _GNU_SOURCE1 1 |
5 | #endif |
6 | |
7 | #define EXPORT_BOOLEAN |
8 | #include <mach/boolean.h> |
9 | #include <mach/kern_return.h> |
10 | #include <mach/message.h> |
11 | #include <mach/mig_errors.h> |
12 | #include <mach/mig_support.h> |
13 | |
14 | #ifndef mig_internalstatic |
15 | #define mig_internalstatic static |
16 | #endif |
17 | |
18 | #ifndef mig_external |
19 | #define mig_external |
20 | #endif |
21 | |
22 | #ifndef mig_unlikely |
23 | #define mig_unlikely(X)__builtin_expect (!! (X), 0) __builtin_expect (!! (X), 0) |
24 | #endif |
25 | |
26 | #ifndef TypeCheck1 |
27 | #define TypeCheck1 1 |
28 | #endif |
29 | |
30 | #ifndef UseExternRCSId1 |
31 | #define UseExternRCSId1 1 |
32 | #endif |
33 | |
34 | #define BAD_TYPECHECK(type, check)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; } )), 0) mig_unlikely (({\__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; } )), 0) |
35 | union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; } )), 0) |
36 | _t.t = *(type); _c.t = *(check);_t.w != _c.w; }))__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; } )), 0) |
37 | #define msgh_request_portmsgh_local_port msgh_local_port |
38 | #define MACH_MSGH_BITS_REQUEST(bits)(((bits) & 0x0000ff00) >> 8) MACH_MSGH_BITS_LOCAL(bits)(((bits) & 0x0000ff00) >> 8) |
39 | #define msgh_reply_portmsgh_remote_port msgh_remote_port |
40 | #define MACH_MSGH_BITS_REPLY(bits)((bits) & 0x000000ff) MACH_MSGH_BITS_REMOTE(bits)((bits) & 0x000000ff) |
41 | |
42 | #include <mach/std_types.h> |
43 | #include <mach/mach_types.h> |
44 | #include <device/device_types.h> |
45 | #include <device/net_status.h> |
46 | |
47 | /* Routine device_open */ |
48 | mig_internalstatic void _Xdevice_open |
49 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
50 | { |
51 | typedef struct { |
52 | mach_msg_header_t Head; |
53 | mach_msg_type_t modeType; |
54 | dev_mode_t mode; |
55 | mach_msg_type_long_t nameType; |
56 | dev_name_t name; |
57 | } Request; |
58 | |
59 | typedef struct { |
60 | mach_msg_header_t Head; |
61 | mach_msg_type_t RetCodeType; |
62 | kern_return_t RetCode; |
63 | mach_msg_type_t deviceType; |
64 | mach_port_t device; |
65 | } Reply; |
66 | |
67 | Request *In0P = (Request *) InHeadP; |
68 | Reply *OutP = (Reply *) OutHeadP; |
69 | mig_external kern_return_t ds_device_open |
70 | (mach_port_t master_port, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, dev_name_t name, mach_port_t *device, mach_msg_type_name_t *devicePoly); |
71 | |
72 | boolean_t msgh_simple = msgh_simple; |
Assigned value is garbage or undefined | |
73 | const mach_msg_type_t modeCheck = { |
74 | /* msgt_name = */ 2, |
75 | /* msgt_size = */ 32, |
76 | /* msgt_number = */ 1, |
77 | /* msgt_inline = */ TRUE((boolean_t) 1), |
78 | /* msgt_longform = */ FALSE((boolean_t) 0), |
79 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
80 | /* msgt_unused = */ 0 |
81 | }; |
82 | |
83 | const mach_msg_type_t deviceType = { |
84 | /* msgt_name = */ -1, |
85 | /* msgt_size = */ 32, |
86 | /* msgt_number = */ 1, |
87 | /* msgt_inline = */ TRUE((boolean_t) 1), |
88 | /* msgt_longform = */ FALSE((boolean_t) 0), |
89 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
90 | /* msgt_unused = */ 0 |
91 | }; |
92 | |
93 | mach_msg_type_name_t devicePoly; |
94 | |
95 | #if TypeCheck1 |
96 | if (mig_unlikely ((In0P->Head.msgh_size != 172) ||__builtin_expect (!! ((In0P->Head.msgh_size != 172) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
97 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 172) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
98 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
99 | #endif /* TypeCheck */ |
100 | |
101 | #if TypeCheck1 |
102 | if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->modeType); _c.t = *(& modeCheck);_t.w != _c.w; })), 0)) |
103 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
104 | #endif /* TypeCheck */ |
105 | |
106 | #if TypeCheck1 |
107 | if (mig_unlikely ((In0P->nameType.msgtl_header.msgt_inline != TRUE) ||__builtin_expect (!! ((In0P->nameType.msgtl_header.msgt_inline != ((boolean_t) 1)) || (In0P->nameType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->nameType.msgtl_name != 12) || (In0P->nameType.msgtl_number != 1) || (In0P->nameType. msgtl_size != 1024)), 0) |
108 | (In0P->nameType.msgtl_header.msgt_longform != TRUE) ||__builtin_expect (!! ((In0P->nameType.msgtl_header.msgt_inline != ((boolean_t) 1)) || (In0P->nameType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->nameType.msgtl_name != 12) || (In0P->nameType.msgtl_number != 1) || (In0P->nameType. msgtl_size != 1024)), 0) |
109 | (In0P->nameType.msgtl_name != 12) ||__builtin_expect (!! ((In0P->nameType.msgtl_header.msgt_inline != ((boolean_t) 1)) || (In0P->nameType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->nameType.msgtl_name != 12) || (In0P->nameType.msgtl_number != 1) || (In0P->nameType. msgtl_size != 1024)), 0) |
110 | (In0P->nameType.msgtl_number != 1) ||__builtin_expect (!! ((In0P->nameType.msgtl_header.msgt_inline != ((boolean_t) 1)) || (In0P->nameType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->nameType.msgtl_name != 12) || (In0P->nameType.msgtl_number != 1) || (In0P->nameType. msgtl_size != 1024)), 0) |
111 | (In0P->nameType.msgtl_size != 1024))__builtin_expect (!! ((In0P->nameType.msgtl_header.msgt_inline != ((boolean_t) 1)) || (In0P->nameType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->nameType.msgtl_name != 12) || (In0P->nameType.msgtl_number != 1) || (In0P->nameType. msgtl_size != 1024)), 0)) |
112 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
113 | #endif /* TypeCheck */ |
114 | |
115 | OutP->RetCode = ds_device_open(In0P->Head.msgh_request_portmsgh_local_port, In0P->Head.msgh_reply_portmsgh_remote_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits)((In0P->Head.msgh_bits) & 0x000000ff), In0P->mode, In0P->name, &OutP->device, &devicePoly); |
116 | if (OutP->RetCode != KERN_SUCCESS0) |
117 | return; |
118 | |
119 | msgh_simple = TRUE((boolean_t) 1); |
120 | OutP->Head.msgh_size = 40; |
121 | |
122 | OutP->deviceType = deviceType; |
123 | |
124 | if (MACH_MSG_TYPE_PORT_ANY(devicePoly)(((devicePoly) >= 16) && ((devicePoly) <= 21))) |
125 | msgh_simple = FALSE((boolean_t) 0); |
126 | |
127 | OutP->deviceType.msgt_name = devicePoly; |
128 | |
129 | if (!msgh_simple) |
130 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
131 | } |
132 | |
133 | /* Default implementation of ds_device_open */ |
134 | #ifdef MIG_EOPNOTSUPP |
135 | kern_return_t __attribute__ ((weak)) |
136 | ds_device_open |
137 | ( |
138 | mach_port_t master_port, |
139 | mach_port_t reply_port, |
140 | mach_msg_type_name_t reply_portPoly, |
141 | dev_mode_t mode, |
142 | dev_name_t name, |
143 | mach_port_t *device, |
144 | mach_msg_type_name_t *devicePoly |
145 | ) { return MIG_EOPNOTSUPP; } |
146 | #endif /* MIG_EOPNOTSUPP */ |
147 | |
148 | /* Routine device_close */ |
149 | mig_internalstatic void _Xdevice_close |
150 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
151 | { |
152 | typedef struct { |
153 | mach_msg_header_t Head; |
154 | } Request; |
155 | |
156 | typedef struct { |
157 | mach_msg_header_t Head; |
158 | mach_msg_type_t RetCodeType; |
159 | kern_return_t RetCode; |
160 | } Reply; |
161 | |
162 | Request *In0P = (Request *) InHeadP; |
163 | Reply *OutP = (Reply *) OutHeadP; |
164 | mig_external kern_return_t ds_device_close |
165 | (mach_port_t device); |
166 | |
167 | #if TypeCheck1 |
168 | if (mig_unlikely ((In0P->Head.msgh_size != 24) ||__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
169 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
170 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
171 | #endif /* TypeCheck */ |
172 | |
173 | OutP->RetCode = ds_device_close(In0P->Head.msgh_request_portmsgh_local_port); |
174 | } |
175 | |
176 | /* Default implementation of ds_device_close */ |
177 | #ifdef MIG_EOPNOTSUPP |
178 | kern_return_t __attribute__ ((weak)) |
179 | ds_device_close |
180 | ( |
181 | mach_port_t device |
182 | ) { return MIG_EOPNOTSUPP; } |
183 | #endif /* MIG_EOPNOTSUPP */ |
184 | |
185 | /* Routine device_write */ |
186 | mig_internalstatic void _Xdevice_write |
187 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
188 | { |
189 | typedef struct { |
190 | mach_msg_header_t Head; |
191 | mach_msg_type_t modeType; |
192 | dev_mode_t mode; |
193 | mach_msg_type_t recnumType; |
194 | recnum_t recnum; |
195 | mach_msg_type_long_t dataType; |
196 | io_buf_ptr_t data; |
197 | } Request; |
198 | |
199 | typedef struct { |
200 | mach_msg_header_t Head; |
201 | mach_msg_type_t RetCodeType; |
202 | kern_return_t RetCode; |
203 | mach_msg_type_t bytes_writtenType; |
204 | int bytes_written; |
205 | } Reply; |
206 | |
207 | Request *In0P = (Request *) InHeadP; |
208 | Reply *OutP = (Reply *) OutHeadP; |
209 | mig_external kern_return_t ds_device_write |
210 | (mach_port_t device, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, recnum_t recnum, io_buf_ptr_t data, mach_msg_type_number_t dataCnt, int *bytes_written); |
211 | |
212 | const mach_msg_type_t modeCheck = { |
213 | /* msgt_name = */ 2, |
214 | /* msgt_size = */ 32, |
215 | /* msgt_number = */ 1, |
216 | /* msgt_inline = */ TRUE((boolean_t) 1), |
217 | /* msgt_longform = */ FALSE((boolean_t) 0), |
218 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
219 | /* msgt_unused = */ 0 |
220 | }; |
221 | |
222 | const mach_msg_type_t recnumCheck = { |
223 | /* msgt_name = */ 2, |
224 | /* msgt_size = */ 32, |
225 | /* msgt_number = */ 1, |
226 | /* msgt_inline = */ TRUE((boolean_t) 1), |
227 | /* msgt_longform = */ FALSE((boolean_t) 0), |
228 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
229 | /* msgt_unused = */ 0 |
230 | }; |
231 | |
232 | const mach_msg_type_t bytes_writtenType = { |
233 | /* msgt_name = */ 2, |
234 | /* msgt_size = */ 32, |
235 | /* msgt_number = */ 1, |
236 | /* msgt_inline = */ TRUE((boolean_t) 1), |
237 | /* msgt_longform = */ FALSE((boolean_t) 0), |
238 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
239 | /* msgt_unused = */ 0 |
240 | }; |
241 | |
242 | #if TypeCheck1 |
243 | if (mig_unlikely ((In0P->Head.msgh_size != 56) ||__builtin_expect (!! ((In0P->Head.msgh_size != 56) || !(In0P ->Head.msgh_bits & 0x80000000U)), 0) |
244 | !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 56) || !(In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
245 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
246 | #endif /* TypeCheck */ |
247 | |
248 | #if TypeCheck1 |
249 | if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->modeType); _c.t = *(& modeCheck);_t.w != _c.w; })), 0)) |
250 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
251 | #endif /* TypeCheck */ |
252 | |
253 | #if TypeCheck1 |
254 | if (BAD_TYPECHECK(&In0P->recnumType, &recnumCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->recnumType); _c.t = *(& recnumCheck);_t.w != _c.w; })), 0)) |
255 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
256 | #endif /* TypeCheck */ |
257 | |
258 | #if TypeCheck1 |
259 | if (mig_unlikely ((In0P->dataType.msgtl_header.msgt_inline != FALSE) ||__builtin_expect (!! ((In0P->dataType.msgtl_header.msgt_inline != ((boolean_t) 0)) || (In0P->dataType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->dataType.msgtl_name != 9) || (In0P->dataType.msgtl_size != 8)), 0) |
260 | (In0P->dataType.msgtl_header.msgt_longform != TRUE) ||__builtin_expect (!! ((In0P->dataType.msgtl_header.msgt_inline != ((boolean_t) 0)) || (In0P->dataType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->dataType.msgtl_name != 9) || (In0P->dataType.msgtl_size != 8)), 0) |
261 | (In0P->dataType.msgtl_name != 9) ||__builtin_expect (!! ((In0P->dataType.msgtl_header.msgt_inline != ((boolean_t) 0)) || (In0P->dataType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->dataType.msgtl_name != 9) || (In0P->dataType.msgtl_size != 8)), 0) |
262 | (In0P->dataType.msgtl_size != 8))__builtin_expect (!! ((In0P->dataType.msgtl_header.msgt_inline != ((boolean_t) 0)) || (In0P->dataType.msgtl_header.msgt_longform != ((boolean_t) 1)) || (In0P->dataType.msgtl_name != 9) || (In0P->dataType.msgtl_size != 8)), 0)) |
263 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
264 | #endif /* TypeCheck */ |
265 | |
266 | OutP->RetCode = ds_device_write(In0P->Head.msgh_request_portmsgh_local_port, In0P->Head.msgh_reply_portmsgh_remote_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits)((In0P->Head.msgh_bits) & 0x000000ff), In0P->mode, In0P->recnum, In0P->data, In0P->dataType.msgtl_number, &OutP->bytes_written); |
267 | if (OutP->RetCode != KERN_SUCCESS0) |
268 | return; |
269 | |
270 | OutP->Head.msgh_size = 40; |
271 | |
272 | OutP->bytes_writtenType = bytes_writtenType; |
273 | } |
274 | |
275 | /* Default implementation of ds_device_write */ |
276 | #ifdef MIG_EOPNOTSUPP |
277 | kern_return_t __attribute__ ((weak)) |
278 | ds_device_write |
279 | ( |
280 | mach_port_t device, |
281 | mach_port_t reply_port, |
282 | mach_msg_type_name_t reply_portPoly, |
283 | dev_mode_t mode, |
284 | recnum_t recnum, |
285 | io_buf_ptr_t data, |
286 | mach_msg_type_number_t dataCnt, |
287 | int *bytes_written |
288 | ) { return MIG_EOPNOTSUPP; } |
289 | #endif /* MIG_EOPNOTSUPP */ |
290 | |
291 | /* Routine device_write_inband */ |
292 | mig_internalstatic void _Xdevice_write_inband |
293 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
294 | { |
295 | typedef struct { |
296 | mach_msg_header_t Head; |
297 | mach_msg_type_t modeType; |
298 | dev_mode_t mode; |
299 | mach_msg_type_t recnumType; |
300 | recnum_t recnum; |
301 | mach_msg_type_t dataType; |
302 | char data[128]; |
303 | } Request; |
304 | |
305 | typedef struct { |
306 | mach_msg_header_t Head; |
307 | mach_msg_type_t RetCodeType; |
308 | kern_return_t RetCode; |
309 | mach_msg_type_t bytes_writtenType; |
310 | int bytes_written; |
311 | } Reply; |
312 | |
313 | Request *In0P = (Request *) InHeadP; |
314 | Reply *OutP = (Reply *) OutHeadP; |
315 | mig_external kern_return_t ds_device_write_inband |
316 | (mach_port_t device, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, recnum_t recnum, io_buf_ptr_inband_t data, mach_msg_type_number_t dataCnt, int *bytes_written); |
317 | |
318 | unsigned int msgh_size; |
319 | |
320 | const mach_msg_type_t modeCheck = { |
321 | /* msgt_name = */ 2, |
322 | /* msgt_size = */ 32, |
323 | /* msgt_number = */ 1, |
324 | /* msgt_inline = */ TRUE((boolean_t) 1), |
325 | /* msgt_longform = */ FALSE((boolean_t) 0), |
326 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
327 | /* msgt_unused = */ 0 |
328 | }; |
329 | |
330 | const mach_msg_type_t recnumCheck = { |
331 | /* msgt_name = */ 2, |
332 | /* msgt_size = */ 32, |
333 | /* msgt_number = */ 1, |
334 | /* msgt_inline = */ TRUE((boolean_t) 1), |
335 | /* msgt_longform = */ FALSE((boolean_t) 0), |
336 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
337 | /* msgt_unused = */ 0 |
338 | }; |
339 | |
340 | const mach_msg_type_t bytes_writtenType = { |
341 | /* msgt_name = */ 2, |
342 | /* msgt_size = */ 32, |
343 | /* msgt_number = */ 1, |
344 | /* msgt_inline = */ TRUE((boolean_t) 1), |
345 | /* msgt_longform = */ FALSE((boolean_t) 0), |
346 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
347 | /* msgt_unused = */ 0 |
348 | }; |
349 | |
350 | #if TypeCheck1 |
351 | msgh_size = In0P->Head.msgh_size; |
352 | if (mig_unlikely ((msgh_size < 44) ||__builtin_expect (!! ((msgh_size < 44) || (In0P->Head.msgh_bits & 0x80000000U)), 0) |
353 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((msgh_size < 44) || (In0P->Head.msgh_bits & 0x80000000U)), 0)) |
354 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
355 | #endif /* TypeCheck */ |
356 | |
357 | #if TypeCheck1 |
358 | if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->modeType); _c.t = *(& modeCheck);_t.w != _c.w; })), 0)) |
359 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
360 | #endif /* TypeCheck */ |
361 | |
362 | #if TypeCheck1 |
363 | if (BAD_TYPECHECK(&In0P->recnumType, &recnumCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->recnumType); _c.t = *(& recnumCheck);_t.w != _c.w; })), 0)) |
364 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
365 | #endif /* TypeCheck */ |
366 | |
367 | #if TypeCheck1 |
368 | if (mig_unlikely ((In0P->dataType.msgt_inline != TRUE) ||__builtin_expect (!! ((In0P->dataType.msgt_inline != ((boolean_t ) 1)) || (In0P->dataType.msgt_longform != ((boolean_t) 0)) || (In0P->dataType.msgt_name != 8) || (In0P->dataType. msgt_size != 8)), 0) |
369 | (In0P->dataType.msgt_longform != FALSE) ||__builtin_expect (!! ((In0P->dataType.msgt_inline != ((boolean_t ) 1)) || (In0P->dataType.msgt_longform != ((boolean_t) 0)) || (In0P->dataType.msgt_name != 8) || (In0P->dataType. msgt_size != 8)), 0) |
370 | (In0P->dataType.msgt_name != 8) ||__builtin_expect (!! ((In0P->dataType.msgt_inline != ((boolean_t ) 1)) || (In0P->dataType.msgt_longform != ((boolean_t) 0)) || (In0P->dataType.msgt_name != 8) || (In0P->dataType. msgt_size != 8)), 0) |
371 | (In0P->dataType.msgt_size != 8))__builtin_expect (!! ((In0P->dataType.msgt_inline != ((boolean_t ) 1)) || (In0P->dataType.msgt_longform != ((boolean_t) 0)) || (In0P->dataType.msgt_name != 8) || (In0P->dataType. msgt_size != 8)), 0)) |
372 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
373 | #endif /* TypeCheck */ |
374 | |
375 | #if TypeCheck1 |
376 | if (mig_unlikely (msgh_size != 44 + ((In0P->dataType.msgt_number + 3) & ~3))__builtin_expect (!! (msgh_size != 44 + ((In0P->dataType.msgt_number + 3) & ~3)), 0)) |
377 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
378 | #endif /* TypeCheck */ |
379 | |
380 | OutP->RetCode = ds_device_write_inband(In0P->Head.msgh_request_portmsgh_local_port, In0P->Head.msgh_reply_portmsgh_remote_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits)((In0P->Head.msgh_bits) & 0x000000ff), In0P->mode, In0P->recnum, In0P->data, In0P->dataType.msgt_number, &OutP->bytes_written); |
381 | if (OutP->RetCode != KERN_SUCCESS0) |
382 | return; |
383 | |
384 | OutP->Head.msgh_size = 40; |
385 | |
386 | OutP->bytes_writtenType = bytes_writtenType; |
387 | } |
388 | |
389 | /* Default implementation of ds_device_write_inband */ |
390 | #ifdef MIG_EOPNOTSUPP |
391 | kern_return_t __attribute__ ((weak)) |
392 | ds_device_write_inband |
393 | ( |
394 | mach_port_t device, |
395 | mach_port_t reply_port, |
396 | mach_msg_type_name_t reply_portPoly, |
397 | dev_mode_t mode, |
398 | recnum_t recnum, |
399 | io_buf_ptr_inband_t data, |
400 | mach_msg_type_number_t dataCnt, |
401 | int *bytes_written |
402 | ) { return MIG_EOPNOTSUPP; } |
403 | #endif /* MIG_EOPNOTSUPP */ |
404 | |
405 | /* Routine device_read */ |
406 | mig_internalstatic void _Xdevice_read |
407 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
408 | { |
409 | typedef struct { |
410 | mach_msg_header_t Head; |
411 | mach_msg_type_t modeType; |
412 | dev_mode_t mode; |
413 | mach_msg_type_t recnumType; |
414 | recnum_t recnum; |
415 | mach_msg_type_t bytes_wantedType; |
416 | int bytes_wanted; |
417 | } Request; |
418 | |
419 | typedef struct { |
420 | mach_msg_header_t Head; |
421 | mach_msg_type_t RetCodeType; |
422 | kern_return_t RetCode; |
423 | mach_msg_type_long_t dataType; |
424 | io_buf_ptr_t data; |
425 | } Reply; |
426 | |
427 | Request *In0P = (Request *) InHeadP; |
428 | Reply *OutP = (Reply *) OutHeadP; |
429 | mig_external kern_return_t ds_device_read |
430 | (mach_port_t device, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, recnum_t recnum, int bytes_wanted, io_buf_ptr_t *data, mach_msg_type_number_t *dataCnt); |
431 | |
432 | const mach_msg_type_t modeCheck = { |
433 | /* msgt_name = */ 2, |
434 | /* msgt_size = */ 32, |
435 | /* msgt_number = */ 1, |
436 | /* msgt_inline = */ TRUE((boolean_t) 1), |
437 | /* msgt_longform = */ FALSE((boolean_t) 0), |
438 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
439 | /* msgt_unused = */ 0 |
440 | }; |
441 | |
442 | const mach_msg_type_t recnumCheck = { |
443 | /* msgt_name = */ 2, |
444 | /* msgt_size = */ 32, |
445 | /* msgt_number = */ 1, |
446 | /* msgt_inline = */ TRUE((boolean_t) 1), |
447 | /* msgt_longform = */ FALSE((boolean_t) 0), |
448 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
449 | /* msgt_unused = */ 0 |
450 | }; |
451 | |
452 | const mach_msg_type_t bytes_wantedCheck = { |
453 | /* msgt_name = */ 2, |
454 | /* msgt_size = */ 32, |
455 | /* msgt_number = */ 1, |
456 | /* msgt_inline = */ TRUE((boolean_t) 1), |
457 | /* msgt_longform = */ FALSE((boolean_t) 0), |
458 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
459 | /* msgt_unused = */ 0 |
460 | }; |
461 | |
462 | const mach_msg_type_long_t dataType = { |
463 | { |
464 | /* msgt_name = */ 0, |
465 | /* msgt_size = */ 0, |
466 | /* msgt_number = */ 0, |
467 | /* msgt_inline = */ FALSE((boolean_t) 0), |
468 | /* msgt_longform = */ TRUE((boolean_t) 1), |
469 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
470 | /* msgt_unused = */ 0 |
471 | }, |
472 | /* msgtl_name = */ 9, |
473 | /* msgtl_size = */ 8, |
474 | /* msgtl_number = */ 0, |
475 | }; |
476 | |
477 | mach_msg_type_number_t dataCnt; |
478 | |
479 | #if TypeCheck1 |
480 | if (mig_unlikely ((In0P->Head.msgh_size != 48) ||__builtin_expect (!! ((In0P->Head.msgh_size != 48) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
481 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 48) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
482 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
483 | #endif /* TypeCheck */ |
484 | |
485 | #if TypeCheck1 |
486 | if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->modeType); _c.t = *(& modeCheck);_t.w != _c.w; })), 0)) |
487 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
488 | #endif /* TypeCheck */ |
489 | |
490 | #if TypeCheck1 |
491 | if (BAD_TYPECHECK(&In0P->recnumType, &recnumCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->recnumType); _c.t = *(& recnumCheck);_t.w != _c.w; })), 0)) |
492 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
493 | #endif /* TypeCheck */ |
494 | |
495 | #if TypeCheck1 |
496 | if (BAD_TYPECHECK(&In0P->bytes_wantedType, &bytes_wantedCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->bytes_wantedType); _c.t = *(&bytes_wantedCheck);_t.w != _c.w; })), 0)) |
497 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
498 | #endif /* TypeCheck */ |
499 | |
500 | OutP->RetCode = ds_device_read(In0P->Head.msgh_request_portmsgh_local_port, In0P->Head.msgh_reply_portmsgh_remote_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits)((In0P->Head.msgh_bits) & 0x000000ff), In0P->mode, In0P->recnum, In0P->bytes_wanted, &OutP->data, &dataCnt); |
501 | if (OutP->RetCode != KERN_SUCCESS0) |
502 | return; |
503 | |
504 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
505 | OutP->Head.msgh_size = 48; |
506 | |
507 | OutP->dataType = dataType; |
508 | |
509 | OutP->dataType.msgtl_number = dataCnt; |
510 | } |
511 | |
512 | /* Default implementation of ds_device_read */ |
513 | #ifdef MIG_EOPNOTSUPP |
514 | kern_return_t __attribute__ ((weak)) |
515 | ds_device_read |
516 | ( |
517 | mach_port_t device, |
518 | mach_port_t reply_port, |
519 | mach_msg_type_name_t reply_portPoly, |
520 | dev_mode_t mode, |
521 | recnum_t recnum, |
522 | int bytes_wanted, |
523 | io_buf_ptr_t *data, |
524 | mach_msg_type_number_t *dataCnt |
525 | ) { return MIG_EOPNOTSUPP; } |
526 | #endif /* MIG_EOPNOTSUPP */ |
527 | |
528 | /* Routine device_read_inband */ |
529 | mig_internalstatic void _Xdevice_read_inband |
530 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
531 | { |
532 | typedef struct { |
533 | mach_msg_header_t Head; |
534 | mach_msg_type_t modeType; |
535 | dev_mode_t mode; |
536 | mach_msg_type_t recnumType; |
537 | recnum_t recnum; |
538 | mach_msg_type_t bytes_wantedType; |
539 | int bytes_wanted; |
540 | } Request; |
541 | |
542 | typedef struct { |
543 | mach_msg_header_t Head; |
544 | mach_msg_type_t RetCodeType; |
545 | kern_return_t RetCode; |
546 | mach_msg_type_t dataType; |
547 | char data[128]; |
548 | } Reply; |
549 | |
550 | Request *In0P = (Request *) InHeadP; |
551 | Reply *OutP = (Reply *) OutHeadP; |
552 | mig_external kern_return_t ds_device_read_inband |
553 | (mach_port_t device, mach_port_t reply_port, mach_msg_type_name_t reply_portPoly, dev_mode_t mode, recnum_t recnum, int bytes_wanted, io_buf_ptr_inband_t data, mach_msg_type_number_t *dataCnt); |
554 | |
555 | const mach_msg_type_t modeCheck = { |
556 | /* msgt_name = */ 2, |
557 | /* msgt_size = */ 32, |
558 | /* msgt_number = */ 1, |
559 | /* msgt_inline = */ TRUE((boolean_t) 1), |
560 | /* msgt_longform = */ FALSE((boolean_t) 0), |
561 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
562 | /* msgt_unused = */ 0 |
563 | }; |
564 | |
565 | const mach_msg_type_t recnumCheck = { |
566 | /* msgt_name = */ 2, |
567 | /* msgt_size = */ 32, |
568 | /* msgt_number = */ 1, |
569 | /* msgt_inline = */ TRUE((boolean_t) 1), |
570 | /* msgt_longform = */ FALSE((boolean_t) 0), |
571 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
572 | /* msgt_unused = */ 0 |
573 | }; |
574 | |
575 | const mach_msg_type_t bytes_wantedCheck = { |
576 | /* msgt_name = */ 2, |
577 | /* msgt_size = */ 32, |
578 | /* msgt_number = */ 1, |
579 | /* msgt_inline = */ TRUE((boolean_t) 1), |
580 | /* msgt_longform = */ FALSE((boolean_t) 0), |
581 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
582 | /* msgt_unused = */ 0 |
583 | }; |
584 | |
585 | const mach_msg_type_t dataType = { |
586 | /* msgt_name = */ 8, |
587 | /* msgt_size = */ 8, |
588 | /* msgt_number = */ 128, |
589 | /* msgt_inline = */ TRUE((boolean_t) 1), |
590 | /* msgt_longform = */ FALSE((boolean_t) 0), |
591 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
592 | /* msgt_unused = */ 0 |
593 | }; |
594 | |
595 | mach_msg_type_number_t dataCnt; |
596 | |
597 | #if TypeCheck1 |
598 | if (mig_unlikely ((In0P->Head.msgh_size != 48) ||__builtin_expect (!! ((In0P->Head.msgh_size != 48) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
599 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 48) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
600 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
601 | #endif /* TypeCheck */ |
602 | |
603 | #if TypeCheck1 |
604 | if (BAD_TYPECHECK(&In0P->modeType, &modeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->modeType); _c.t = *(& modeCheck);_t.w != _c.w; })), 0)) |
605 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
606 | #endif /* TypeCheck */ |
607 | |
608 | #if TypeCheck1 |
609 | if (BAD_TYPECHECK(&In0P->recnumType, &recnumCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->recnumType); _c.t = *(& recnumCheck);_t.w != _c.w; })), 0)) |
610 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
611 | #endif /* TypeCheck */ |
612 | |
613 | #if TypeCheck1 |
614 | if (BAD_TYPECHECK(&In0P->bytes_wantedType, &bytes_wantedCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->bytes_wantedType); _c.t = *(&bytes_wantedCheck);_t.w != _c.w; })), 0)) |
615 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
616 | #endif /* TypeCheck */ |
617 | |
618 | dataCnt = 128; |
619 | |
620 | OutP->RetCode = ds_device_read_inband(In0P->Head.msgh_request_portmsgh_local_port, In0P->Head.msgh_reply_portmsgh_remote_port, MACH_MSGH_BITS_REPLY(In0P->Head.msgh_bits)((In0P->Head.msgh_bits) & 0x000000ff), In0P->mode, In0P->recnum, In0P->bytes_wanted, OutP->data, &dataCnt); |
621 | if (OutP->RetCode != KERN_SUCCESS0) |
622 | return; |
623 | |
624 | OutP->dataType = dataType; |
625 | |
626 | OutP->dataType.msgt_number = dataCnt; |
627 | OutP->Head.msgh_size = 36 + ((dataCnt + 3) & ~3); |
628 | } |
629 | |
630 | /* Default implementation of ds_device_read_inband */ |
631 | #ifdef MIG_EOPNOTSUPP |
632 | kern_return_t __attribute__ ((weak)) |
633 | ds_device_read_inband |
634 | ( |
635 | mach_port_t device, |
636 | mach_port_t reply_port, |
637 | mach_msg_type_name_t reply_portPoly, |
638 | dev_mode_t mode, |
639 | recnum_t recnum, |
640 | int bytes_wanted, |
641 | io_buf_ptr_inband_t data, |
642 | mach_msg_type_number_t *dataCnt |
643 | ) { return MIG_EOPNOTSUPP; } |
644 | #endif /* MIG_EOPNOTSUPP */ |
645 | |
646 | /* Routine device_map */ |
647 | mig_internalstatic void _Xdevice_map |
648 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
649 | { |
650 | typedef struct { |
651 | mach_msg_header_t Head; |
652 | mach_msg_type_t protType; |
653 | vm_prot_t prot; |
654 | mach_msg_type_t offsetType; |
655 | vm_offset_t offset; |
656 | mach_msg_type_t sizeType; |
657 | vm_size_t size; |
658 | mach_msg_type_t unmapType; |
659 | int unmap; |
660 | } Request; |
661 | |
662 | typedef struct { |
663 | mach_msg_header_t Head; |
664 | mach_msg_type_t RetCodeType; |
665 | kern_return_t RetCode; |
666 | mach_msg_type_t pagerType; |
667 | mach_port_t pager; |
668 | } Reply; |
669 | |
670 | Request *In0P = (Request *) InHeadP; |
671 | Reply *OutP = (Reply *) OutHeadP; |
672 | mig_external kern_return_t ds_device_map |
673 | (mach_port_t device, vm_prot_t prot, vm_offset_t offset, vm_size_t size, mach_port_t *pager, int unmap); |
674 | |
675 | const mach_msg_type_t protCheck = { |
676 | /* msgt_name = */ 2, |
677 | /* msgt_size = */ 32, |
678 | /* msgt_number = */ 1, |
679 | /* msgt_inline = */ TRUE((boolean_t) 1), |
680 | /* msgt_longform = */ FALSE((boolean_t) 0), |
681 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
682 | /* msgt_unused = */ 0 |
683 | }; |
684 | |
685 | const mach_msg_type_t offsetCheck = { |
686 | /* msgt_name = */ 2, |
687 | /* msgt_size = */ 32, |
688 | /* msgt_number = */ 1, |
689 | /* msgt_inline = */ TRUE((boolean_t) 1), |
690 | /* msgt_longform = */ FALSE((boolean_t) 0), |
691 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
692 | /* msgt_unused = */ 0 |
693 | }; |
694 | |
695 | const mach_msg_type_t sizeCheck = { |
696 | /* msgt_name = */ 2, |
697 | /* msgt_size = */ 32, |
698 | /* msgt_number = */ 1, |
699 | /* msgt_inline = */ TRUE((boolean_t) 1), |
700 | /* msgt_longform = */ FALSE((boolean_t) 0), |
701 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
702 | /* msgt_unused = */ 0 |
703 | }; |
704 | |
705 | const mach_msg_type_t unmapCheck = { |
706 | /* msgt_name = */ 2, |
707 | /* msgt_size = */ 32, |
708 | /* msgt_number = */ 1, |
709 | /* msgt_inline = */ TRUE((boolean_t) 1), |
710 | /* msgt_longform = */ FALSE((boolean_t) 0), |
711 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
712 | /* msgt_unused = */ 0 |
713 | }; |
714 | |
715 | const mach_msg_type_t pagerType = { |
716 | /* msgt_name = */ 19, |
717 | /* msgt_size = */ 32, |
718 | /* msgt_number = */ 1, |
719 | /* msgt_inline = */ TRUE((boolean_t) 1), |
720 | /* msgt_longform = */ FALSE((boolean_t) 0), |
721 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
722 | /* msgt_unused = */ 0 |
723 | }; |
724 | |
725 | #if TypeCheck1 |
726 | if (mig_unlikely ((In0P->Head.msgh_size != 56) ||__builtin_expect (!! ((In0P->Head.msgh_size != 56) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
727 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 56) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
728 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
729 | #endif /* TypeCheck */ |
730 | |
731 | #if TypeCheck1 |
732 | if (BAD_TYPECHECK(&In0P->protType, &protCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->protType); _c.t = *(& protCheck);_t.w != _c.w; })), 0)) |
733 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
734 | #endif /* TypeCheck */ |
735 | |
736 | #if TypeCheck1 |
737 | if (BAD_TYPECHECK(&In0P->offsetType, &offsetCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->offsetType); _c.t = *(& offsetCheck);_t.w != _c.w; })), 0)) |
738 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
739 | #endif /* TypeCheck */ |
740 | |
741 | #if TypeCheck1 |
742 | if (BAD_TYPECHECK(&In0P->sizeType, &sizeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->sizeType); _c.t = *(& sizeCheck);_t.w != _c.w; })), 0)) |
743 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
744 | #endif /* TypeCheck */ |
745 | |
746 | #if TypeCheck1 |
747 | if (BAD_TYPECHECK(&In0P->unmapType, &unmapCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->unmapType); _c.t = *(& unmapCheck);_t.w != _c.w; })), 0)) |
748 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
749 | #endif /* TypeCheck */ |
750 | |
751 | OutP->RetCode = ds_device_map(In0P->Head.msgh_request_portmsgh_local_port, In0P->prot, In0P->offset, In0P->size, &OutP->pager, In0P->unmap); |
752 | if (OutP->RetCode != KERN_SUCCESS0) |
753 | return; |
754 | |
755 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
756 | OutP->Head.msgh_size = 40; |
757 | |
758 | OutP->pagerType = pagerType; |
759 | } |
760 | |
761 | /* Default implementation of ds_device_map */ |
762 | #ifdef MIG_EOPNOTSUPP |
763 | kern_return_t __attribute__ ((weak)) |
764 | ds_device_map |
765 | ( |
766 | mach_port_t device, |
767 | vm_prot_t prot, |
768 | vm_offset_t offset, |
769 | vm_size_t size, |
770 | mach_port_t *pager, |
771 | int unmap |
772 | ) { return MIG_EOPNOTSUPP; } |
773 | #endif /* MIG_EOPNOTSUPP */ |
774 | |
775 | /* Routine device_set_status */ |
776 | mig_internalstatic void _Xdevice_set_status |
777 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
778 | { |
779 | typedef struct { |
780 | mach_msg_header_t Head; |
781 | mach_msg_type_t flavorType; |
782 | dev_flavor_t flavor; |
783 | mach_msg_type_t statusType; |
784 | int status[1024]; |
785 | } Request; |
786 | |
787 | typedef struct { |
788 | mach_msg_header_t Head; |
789 | mach_msg_type_t RetCodeType; |
790 | kern_return_t RetCode; |
791 | } Reply; |
792 | |
793 | Request *In0P = (Request *) InHeadP; |
794 | Reply *OutP = (Reply *) OutHeadP; |
795 | mig_external kern_return_t ds_device_set_status |
796 | (mach_port_t device, dev_flavor_t flavor, dev_status_t status, mach_msg_type_number_t statusCnt); |
797 | |
798 | unsigned int msgh_size; |
799 | |
800 | const mach_msg_type_t flavorCheck = { |
801 | /* msgt_name = */ 2, |
802 | /* msgt_size = */ 32, |
803 | /* msgt_number = */ 1, |
804 | /* msgt_inline = */ TRUE((boolean_t) 1), |
805 | /* msgt_longform = */ FALSE((boolean_t) 0), |
806 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
807 | /* msgt_unused = */ 0 |
808 | }; |
809 | |
810 | #if TypeCheck1 |
811 | msgh_size = In0P->Head.msgh_size; |
812 | if (mig_unlikely ((msgh_size < 36) ||__builtin_expect (!! ((msgh_size < 36) || (In0P->Head.msgh_bits & 0x80000000U)), 0) |
813 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((msgh_size < 36) || (In0P->Head.msgh_bits & 0x80000000U)), 0)) |
814 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
815 | #endif /* TypeCheck */ |
816 | |
817 | #if TypeCheck1 |
818 | if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->flavorType); _c.t = *(& flavorCheck);_t.w != _c.w; })), 0)) |
819 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
820 | #endif /* TypeCheck */ |
821 | |
822 | #if TypeCheck1 |
823 | if (mig_unlikely ((In0P->statusType.msgt_inline != TRUE) ||__builtin_expect (!! ((In0P->statusType.msgt_inline != ((boolean_t ) 1)) || (In0P->statusType.msgt_longform != ((boolean_t) 0 )) || (In0P->statusType.msgt_name != 2) || (In0P->statusType .msgt_size != 32)), 0) |
824 | (In0P->statusType.msgt_longform != FALSE) ||__builtin_expect (!! ((In0P->statusType.msgt_inline != ((boolean_t ) 1)) || (In0P->statusType.msgt_longform != ((boolean_t) 0 )) || (In0P->statusType.msgt_name != 2) || (In0P->statusType .msgt_size != 32)), 0) |
825 | (In0P->statusType.msgt_name != 2) ||__builtin_expect (!! ((In0P->statusType.msgt_inline != ((boolean_t ) 1)) || (In0P->statusType.msgt_longform != ((boolean_t) 0 )) || (In0P->statusType.msgt_name != 2) || (In0P->statusType .msgt_size != 32)), 0) |
826 | (In0P->statusType.msgt_size != 32))__builtin_expect (!! ((In0P->statusType.msgt_inline != ((boolean_t ) 1)) || (In0P->statusType.msgt_longform != ((boolean_t) 0 )) || (In0P->statusType.msgt_name != 2) || (In0P->statusType .msgt_size != 32)), 0)) |
827 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
828 | #endif /* TypeCheck */ |
829 | |
830 | #if TypeCheck1 |
831 | if (mig_unlikely (msgh_size != 36 + (4 * In0P->statusType.msgt_number))__builtin_expect (!! (msgh_size != 36 + (4 * In0P->statusType .msgt_number)), 0)) |
832 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
833 | #endif /* TypeCheck */ |
834 | |
835 | OutP->RetCode = ds_device_set_status(In0P->Head.msgh_request_portmsgh_local_port, In0P->flavor, In0P->status, In0P->statusType.msgt_number); |
836 | } |
837 | |
838 | /* Default implementation of ds_device_set_status */ |
839 | #ifdef MIG_EOPNOTSUPP |
840 | kern_return_t __attribute__ ((weak)) |
841 | ds_device_set_status |
842 | ( |
843 | mach_port_t device, |
844 | dev_flavor_t flavor, |
845 | dev_status_t status, |
846 | mach_msg_type_number_t statusCnt |
847 | ) { return MIG_EOPNOTSUPP; } |
848 | #endif /* MIG_EOPNOTSUPP */ |
849 | |
850 | /* Routine device_get_status */ |
851 | mig_internalstatic void _Xdevice_get_status |
852 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
853 | { |
854 | typedef struct { |
855 | mach_msg_header_t Head; |
856 | mach_msg_type_t flavorType; |
857 | dev_flavor_t flavor; |
858 | mach_msg_type_t statusCntType; |
859 | mach_msg_type_number_t statusCnt; |
860 | } Request; |
861 | |
862 | typedef struct { |
863 | mach_msg_header_t Head; |
864 | mach_msg_type_t RetCodeType; |
865 | kern_return_t RetCode; |
866 | mach_msg_type_t statusType; |
867 | int status[1024]; |
868 | } Reply; |
869 | |
870 | Request *In0P = (Request *) InHeadP; |
871 | Reply *OutP = (Reply *) OutHeadP; |
872 | mig_external kern_return_t ds_device_get_status |
873 | (mach_port_t device, dev_flavor_t flavor, dev_status_t status, mach_msg_type_number_t *statusCnt); |
874 | |
875 | const mach_msg_type_t flavorCheck = { |
876 | /* msgt_name = */ 2, |
877 | /* msgt_size = */ 32, |
878 | /* msgt_number = */ 1, |
879 | /* msgt_inline = */ TRUE((boolean_t) 1), |
880 | /* msgt_longform = */ FALSE((boolean_t) 0), |
881 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
882 | /* msgt_unused = */ 0 |
883 | }; |
884 | |
885 | const mach_msg_type_t statusCntCheck = { |
886 | /* msgt_name = */ MACH_MSG_TYPE_INTEGER_322, |
887 | /* msgt_size = */ 32, |
888 | /* msgt_number = */ 1, |
889 | /* msgt_inline = */ TRUE((boolean_t) 1), |
890 | /* msgt_longform = */ FALSE((boolean_t) 0), |
891 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
892 | /* msgt_unused = */ 0 |
893 | }; |
894 | |
895 | const mach_msg_type_t statusType = { |
896 | /* msgt_name = */ 2, |
897 | /* msgt_size = */ 32, |
898 | /* msgt_number = */ 1024, |
899 | /* msgt_inline = */ TRUE((boolean_t) 1), |
900 | /* msgt_longform = */ FALSE((boolean_t) 0), |
901 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
902 | /* msgt_unused = */ 0 |
903 | }; |
904 | |
905 | mach_msg_type_number_t statusCnt; |
906 | |
907 | #if TypeCheck1 |
908 | if (mig_unlikely ((In0P->Head.msgh_size != 40) ||__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P ->Head.msgh_bits & 0x80000000U)), 0) |
909 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P ->Head.msgh_bits & 0x80000000U)), 0)) |
910 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
911 | #endif /* TypeCheck */ |
912 | |
913 | #if TypeCheck1 |
914 | if (BAD_TYPECHECK(&In0P->flavorType, &flavorCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->flavorType); _c.t = *(& flavorCheck);_t.w != _c.w; })), 0)) |
915 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
916 | #endif /* TypeCheck */ |
917 | |
918 | #if TypeCheck1 |
919 | if (BAD_TYPECHECK(&In0P->statusCntType, &statusCntCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->statusCntType); _c.t = * (&statusCntCheck);_t.w != _c.w; })), 0)) |
920 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
921 | #endif /* TypeCheck */ |
922 | |
923 | statusCnt = 1024; |
924 | if (In0P->statusCnt < statusCnt) |
925 | statusCnt = In0P->statusCnt; |
926 | |
927 | OutP->RetCode = ds_device_get_status(In0P->Head.msgh_request_portmsgh_local_port, In0P->flavor, OutP->status, &statusCnt); |
928 | if (OutP->RetCode != KERN_SUCCESS0) |
929 | return; |
930 | |
931 | OutP->statusType = statusType; |
932 | |
933 | OutP->statusType.msgt_number = statusCnt; |
934 | OutP->Head.msgh_size = 36 + (4 * statusCnt); |
935 | } |
936 | |
937 | /* Default implementation of ds_device_get_status */ |
938 | #ifdef MIG_EOPNOTSUPP |
939 | kern_return_t __attribute__ ((weak)) |
940 | ds_device_get_status |
941 | ( |
942 | mach_port_t device, |
943 | dev_flavor_t flavor, |
944 | dev_status_t status, |
945 | mach_msg_type_number_t *statusCnt |
946 | ) { return MIG_EOPNOTSUPP; } |
947 | #endif /* MIG_EOPNOTSUPP */ |
948 | |
949 | /* Routine device_set_filter */ |
950 | mig_internalstatic void _Xdevice_set_filter |
951 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
952 | { |
953 | typedef struct { |
954 | mach_msg_header_t Head; |
955 | mach_msg_type_t receive_portType; |
956 | mach_port_t receive_port; |
957 | mach_msg_type_t priorityType; |
958 | int priority; |
959 | mach_msg_type_t filterType; |
960 | filter_t filter[128]; |
961 | } Request; |
962 | |
963 | typedef struct { |
964 | mach_msg_header_t Head; |
965 | mach_msg_type_t RetCodeType; |
966 | kern_return_t RetCode; |
967 | } Reply; |
968 | |
969 | Request *In0P = (Request *) InHeadP; |
970 | Reply *OutP = (Reply *) OutHeadP; |
971 | mig_external kern_return_t ds_device_set_filter |
972 | (mach_port_t device, mach_port_t receive_port, int priority, filter_array_t filter, mach_msg_type_number_t filterCnt); |
973 | |
974 | unsigned int msgh_size; |
975 | |
976 | const mach_msg_type_t receive_portCheck = { |
977 | /* msgt_name = */ 17, |
978 | /* msgt_size = */ 32, |
979 | /* msgt_number = */ 1, |
980 | /* msgt_inline = */ TRUE((boolean_t) 1), |
981 | /* msgt_longform = */ FALSE((boolean_t) 0), |
982 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
983 | /* msgt_unused = */ 0 |
984 | }; |
985 | |
986 | const mach_msg_type_t priorityCheck = { |
987 | /* msgt_name = */ 2, |
988 | /* msgt_size = */ 32, |
989 | /* msgt_number = */ 1, |
990 | /* msgt_inline = */ TRUE((boolean_t) 1), |
991 | /* msgt_longform = */ FALSE((boolean_t) 0), |
992 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
993 | /* msgt_unused = */ 0 |
994 | }; |
995 | |
996 | #if TypeCheck1 |
997 | msgh_size = In0P->Head.msgh_size; |
998 | if (mig_unlikely ((msgh_size < 44) ||__builtin_expect (!! ((msgh_size < 44) || !(In0P->Head. msgh_bits & 0x80000000U)), 0) |
999 | !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((msgh_size < 44) || !(In0P->Head. msgh_bits & 0x80000000U)), 0)) |
1000 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1001 | #endif /* TypeCheck */ |
1002 | |
1003 | #if TypeCheck1 |
1004 | if (BAD_TYPECHECK(&In0P->receive_portType, &receive_portCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->receive_portType); _c.t = *(&receive_portCheck);_t.w != _c.w; })), 0)) |
1005 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1006 | #endif /* TypeCheck */ |
1007 | |
1008 | #if TypeCheck1 |
1009 | if (BAD_TYPECHECK(&In0P->priorityType, &priorityCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->priorityType); _c.t = *( &priorityCheck);_t.w != _c.w; })), 0)) |
1010 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1011 | #endif /* TypeCheck */ |
1012 | |
1013 | #if TypeCheck1 |
1014 | if (mig_unlikely ((In0P->filterType.msgt_inline != TRUE) ||__builtin_expect (!! ((In0P->filterType.msgt_inline != ((boolean_t ) 1)) || (In0P->filterType.msgt_longform != ((boolean_t) 0 )) || (In0P->filterType.msgt_name != 1) || (In0P->filterType .msgt_size != 16)), 0) |
1015 | (In0P->filterType.msgt_longform != FALSE) ||__builtin_expect (!! ((In0P->filterType.msgt_inline != ((boolean_t ) 1)) || (In0P->filterType.msgt_longform != ((boolean_t) 0 )) || (In0P->filterType.msgt_name != 1) || (In0P->filterType .msgt_size != 16)), 0) |
1016 | (In0P->filterType.msgt_name != 1) ||__builtin_expect (!! ((In0P->filterType.msgt_inline != ((boolean_t ) 1)) || (In0P->filterType.msgt_longform != ((boolean_t) 0 )) || (In0P->filterType.msgt_name != 1) || (In0P->filterType .msgt_size != 16)), 0) |
1017 | (In0P->filterType.msgt_size != 16))__builtin_expect (!! ((In0P->filterType.msgt_inline != ((boolean_t ) 1)) || (In0P->filterType.msgt_longform != ((boolean_t) 0 )) || (In0P->filterType.msgt_name != 1) || (In0P->filterType .msgt_size != 16)), 0)) |
1018 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1019 | #endif /* TypeCheck */ |
1020 | |
1021 | #if TypeCheck1 |
1022 | if (mig_unlikely (msgh_size != 44 + ((2 * In0P->filterType.msgt_number + 3) & ~3))__builtin_expect (!! (msgh_size != 44 + ((2 * In0P->filterType .msgt_number + 3) & ~3)), 0)) |
1023 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
1024 | #endif /* TypeCheck */ |
1025 | |
1026 | OutP->RetCode = ds_device_set_filter(In0P->Head.msgh_request_portmsgh_local_port, In0P->receive_port, In0P->priority, In0P->filter, In0P->filterType.msgt_number); |
1027 | } |
1028 | |
1029 | /* Default implementation of ds_device_set_filter */ |
1030 | #ifdef MIG_EOPNOTSUPP |
1031 | kern_return_t __attribute__ ((weak)) |
1032 | ds_device_set_filter |
1033 | ( |
1034 | mach_port_t device, |
1035 | mach_port_t receive_port, |
1036 | int priority, |
1037 | filter_array_t filter, |
1038 | mach_msg_type_number_t filterCnt |
1039 | ) { return MIG_EOPNOTSUPP; } |
1040 | #endif /* MIG_EOPNOTSUPP */ |
1041 | |
1042 | mig_routine_t device_server_routines[] = { |
1043 | _Xdevice_open, |
1044 | _Xdevice_close, |
1045 | _Xdevice_write, |
1046 | _Xdevice_write_inband, |
1047 | _Xdevice_read, |
1048 | _Xdevice_read_inband, |
1049 | 0, |
1050 | 0, |
1051 | 0, |
1052 | _Xdevice_map, |
1053 | _Xdevice_set_status, |
1054 | _Xdevice_get_status, |
1055 | _Xdevice_set_filter, |
1056 | }; |
1057 | |
1058 | mig_external boolean_t device_server |
1059 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
1060 | { |
1061 | mach_msg_header_t *InP = InHeadP; |
1062 | mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; |
1063 | |
1064 | const mach_msg_type_t RetCodeType = { |
1065 | /* msgt_name = */ MACH_MSG_TYPE_INTEGER_322, |
1066 | /* msgt_size = */ 32, |
1067 | /* msgt_number = */ 1, |
1068 | /* msgt_inline = */ TRUE((boolean_t) 1), |
1069 | /* msgt_longform = */ FALSE((boolean_t) 0), |
1070 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
1071 | /* msgt_unused = */ 0 |
1072 | }; |
1073 | |
1074 | mig_routine_t routine; |
1075 | |
1076 | OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0)((((InP->msgh_bits) & 0x000000ff)) | ((0) << 8)); |
1077 | OutP->Head.msgh_size = sizeof *OutP; |
1078 | OutP->Head.msgh_remote_port = InP->msgh_reply_portmsgh_remote_port; |
1079 | OutP->Head.msgh_local_port = MACH_PORT_NULL((mach_port_t) 0); |
1080 | OutP->Head.msgh_seqno = 0; |
1081 | OutP->Head.msgh_id = InP->msgh_id + 100; |
1082 | |
1083 | OutP->RetCodeType = RetCodeType; |
1084 | |
1085 | if ((InP->msgh_id > 2812) || (InP->msgh_id < 2800) || |
1086 | ((routine = device_server_routines[InP->msgh_id - 2800]) == 0)) { |
1087 | OutP->RetCode = MIG_BAD_ID-303; |
1088 | return FALSE((boolean_t) 0); |
1089 | } |
1090 | (*routine) (InP, &OutP->Head); |
1091 | return TRUE((boolean_t) 1); |
1092 | } |
1093 | |
1094 | mig_external mig_routine_t device_server_routine |
1095 | (const mach_msg_header_t *InHeadP) |
1096 | { |
1097 | int msgh_id; |
1098 | |
1099 | msgh_id = InHeadP->msgh_id - 2800; |
1100 | |
1101 | if ((msgh_id > 12) || (msgh_id < 0)) |
1102 | return 0; |
1103 | |
1104 | return device_server_routines[msgh_id]; |
1105 | } |
1106 |