1#ifndef _processor_server_
2#define _processor_server_
3
4/* Module processor */
5
6#include <string.h>
7#include <mach/ndr.h>
8#include <mach/boolean.h>
9#include <mach/kern_return.h>
10#include <mach/notify.h>
11#include <mach/mach_types.h>
12#include <mach/message.h>
13#include <mach/mig_errors.h>
14#include <mach/port.h>
15
16/* BEGIN MIG_STRNCPY_ZEROFILL CODE */
17
18#if defined(__has_include)
19#if __has_include(<mach/mig_strncpy_zerofill_support.h>)
20#ifndef USING_MIG_STRNCPY_ZEROFILL
21#define USING_MIG_STRNCPY_ZEROFILL
22#endif
23#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
24#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__
25#ifdef __cplusplus
26extern "C" {
27#endif
28#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS_CSTRING_ATTR
29#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS_CSTRING_COUNTEDBY_ATTR(C) __unsafe_indexable
30#endif
31 extern int mig_strncpy_zerofill(char * dest, const char * src, int len) __attribute__((weak_import));
32#ifdef __cplusplus
33}
34#endif
35#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */
36#endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */
37#endif /* __has_include */
38
39/* END MIG_STRNCPY_ZEROFILL CODE */
40
41
42#ifdef AUTOTEST
43#ifndef FUNCTION_PTR_T
44#define FUNCTION_PTR_T
45typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t);
46typedef struct {
47 char * name;
48 function_ptr_t function;
49} function_table_entry;
50typedef function_table_entry *function_table_t;
51#endif /* FUNCTION_PTR_T */
52#endif /* AUTOTEST */
53
54#ifndef processor_MSG_COUNT
55#define processor_MSG_COUNT 6
56#endif /* processor_MSG_COUNT */
57
58#include <Availability.h>
59#include <mach/std_types.h>
60#include <mach/mig.h>
61#include <ipc/ipc_voucher.h>
62#include <kern/ipc_kobject.h>
63#include <kern/ipc_tt.h>
64#include <kern/ipc_host.h>
65#include <kern/ledger.h>
66#include <kern/processor.h>
67#include <kern/sync_sema.h>
68#include <ipc/ipc_eventlink.h>
69#include <vm/memory_object.h>
70#include <vm/vm_map.h>
71#include <kern/arcade.h>
72#include <kern/ipc_mig.h>
73#include <kern/task_ident.h>
74#include <kern/kern_cdata.h>
75#include <mach/mig.h>
76#include <mach/mach_types.h>
77
78#ifdef __BeforeMigServerHeader
79__BeforeMigServerHeader
80#endif /* __BeforeMigServerHeader */
81
82#ifndef MIG_SERVER_ROUTINE
83#define MIG_SERVER_ROUTINE
84#endif
85
86
87/* Routine processor_start_from_user */
88#ifdef mig_external
89mig_external
90#else
91extern
92#endif /* mig_external */
93MIG_SERVER_ROUTINE
94kern_return_t processor_start_from_user
95(
96 processor_t processor
97);
98
99/* Routine processor_exit_from_user */
100#ifdef mig_external
101mig_external
102#else
103extern
104#endif /* mig_external */
105MIG_SERVER_ROUTINE
106kern_return_t processor_exit_from_user
107(
108 processor_t processor
109);
110
111/* Routine processor_info */
112#ifdef mig_external
113mig_external
114#else
115extern
116#endif /* mig_external */
117MIG_SERVER_ROUTINE
118kern_return_t processor_info
119(
120 processor_t processor,
121 processor_flavor_t flavor,
122 host_t *host,
123 processor_info_t processor_info_out,
124 mach_msg_type_number_t *processor_info_outCnt
125);
126
127/* Routine processor_control */
128#ifdef mig_external
129mig_external
130#else
131extern
132#endif /* mig_external */
133MIG_SERVER_ROUTINE
134kern_return_t processor_control
135(
136 processor_t processor,
137 processor_info_t processor_cmd,
138 mach_msg_type_number_t processor_cmdCnt
139);
140
141/* Routine processor_assign */
142#ifdef mig_external
143mig_external
144#else
145extern
146#endif /* mig_external */
147MIG_SERVER_ROUTINE
148kern_return_t processor_assign
149(
150 processor_t processor,
151 processor_set_t new_set,
152 boolean_t wait
153);
154
155/* Routine processor_get_assignment */
156#ifdef mig_external
157mig_external
158#else
159extern
160#endif /* mig_external */
161MIG_SERVER_ROUTINE
162kern_return_t processor_get_assignment
163(
164 processor_t processor,
165 processor_set_name_t *assigned_set
166);
167
168#ifdef mig_external
169mig_external
170#else
171extern
172#endif /* mig_external */
173boolean_t processor_server(
174 mach_msg_header_t *InHeadP,
175 void *InDataP,
176 mach_msg_max_trailer_t *InTrailerP,
177 mach_msg_header_t *OutHeadP,
178 void *OutDataP);
179
180#ifdef mig_external
181mig_external
182#else
183extern
184#endif /* mig_external */
185mig_kern_routine_t processor_server_routine(
186 mach_msg_header_t *InHeadP);
187
188
189/* Description of this kernel subsystem, for use in direct RPC */
190extern const struct processor_subsystem {
191 mig_kern_server_routine_t kserver; /* Server routine */
192 mach_msg_id_t start; /* Min routine number */
193 mach_msg_id_t end; /* Max routine number + 1 */
194 unsigned int maxsize; /* Max msg size */
195 vm_address_t reserved; /* Reserved */
196 struct kern_routine_descriptor /* Array of routine descriptors */
197 kroutine[6];
198} processor_subsystem;
199
200/* typedefs for all requests */
201
202#ifndef __Request__processor_subsystem__defined
203#define __Request__processor_subsystem__defined
204
205#ifdef __MigPackStructs
206#pragma pack(push, 4)
207#endif
208 typedef struct {
209 mach_msg_header_t Head;
210 } __Request__processor_start_from_user_t __attribute__((unused));
211#ifdef __MigPackStructs
212#pragma pack(pop)
213#endif
214/* Struct for kernel processed data (Header + Descriptors) */
215#ifdef __MigPackStructs
216#pragma pack(push, 4)
217#endif
218 typedef struct {
219 mach_msg_header_t Head;
220 } __RequestKData__processor_start_from_user_t __attribute__((unused));
221#ifdef __MigPackStructs
222#pragma pack(pop)
223#endif
224/* Struct for pure user data */
225#ifdef __MigPackStructs
226#pragma pack(push, 4)
227#endif
228 typedef struct {
229 char padding[0]; /* Avoid generating empty UData structs */
230 } __RequestUData__processor_start_from_user_t __attribute__((unused));
231#ifdef __MigPackStructs
232#pragma pack(pop)
233#endif
234
235#ifdef __MigPackStructs
236#pragma pack(push, 4)
237#endif
238 typedef struct {
239 mach_msg_header_t Head;
240 } __Request__processor_exit_from_user_t __attribute__((unused));
241#ifdef __MigPackStructs
242#pragma pack(pop)
243#endif
244/* Struct for kernel processed data (Header + Descriptors) */
245#ifdef __MigPackStructs
246#pragma pack(push, 4)
247#endif
248 typedef struct {
249 mach_msg_header_t Head;
250 } __RequestKData__processor_exit_from_user_t __attribute__((unused));
251#ifdef __MigPackStructs
252#pragma pack(pop)
253#endif
254/* Struct for pure user data */
255#ifdef __MigPackStructs
256#pragma pack(push, 4)
257#endif
258 typedef struct {
259 char padding[0]; /* Avoid generating empty UData structs */
260 } __RequestUData__processor_exit_from_user_t __attribute__((unused));
261#ifdef __MigPackStructs
262#pragma pack(pop)
263#endif
264
265#ifdef __MigPackStructs
266#pragma pack(push, 4)
267#endif
268 typedef struct {
269 mach_msg_header_t Head;
270 NDR_record_t NDR;
271 processor_flavor_t flavor;
272 mach_msg_type_number_t processor_info_outCnt;
273 } __Request__processor_info_t __attribute__((unused));
274#ifdef __MigPackStructs
275#pragma pack(pop)
276#endif
277/* Struct for kernel processed data (Header + Descriptors) */
278#ifdef __MigPackStructs
279#pragma pack(push, 4)
280#endif
281 typedef struct {
282 mach_msg_header_t Head;
283 } __RequestKData__processor_info_t __attribute__((unused));
284#ifdef __MigPackStructs
285#pragma pack(pop)
286#endif
287/* Struct for pure user data */
288#ifdef __MigPackStructs
289#pragma pack(push, 4)
290#endif
291 typedef struct {
292 NDR_record_t NDR;
293 processor_flavor_t flavor;
294 mach_msg_type_number_t processor_info_outCnt;
295 char padding[0]; /* Avoid generating empty UData structs */
296 } __RequestUData__processor_info_t __attribute__((unused));
297#ifdef __MigPackStructs
298#pragma pack(pop)
299#endif
300
301#ifdef __MigPackStructs
302#pragma pack(push, 4)
303#endif
304 typedef struct {
305 mach_msg_header_t Head;
306 NDR_record_t NDR;
307 mach_msg_type_number_t processor_cmdCnt;
308 integer_t processor_cmd[20];
309 } __Request__processor_control_t __attribute__((unused));
310#ifdef __MigPackStructs
311#pragma pack(pop)
312#endif
313/* Struct for kernel processed data (Header + Descriptors) */
314#ifdef __MigPackStructs
315#pragma pack(push, 4)
316#endif
317 typedef struct {
318 mach_msg_header_t Head;
319 } __RequestKData__processor_control_t __attribute__((unused));
320#ifdef __MigPackStructs
321#pragma pack(pop)
322#endif
323/* Struct for pure user data */
324#ifdef __MigPackStructs
325#pragma pack(push, 4)
326#endif
327 typedef struct {
328 NDR_record_t NDR;
329 mach_msg_type_number_t processor_cmdCnt;
330 integer_t processor_cmd[20];
331 char padding[0]; /* Avoid generating empty UData structs */
332 } __RequestUData__processor_control_t __attribute__((unused));
333#ifdef __MigPackStructs
334#pragma pack(pop)
335#endif
336
337#ifdef __MigPackStructs
338#pragma pack(push, 4)
339#endif
340 typedef struct {
341 mach_msg_header_t Head;
342 /* start of the kernel processed data */
343 mach_msg_body_t msgh_body;
344 mach_msg_port_descriptor_t new_set;
345 /* end of the kernel processed data */
346 NDR_record_t NDR;
347 boolean_t wait;
348 } __Request__processor_assign_t __attribute__((unused));
349#ifdef __MigPackStructs
350#pragma pack(pop)
351#endif
352/* Struct for kernel processed data (Header + Descriptors) */
353#ifdef __MigPackStructs
354#pragma pack(push, 4)
355#endif
356 typedef struct {
357 mach_msg_header_t Head;
358 mach_msg_body_t msgh_body;
359 mach_msg_port_descriptor_t new_set;
360 } __RequestKData__processor_assign_t __attribute__((unused));
361#ifdef __MigPackStructs
362#pragma pack(pop)
363#endif
364/* Struct for pure user data */
365#ifdef __MigPackStructs
366#pragma pack(push, 4)
367#endif
368 typedef struct {
369 NDR_record_t NDR;
370 boolean_t wait;
371 char padding[0]; /* Avoid generating empty UData structs */
372 } __RequestUData__processor_assign_t __attribute__((unused));
373#ifdef __MigPackStructs
374#pragma pack(pop)
375#endif
376
377#ifdef __MigPackStructs
378#pragma pack(push, 4)
379#endif
380 typedef struct {
381 mach_msg_header_t Head;
382 } __Request__processor_get_assignment_t __attribute__((unused));
383#ifdef __MigPackStructs
384#pragma pack(pop)
385#endif
386/* Struct for kernel processed data (Header + Descriptors) */
387#ifdef __MigPackStructs
388#pragma pack(push, 4)
389#endif
390 typedef struct {
391 mach_msg_header_t Head;
392 } __RequestKData__processor_get_assignment_t __attribute__((unused));
393#ifdef __MigPackStructs
394#pragma pack(pop)
395#endif
396/* Struct for pure user data */
397#ifdef __MigPackStructs
398#pragma pack(push, 4)
399#endif
400 typedef struct {
401 char padding[0]; /* Avoid generating empty UData structs */
402 } __RequestUData__processor_get_assignment_t __attribute__((unused));
403#ifdef __MigPackStructs
404#pragma pack(pop)
405#endif
406#endif /* !__Request__processor_subsystem__defined */
407
408
409/* union of all requests */
410
411#ifndef __RequestUnion__processor_subsystem__defined
412#define __RequestUnion__processor_subsystem__defined
413union __RequestUnion__processor_subsystem {
414 __Request__processor_start_from_user_t Request_processor_start_from_user;
415 __Request__processor_exit_from_user_t Request_processor_exit_from_user;
416 __Request__processor_info_t Request_processor_info;
417 __Request__processor_control_t Request_processor_control;
418 __Request__processor_assign_t Request_processor_assign;
419 __Request__processor_get_assignment_t Request_processor_get_assignment;
420};
421#endif /* __RequestUnion__processor_subsystem__defined */
422/* typedefs for all replies */
423
424#ifndef __Reply__processor_subsystem__defined
425#define __Reply__processor_subsystem__defined
426
427#ifdef __MigPackStructs
428#pragma pack(push, 4)
429#endif
430 typedef struct {
431 mach_msg_header_t Head;
432 NDR_record_t NDR;
433 kern_return_t RetCode;
434 } __Reply__processor_start_from_user_t __attribute__((unused));
435#ifdef __MigPackStructs
436#pragma pack(pop)
437#endif
438/* Struct for kernel processed data (Header + Descriptors) */
439#ifdef __MigPackStructs
440#pragma pack(push, 4)
441#endif
442 typedef struct {
443 mach_msg_header_t Head;
444 } __ReplyKData__processor_start_from_user_t __attribute__((unused));
445#ifdef __MigPackStructs
446#pragma pack(pop)
447#endif
448/* Struct for pure user data */
449#ifdef __MigPackStructs
450#pragma pack(push, 4)
451#endif
452 typedef struct {
453 NDR_record_t NDR;
454 kern_return_t RetCode;
455 char padding[0]; /* Avoid generating empty UData structs */
456 } __ReplyUData__processor_start_from_user_t __attribute__((unused));
457#ifdef __MigPackStructs
458#pragma pack(pop)
459#endif
460
461#ifdef __MigPackStructs
462#pragma pack(push, 4)
463#endif
464 typedef struct {
465 mach_msg_header_t Head;
466 NDR_record_t NDR;
467 kern_return_t RetCode;
468 } __Reply__processor_exit_from_user_t __attribute__((unused));
469#ifdef __MigPackStructs
470#pragma pack(pop)
471#endif
472/* Struct for kernel processed data (Header + Descriptors) */
473#ifdef __MigPackStructs
474#pragma pack(push, 4)
475#endif
476 typedef struct {
477 mach_msg_header_t Head;
478 } __ReplyKData__processor_exit_from_user_t __attribute__((unused));
479#ifdef __MigPackStructs
480#pragma pack(pop)
481#endif
482/* Struct for pure user data */
483#ifdef __MigPackStructs
484#pragma pack(push, 4)
485#endif
486 typedef struct {
487 NDR_record_t NDR;
488 kern_return_t RetCode;
489 char padding[0]; /* Avoid generating empty UData structs */
490 } __ReplyUData__processor_exit_from_user_t __attribute__((unused));
491#ifdef __MigPackStructs
492#pragma pack(pop)
493#endif
494
495#ifdef __MigPackStructs
496#pragma pack(push, 4)
497#endif
498 typedef struct {
499 mach_msg_header_t Head;
500 /* start of the kernel processed data */
501 mach_msg_body_t msgh_body;
502 mach_msg_port_descriptor_t host;
503 /* end of the kernel processed data */
504 NDR_record_t NDR;
505 mach_msg_type_number_t processor_info_outCnt;
506 integer_t processor_info_out[20];
507 } __Reply__processor_info_t __attribute__((unused));
508#ifdef __MigPackStructs
509#pragma pack(pop)
510#endif
511/* Struct for kernel processed data (Header + Descriptors) */
512#ifdef __MigPackStructs
513#pragma pack(push, 4)
514#endif
515 typedef struct {
516 mach_msg_header_t Head;
517 mach_msg_body_t msgh_body;
518 mach_msg_port_descriptor_t host;
519 } __ReplyKData__processor_info_t __attribute__((unused));
520#ifdef __MigPackStructs
521#pragma pack(pop)
522#endif
523/* Struct for pure user data */
524#ifdef __MigPackStructs
525#pragma pack(push, 4)
526#endif
527 typedef struct {
528 NDR_record_t NDR;
529 mach_msg_type_number_t processor_info_outCnt;
530 integer_t processor_info_out[20];
531 char padding[0]; /* Avoid generating empty UData structs */
532 } __ReplyUData__processor_info_t __attribute__((unused));
533#ifdef __MigPackStructs
534#pragma pack(pop)
535#endif
536
537#ifdef __MigPackStructs
538#pragma pack(push, 4)
539#endif
540 typedef struct {
541 mach_msg_header_t Head;
542 NDR_record_t NDR;
543 kern_return_t RetCode;
544 } __Reply__processor_control_t __attribute__((unused));
545#ifdef __MigPackStructs
546#pragma pack(pop)
547#endif
548/* Struct for kernel processed data (Header + Descriptors) */
549#ifdef __MigPackStructs
550#pragma pack(push, 4)
551#endif
552 typedef struct {
553 mach_msg_header_t Head;
554 } __ReplyKData__processor_control_t __attribute__((unused));
555#ifdef __MigPackStructs
556#pragma pack(pop)
557#endif
558/* Struct for pure user data */
559#ifdef __MigPackStructs
560#pragma pack(push, 4)
561#endif
562 typedef struct {
563 NDR_record_t NDR;
564 kern_return_t RetCode;
565 char padding[0]; /* Avoid generating empty UData structs */
566 } __ReplyUData__processor_control_t __attribute__((unused));
567#ifdef __MigPackStructs
568#pragma pack(pop)
569#endif
570
571#ifdef __MigPackStructs
572#pragma pack(push, 4)
573#endif
574 typedef struct {
575 mach_msg_header_t Head;
576 NDR_record_t NDR;
577 kern_return_t RetCode;
578 } __Reply__processor_assign_t __attribute__((unused));
579#ifdef __MigPackStructs
580#pragma pack(pop)
581#endif
582/* Struct for kernel processed data (Header + Descriptors) */
583#ifdef __MigPackStructs
584#pragma pack(push, 4)
585#endif
586 typedef struct {
587 mach_msg_header_t Head;
588 } __ReplyKData__processor_assign_t __attribute__((unused));
589#ifdef __MigPackStructs
590#pragma pack(pop)
591#endif
592/* Struct for pure user data */
593#ifdef __MigPackStructs
594#pragma pack(push, 4)
595#endif
596 typedef struct {
597 NDR_record_t NDR;
598 kern_return_t RetCode;
599 char padding[0]; /* Avoid generating empty UData structs */
600 } __ReplyUData__processor_assign_t __attribute__((unused));
601#ifdef __MigPackStructs
602#pragma pack(pop)
603#endif
604
605#ifdef __MigPackStructs
606#pragma pack(push, 4)
607#endif
608 typedef struct {
609 mach_msg_header_t Head;
610 /* start of the kernel processed data */
611 mach_msg_body_t msgh_body;
612 mach_msg_port_descriptor_t assigned_set;
613 /* end of the kernel processed data */
614 } __Reply__processor_get_assignment_t __attribute__((unused));
615#ifdef __MigPackStructs
616#pragma pack(pop)
617#endif
618/* Struct for kernel processed data (Header + Descriptors) */
619#ifdef __MigPackStructs
620#pragma pack(push, 4)
621#endif
622 typedef struct {
623 mach_msg_header_t Head;
624 mach_msg_body_t msgh_body;
625 mach_msg_port_descriptor_t assigned_set;
626 } __ReplyKData__processor_get_assignment_t __attribute__((unused));
627#ifdef __MigPackStructs
628#pragma pack(pop)
629#endif
630/* Struct for pure user data */
631#ifdef __MigPackStructs
632#pragma pack(push, 4)
633#endif
634 typedef struct {
635 char padding[0]; /* Avoid generating empty UData structs */
636 } __ReplyUData__processor_get_assignment_t __attribute__((unused));
637#ifdef __MigPackStructs
638#pragma pack(pop)
639#endif
640#endif /* !__Reply__processor_subsystem__defined */
641
642
643/* union of all replies */
644
645#ifndef __ReplyUnion__processor_subsystem__defined
646#define __ReplyUnion__processor_subsystem__defined
647union __ReplyUnion__processor_subsystem {
648 __Reply__processor_start_from_user_t Reply_processor_start_from_user;
649 __Reply__processor_exit_from_user_t Reply_processor_exit_from_user;
650 __Reply__processor_info_t Reply_processor_info;
651 __Reply__processor_control_t Reply_processor_control;
652 __Reply__processor_assign_t Reply_processor_assign;
653 __Reply__processor_get_assignment_t Reply_processor_get_assignment;
654};
655#endif /* __ReplyUnion__processor_subsystem__defined */
656
657#ifndef subsystem_to_name_map_processor
658#define subsystem_to_name_map_processor \
659 { "processor_start_from_user", 3000 },\
660 { "processor_exit_from_user", 3001 },\
661 { "processor_info", 3002 },\
662 { "processor_control", 3003 },\
663 { "processor_assign", 3004 },\
664 { "processor_get_assignment", 3005 }
665#endif
666
667#ifdef __AfterMigServerHeader
668__AfterMigServerHeader
669#endif /* __AfterMigServerHeader */
670
671#endif /* _processor_server_ */
672