File: | obj-scan-build/i386/i386/mach_i386.server.c |
Location: | line 97, column 2 |
Description: | Value stored to 'msgh_simple' is never read |
1 | /* Module mach_i386 */ |
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 | #include <ipc/ipc_port.h> |
14 | |
15 | #ifndef mig_internalstatic |
16 | #define mig_internalstatic static |
17 | #endif |
18 | |
19 | #ifndef mig_external |
20 | #define mig_external |
21 | #endif |
22 | |
23 | #ifndef TypeCheck1 |
24 | #define TypeCheck1 1 |
25 | #endif |
26 | |
27 | #ifndef UseExternRCSId1 |
28 | #define UseExternRCSId1 1 |
29 | #endif |
30 | |
31 | #define BAD_TYPECHECK(type, check)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) ({\ |
32 | union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ |
33 | _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) |
34 | #define msgh_request_portmsgh_remote_port msgh_remote_port |
35 | #define MACH_MSGH_BITS_REQUEST(bits)((bits) & 0x000000ff) MACH_MSGH_BITS_REMOTE(bits)((bits) & 0x000000ff) |
36 | #define msgh_reply_portmsgh_local_port msgh_local_port |
37 | #define MACH_MSGH_BITS_REPLY(bits)(((bits) & 0x0000ff00) >> 8) MACH_MSGH_BITS_LOCAL(bits)(((bits) & 0x0000ff00) >> 8) |
38 | |
39 | #include <mach/std_types.h> |
40 | #include <kern/ipc_kobject.h> |
41 | #include <kern/ipc_tt.h> |
42 | #include <kern/ipc_host.h> |
43 | #include <kern/task.h> |
44 | #include <kern/thread.h> |
45 | #include <kern/host.h> |
46 | #include <kern/processor.h> |
47 | #include <vm/vm_object.h> |
48 | #include <vm/vm_map.h> |
49 | #include <ipc/ipc_space.h> |
50 | #include <mach/mach_types.h> |
51 | #include <mach/machine/mach_i386_types.h> |
52 | #include <machine/io_perm.h> |
53 | |
54 | /* Routine i386_set_ldt */ |
55 | mig_internalstatic void _Xi386_set_ldt |
56 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
57 | { |
58 | typedef struct { |
59 | mach_msg_header_t Head; |
60 | mach_msg_type_t first_selectorType; |
61 | int first_selector; |
62 | mach_msg_type_long_t desc_listType; |
63 | descriptor_t desc_list[256]; |
64 | } Request; |
65 | |
66 | typedef struct { |
67 | mach_msg_header_t Head; |
68 | mach_msg_type_t RetCodeType; |
69 | kern_return_t RetCode; |
70 | } Reply; |
71 | |
72 | Request *In0P = (Request *) InHeadP; |
73 | Reply *OutP = (Reply *) OutHeadP; |
74 | mig_external kern_return_t i386_set_ldt |
75 | (thread_t target_thread, int first_selector, descriptor_list_t desc_list, mach_msg_type_number_t desc_listCnt, boolean_t desc_listSCopy); |
76 | |
77 | #if TypeCheck1 |
78 | boolean_t msgh_simple; |
79 | #endif /* TypeCheck */ |
80 | |
81 | unsigned int msgh_size; |
82 | |
83 | const mach_msg_type_t first_selectorCheck = { |
84 | /* msgt_name = */ 2, |
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 | thread_t target_thread; |
94 | |
95 | #if TypeCheck1 |
96 | msgh_size = In0P->Head.msgh_size; |
97 | msgh_simple = !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U); |
Value stored to 'msgh_simple' is never read | |
98 | if ((msgh_size < 44)) |
99 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
100 | #endif /* TypeCheck */ |
101 | |
102 | #if TypeCheck1 |
103 | if (BAD_TYPECHECK(&In0P->first_selectorType, &first_selectorCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->first_selectorType); _c.t = *(&first_selectorCheck ); _t.w != _c.w; })) |
104 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
105 | #endif /* TypeCheck */ |
106 | |
107 | #if TypeCheck1 |
108 | if ((In0P->desc_listType.msgtl_header.msgt_longform != TRUE((boolean_t) 1)) || |
109 | (In0P->desc_listType.msgtl_name != 2) || |
110 | (In0P->desc_listType.msgtl_size != 32)) |
111 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
112 | #endif /* TypeCheck */ |
113 | |
114 | #if TypeCheck1 |
115 | if (msgh_size != 44 + ((In0P->desc_listType.msgtl_header.msgt_inline) ? 4 * In0P->desc_listType.msgtl_number : sizeof(descriptor_t *))) |
116 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
117 | #endif /* TypeCheck */ |
118 | |
119 | target_thread = convert_port_to_thread((ipc_port_t) In0P->Head.msgh_request_portmsgh_remote_port); |
120 | |
121 | OutP->RetCode = i386_set_ldt(target_thread, In0P->first_selector, (In0P->desc_listType.msgtl_header.msgt_inline) ? In0P->desc_list : *((descriptor_t **)In0P->desc_list), In0P->desc_listType.msgtl_number / 2, In0P->desc_listType.msgtl_header.msgt_inline); |
122 | thread_deallocate(target_thread); |
123 | } |
124 | |
125 | /* Routine i386_get_ldt */ |
126 | mig_internalstatic void _Xi386_get_ldt |
127 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
128 | { |
129 | typedef struct { |
130 | mach_msg_header_t Head; |
131 | mach_msg_type_t first_selectorType; |
132 | int first_selector; |
133 | mach_msg_type_t selector_countType; |
134 | int selector_count; |
135 | } Request; |
136 | |
137 | typedef struct { |
138 | mach_msg_header_t Head; |
139 | mach_msg_type_t RetCodeType; |
140 | kern_return_t RetCode; |
141 | mach_msg_type_long_t desc_listType; |
142 | descriptor_t desc_list[256]; |
143 | } Reply; |
144 | |
145 | Request *In0P = (Request *) InHeadP; |
146 | Reply *OutP = (Reply *) OutHeadP; |
147 | mig_external kern_return_t i386_get_ldt |
148 | (thread_t target_thread, int first_selector, int selector_count, descriptor_list_t *desc_list, mach_msg_type_number_t *desc_listCnt); |
149 | |
150 | boolean_t msgh_simple; |
151 | const mach_msg_type_t first_selectorCheck = { |
152 | /* msgt_name = */ 2, |
153 | /* msgt_size = */ 32, |
154 | /* msgt_number = */ 1, |
155 | /* msgt_inline = */ TRUE((boolean_t) 1), |
156 | /* msgt_longform = */ FALSE((boolean_t) 0), |
157 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
158 | /* msgt_unused = */ 0 |
159 | }; |
160 | |
161 | const mach_msg_type_t selector_countCheck = { |
162 | /* msgt_name = */ 2, |
163 | /* msgt_size = */ 32, |
164 | /* msgt_number = */ 1, |
165 | /* msgt_inline = */ TRUE((boolean_t) 1), |
166 | /* msgt_longform = */ FALSE((boolean_t) 0), |
167 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
168 | /* msgt_unused = */ 0 |
169 | }; |
170 | |
171 | const mach_msg_type_long_t desc_listType = { |
172 | { |
173 | /* msgt_name = */ 0, |
174 | /* msgt_size = */ 0, |
175 | /* msgt_number = */ 0, |
176 | /* msgt_inline = */ TRUE((boolean_t) 1), |
177 | /* msgt_longform = */ TRUE((boolean_t) 1), |
178 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
179 | /* msgt_unused = */ 0 |
180 | }, |
181 | /* msgtl_name = */ 2, |
182 | /* msgtl_size = */ 32, |
183 | /* msgtl_number = */ 512, |
184 | }; |
185 | |
186 | thread_t target_thread; |
187 | mach_msg_type_number_t desc_listCnt; |
188 | |
189 | descriptor_t *desc_listP; |
190 | |
191 | #if TypeCheck1 |
192 | if ((In0P->Head.msgh_size != 40) || |
193 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U)) |
194 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
195 | #endif /* TypeCheck */ |
196 | |
197 | #if TypeCheck1 |
198 | if (BAD_TYPECHECK(&In0P->first_selectorType, &first_selectorCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->first_selectorType); _c.t = *(&first_selectorCheck ); _t.w != _c.w; })) |
199 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
200 | #endif /* TypeCheck */ |
201 | |
202 | #if TypeCheck1 |
203 | if (BAD_TYPECHECK(&In0P->selector_countType, &selector_countCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->selector_countType); _c.t = *(&selector_countCheck ); _t.w != _c.w; })) |
204 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
205 | #endif /* TypeCheck */ |
206 | |
207 | target_thread = convert_port_to_thread((ipc_port_t) In0P->Head.msgh_request_portmsgh_remote_port); |
208 | |
209 | desc_listP = OutP->desc_list; |
210 | desc_listCnt = 256; |
211 | |
212 | OutP->RetCode = i386_get_ldt(target_thread, In0P->first_selector, In0P->selector_count, &desc_listP, &desc_listCnt); |
213 | thread_deallocate(target_thread); |
214 | if (OutP->RetCode != KERN_SUCCESS0) |
215 | return; |
216 | |
217 | msgh_simple = TRUE((boolean_t) 1); |
218 | |
219 | OutP->desc_listType = desc_listType; |
220 | if (desc_listP != OutP->desc_list) { |
221 | OutP->desc_listType.msgtl_header.msgt_inline = FALSE((boolean_t) 0); |
222 | *((descriptor_t **)OutP->desc_list) = desc_listP; |
223 | msgh_simple = FALSE((boolean_t) 0); |
224 | } |
225 | |
226 | OutP->desc_listType.msgtl_number = 2 * desc_listCnt; |
227 | OutP->Head.msgh_size = 44 + ((OutP->desc_listType.msgtl_header.msgt_inline) ? 8 * desc_listCnt : sizeof(descriptor_t *)); |
228 | |
229 | if (!msgh_simple) |
230 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
231 | } |
232 | |
233 | /* Routine i386_io_perm_create */ |
234 | mig_internalstatic void _Xi386_io_perm_create |
235 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
236 | { |
237 | typedef struct { |
238 | mach_msg_header_t Head; |
239 | mach_msg_type_t fromType; |
240 | io_port_t from; |
241 | char fromPad[2]; |
242 | mach_msg_type_t toType; |
243 | io_port_t to; |
244 | char toPad[2]; |
245 | } Request; |
246 | |
247 | typedef struct { |
248 | mach_msg_header_t Head; |
249 | mach_msg_type_t RetCodeType; |
250 | kern_return_t RetCode; |
251 | mach_msg_type_t io_permType; |
252 | ipc_port_t io_perm; |
253 | } Reply; |
254 | |
255 | Request *In0P = (Request *) InHeadP; |
256 | Reply *OutP = (Reply *) OutHeadP; |
257 | mig_external kern_return_t i386_io_perm_create |
258 | (ipc_port_t master_port, io_port_t from, io_port_t to, io_perm_t *io_perm); |
259 | |
260 | const mach_msg_type_t fromCheck = { |
261 | /* msgt_name = */ 1, |
262 | /* msgt_size = */ 16, |
263 | /* msgt_number = */ 1, |
264 | /* msgt_inline = */ TRUE((boolean_t) 1), |
265 | /* msgt_longform = */ FALSE((boolean_t) 0), |
266 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
267 | /* msgt_unused = */ 0 |
268 | }; |
269 | |
270 | const mach_msg_type_t toCheck = { |
271 | /* msgt_name = */ 1, |
272 | /* msgt_size = */ 16, |
273 | /* msgt_number = */ 1, |
274 | /* msgt_inline = */ TRUE((boolean_t) 1), |
275 | /* msgt_longform = */ FALSE((boolean_t) 0), |
276 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
277 | /* msgt_unused = */ 0 |
278 | }; |
279 | |
280 | const mach_msg_type_t io_permType = { |
281 | /* msgt_name = */ 17, |
282 | /* msgt_size = */ 32, |
283 | /* msgt_number = */ 1, |
284 | /* msgt_inline = */ TRUE((boolean_t) 1), |
285 | /* msgt_longform = */ FALSE((boolean_t) 0), |
286 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
287 | /* msgt_unused = */ 0 |
288 | }; |
289 | |
290 | io_perm_t io_perm; |
291 | |
292 | #if TypeCheck1 |
293 | if ((In0P->Head.msgh_size != 40) || |
294 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U)) |
295 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
296 | #endif /* TypeCheck */ |
297 | |
298 | #if TypeCheck1 |
299 | if (BAD_TYPECHECK(&In0P->fromType, &fromCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->fromType); _c.t = *(&fromCheck); _t.w != _c.w; })) |
300 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
301 | #endif /* TypeCheck */ |
302 | |
303 | #if TypeCheck1 |
304 | if (BAD_TYPECHECK(&In0P->toType, &toCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->toType); _c.t = *(&toCheck); _t.w != _c. w; })) |
305 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
306 | #endif /* TypeCheck */ |
307 | |
308 | OutP->RetCode = i386_io_perm_create((ipc_port_t) In0P->Head.msgh_request_portmsgh_remote_port, In0P->from, In0P->to, &io_perm); |
309 | if (OutP->RetCode != KERN_SUCCESS0) |
310 | return; |
311 | |
312 | OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U; |
313 | OutP->Head.msgh_size = 40; |
314 | |
315 | OutP->io_permType = io_permType; |
316 | |
317 | OutP->io_perm = convert_io_perm_to_port(io_perm); |
318 | } |
319 | |
320 | /* Routine i386_io_perm_modify */ |
321 | mig_internalstatic void _Xi386_io_perm_modify |
322 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
323 | { |
324 | typedef struct { |
325 | mach_msg_header_t Head; |
326 | mach_msg_type_t io_permType; |
327 | ipc_port_t io_perm; |
328 | mach_msg_type_t enableType; |
329 | boolean_t enable; |
330 | } Request; |
331 | |
332 | typedef struct { |
333 | mach_msg_header_t Head; |
334 | mach_msg_type_t RetCodeType; |
335 | kern_return_t RetCode; |
336 | } Reply; |
337 | |
338 | Request *In0P = (Request *) InHeadP; |
339 | Reply *OutP = (Reply *) OutHeadP; |
340 | mig_external kern_return_t i386_io_perm_modify |
341 | (task_t target_task, io_perm_t io_perm, boolean_t enable); |
342 | |
343 | const mach_msg_type_t enableCheck = { |
344 | /* msgt_name = */ 0, |
345 | /* msgt_size = */ 32, |
346 | /* msgt_number = */ 1, |
347 | /* msgt_inline = */ TRUE((boolean_t) 1), |
348 | /* msgt_longform = */ FALSE((boolean_t) 0), |
349 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
350 | /* msgt_unused = */ 0 |
351 | }; |
352 | |
353 | task_t target_task; |
354 | |
355 | #if TypeCheck1 |
356 | if ((In0P->Head.msgh_size != 40) || |
357 | !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U)) |
358 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
359 | #endif /* TypeCheck */ |
360 | |
361 | #if TypeCheck1 |
362 | if ((In0P->io_permType.msgt_inline != TRUE((boolean_t) 1)) || |
363 | (In0P->io_permType.msgt_longform != FALSE((boolean_t) 0)) || |
364 | (In0P->io_permType.msgt_name != 17) || |
365 | (In0P->io_permType.msgt_number != 1) || |
366 | (In0P->io_permType.msgt_size != 32)) |
367 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
368 | #endif /* TypeCheck */ |
369 | |
370 | #if TypeCheck1 |
371 | if (BAD_TYPECHECK(&In0P->enableType, &enableCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->enableType); _c.t = *(&enableCheck); _t. w != _c.w; })) |
372 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
373 | #endif /* TypeCheck */ |
374 | |
375 | target_task = convert_port_to_task((ipc_port_t) In0P->Head.msgh_request_portmsgh_remote_port); |
376 | |
377 | OutP->RetCode = i386_io_perm_modify(target_task, convert_port_to_io_perm(In0P->io_perm), In0P->enable); |
378 | task_deallocate(target_task); |
379 | if (OutP->RetCode != KERN_SUCCESS0) |
380 | return; |
381 | |
382 | if (IP_VALID(In0P->io_perm)(((&(In0P->io_perm)->ip_target.ipt_object) != ((ipc_object_t ) 0)) && ((&(In0P->io_perm)->ip_target.ipt_object ) != ((ipc_object_t) -1)))) |
383 | ipc_port_release_send(In0P->io_perm); |
384 | } |
385 | |
386 | /* Routine i386_set_gdt */ |
387 | mig_internalstatic void _Xi386_set_gdt |
388 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
389 | { |
390 | typedef struct { |
391 | mach_msg_header_t Head; |
392 | mach_msg_type_t selectorType; |
393 | int selector; |
394 | mach_msg_type_t descType; |
395 | descriptor_t desc; |
396 | } Request; |
397 | |
398 | typedef struct { |
399 | mach_msg_header_t Head; |
400 | mach_msg_type_t RetCodeType; |
401 | kern_return_t RetCode; |
402 | mach_msg_type_t selectorType; |
403 | int selector; |
404 | } Reply; |
405 | |
406 | Request *In0P = (Request *) InHeadP; |
407 | Reply *OutP = (Reply *) OutHeadP; |
408 | mig_external kern_return_t i386_set_gdt |
409 | (thread_t target_thread, int *selector, descriptor_t desc); |
410 | |
411 | const mach_msg_type_t selectorCheck = { |
412 | /* msgt_name = */ 2, |
413 | /* msgt_size = */ 32, |
414 | /* msgt_number = */ 1, |
415 | /* msgt_inline = */ TRUE((boolean_t) 1), |
416 | /* msgt_longform = */ FALSE((boolean_t) 0), |
417 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
418 | /* msgt_unused = */ 0 |
419 | }; |
420 | |
421 | const mach_msg_type_t descCheck = { |
422 | /* msgt_name = */ 2, |
423 | /* msgt_size = */ 32, |
424 | /* msgt_number = */ 2, |
425 | /* msgt_inline = */ TRUE((boolean_t) 1), |
426 | /* msgt_longform = */ FALSE((boolean_t) 0), |
427 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
428 | /* msgt_unused = */ 0 |
429 | }; |
430 | |
431 | const mach_msg_type_t selectorType = { |
432 | /* msgt_name = */ 2, |
433 | /* msgt_size = */ 32, |
434 | /* msgt_number = */ 1, |
435 | /* msgt_inline = */ TRUE((boolean_t) 1), |
436 | /* msgt_longform = */ FALSE((boolean_t) 0), |
437 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
438 | /* msgt_unused = */ 0 |
439 | }; |
440 | |
441 | thread_t target_thread; |
442 | |
443 | #if TypeCheck1 |
444 | if ((In0P->Head.msgh_size != 44) || |
445 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U)) |
446 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
447 | #endif /* TypeCheck */ |
448 | |
449 | #if TypeCheck1 |
450 | if (BAD_TYPECHECK(&In0P->selectorType, &selectorCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->selectorType); _c.t = *(&selectorCheck); _t.w != _c.w; })) |
451 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
452 | #endif /* TypeCheck */ |
453 | |
454 | #if TypeCheck1 |
455 | if (BAD_TYPECHECK(&In0P->descType, &descCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->descType); _c.t = *(&descCheck); _t.w != _c.w; })) |
456 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
457 | #endif /* TypeCheck */ |
458 | |
459 | target_thread = convert_port_to_thread((ipc_port_t) In0P->Head.msgh_request_portmsgh_remote_port); |
460 | |
461 | OutP->RetCode = i386_set_gdt(target_thread, &In0P->selector, In0P->desc); |
462 | thread_deallocate(target_thread); |
463 | if (OutP->RetCode != KERN_SUCCESS0) |
464 | return; |
465 | |
466 | OutP->Head.msgh_size = 40; |
467 | |
468 | OutP->selectorType = selectorType; |
469 | |
470 | OutP->selector = In0P->selector; |
471 | } |
472 | |
473 | /* Routine i386_get_gdt */ |
474 | mig_internalstatic void _Xi386_get_gdt |
475 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
476 | { |
477 | typedef struct { |
478 | mach_msg_header_t Head; |
479 | mach_msg_type_t selectorType; |
480 | int selector; |
481 | } Request; |
482 | |
483 | typedef struct { |
484 | mach_msg_header_t Head; |
485 | mach_msg_type_t RetCodeType; |
486 | kern_return_t RetCode; |
487 | mach_msg_type_t descType; |
488 | descriptor_t desc; |
489 | } Reply; |
490 | |
491 | Request *In0P = (Request *) InHeadP; |
492 | Reply *OutP = (Reply *) OutHeadP; |
493 | mig_external kern_return_t i386_get_gdt |
494 | (thread_t target_thread, int selector, descriptor_t *desc); |
495 | |
496 | const mach_msg_type_t selectorCheck = { |
497 | /* msgt_name = */ 2, |
498 | /* msgt_size = */ 32, |
499 | /* msgt_number = */ 1, |
500 | /* msgt_inline = */ TRUE((boolean_t) 1), |
501 | /* msgt_longform = */ FALSE((boolean_t) 0), |
502 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
503 | /* msgt_unused = */ 0 |
504 | }; |
505 | |
506 | const mach_msg_type_t descType = { |
507 | /* msgt_name = */ 2, |
508 | /* msgt_size = */ 32, |
509 | /* msgt_number = */ 2, |
510 | /* msgt_inline = */ TRUE((boolean_t) 1), |
511 | /* msgt_longform = */ FALSE((boolean_t) 0), |
512 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
513 | /* msgt_unused = */ 0 |
514 | }; |
515 | |
516 | thread_t target_thread; |
517 | |
518 | #if TypeCheck1 |
519 | if ((In0P->Head.msgh_size != 32) || |
520 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U)) |
521 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
522 | #endif /* TypeCheck */ |
523 | |
524 | #if TypeCheck1 |
525 | if (BAD_TYPECHECK(&In0P->selectorType, &selectorCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->selectorType); _c.t = *(&selectorCheck); _t.w != _c.w; })) |
526 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
527 | #endif /* TypeCheck */ |
528 | |
529 | target_thread = convert_port_to_thread((ipc_port_t) In0P->Head.msgh_request_portmsgh_remote_port); |
530 | |
531 | OutP->RetCode = i386_get_gdt(target_thread, In0P->selector, &OutP->desc); |
532 | thread_deallocate(target_thread); |
533 | if (OutP->RetCode != KERN_SUCCESS0) |
534 | return; |
535 | |
536 | OutP->Head.msgh_size = 44; |
537 | |
538 | OutP->descType = descType; |
539 | } |
540 | |
541 | mig_routine_t mach_i386_server_routines[] = { |
542 | 0, |
543 | 0, |
544 | 0, |
545 | _Xi386_set_ldt, |
546 | _Xi386_get_ldt, |
547 | _Xi386_io_perm_create, |
548 | _Xi386_io_perm_modify, |
549 | _Xi386_set_gdt, |
550 | _Xi386_get_gdt, |
551 | }; |
552 | |
553 | mig_external boolean_t mach_i386_server |
554 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
555 | { |
556 | mach_msg_header_t *InP = InHeadP; |
557 | mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; |
558 | |
559 | const mach_msg_type_t RetCodeType = { |
560 | /* msgt_name = */ MACH_MSG_TYPE_INTEGER_322, |
561 | /* msgt_size = */ 32, |
562 | /* msgt_number = */ 1, |
563 | /* msgt_inline = */ TRUE((boolean_t) 1), |
564 | /* msgt_longform = */ FALSE((boolean_t) 0), |
565 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
566 | /* msgt_unused = */ 0 |
567 | }; |
568 | |
569 | mig_routine_t routine; |
570 | |
571 | OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0)(((((InP->msgh_bits) & 0x0000ff00) >> 8)) | ((0) << 8)); |
572 | OutP->Head.msgh_size = sizeof *OutP; |
573 | OutP->Head.msgh_remote_port = InP->msgh_reply_portmsgh_local_port; |
574 | OutP->Head.msgh_local_port = MACH_PORT_NULL((mach_port_t) 0); |
575 | OutP->Head.msgh_seqno = 0; |
576 | OutP->Head.msgh_id = InP->msgh_id + 100; |
577 | |
578 | OutP->RetCodeType = RetCodeType; |
579 | |
580 | if ((InP->msgh_id > 3808) || (InP->msgh_id < 3800) || |
581 | ((routine = mach_i386_server_routines[InP->msgh_id - 3800]) == 0)) { |
582 | OutP->RetCode = MIG_BAD_ID-303; |
583 | return FALSE((boolean_t) 0); |
584 | } |
585 | (*routine) (InP, &OutP->Head); |
586 | return TRUE((boolean_t) 1); |
587 | } |
588 | |
589 | mig_external mig_routine_t mach_i386_server_routine |
590 | (const mach_msg_header_t *InHeadP) |
591 | { |
592 | int msgh_id; |
593 | |
594 | msgh_id = InHeadP->msgh_id - 3800; |
595 | |
596 | if ((msgh_id > 8) || (msgh_id < 0)) |
597 | return 0; |
598 | |
599 | return mach_i386_server_routines[msgh_id]; |
600 | } |
601 |