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 |
26 | extern "C" { |
27 | #endif |
28 | extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); |
29 | #ifdef __cplusplus |
30 | } |
31 | #endif |
32 | #endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ |
33 | #endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */ |
34 | #endif /* __has_include */ |
35 | |
36 | /* END MIG_STRNCPY_ZEROFILL CODE */ |
37 | |
38 | |
39 | #ifdef AUTOTEST |
40 | #ifndef FUNCTION_PTR_T |
41 | #define FUNCTION_PTR_T |
42 | typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); |
43 | typedef struct { |
44 | char *name; |
45 | function_ptr_t function; |
46 | } function_table_entry; |
47 | typedef function_table_entry *function_table_t; |
48 | #endif /* FUNCTION_PTR_T */ |
49 | #endif /* AUTOTEST */ |
50 | |
51 | #ifndef processor_MSG_COUNT |
52 | #define processor_MSG_COUNT 6 |
53 | #endif /* processor_MSG_COUNT */ |
54 | |
55 | #include <mach/std_types.h> |
56 | #include <mach/mig.h> |
57 | #include <ipc/ipc_voucher.h> |
58 | #include <kern/ipc_kobject.h> |
59 | #include <kern/ipc_tt.h> |
60 | #include <kern/ipc_host.h> |
61 | #include <kern/ipc_sync.h> |
62 | #include <kern/ledger.h> |
63 | #include <kern/processor.h> |
64 | #include <kern/sync_lock.h> |
65 | #include <kern/sync_sema.h> |
66 | #include <vm/memory_object.h> |
67 | #include <vm/vm_map.h> |
68 | #include <kern/ipc_mig.h> |
69 | #include <mach/mig.h> |
70 | #include <mach/mach_types.h> |
71 | |
72 | #ifdef __BeforeMigServerHeader |
73 | __BeforeMigServerHeader |
74 | #endif /* __BeforeMigServerHeader */ |
75 | |
76 | |
77 | /* Routine processor_start */ |
78 | #ifdef mig_external |
79 | mig_external |
80 | #else |
81 | extern |
82 | #endif /* mig_external */ |
83 | kern_return_t processor_start |
84 | ( |
85 | processor_t processor |
86 | ); |
87 | |
88 | /* Routine processor_exit */ |
89 | #ifdef mig_external |
90 | mig_external |
91 | #else |
92 | extern |
93 | #endif /* mig_external */ |
94 | kern_return_t processor_exit |
95 | ( |
96 | processor_t processor |
97 | ); |
98 | |
99 | /* Routine processor_info */ |
100 | #ifdef mig_external |
101 | mig_external |
102 | #else |
103 | extern |
104 | #endif /* mig_external */ |
105 | kern_return_t processor_info |
106 | ( |
107 | processor_t processor, |
108 | processor_flavor_t flavor, |
109 | host_t *host, |
110 | processor_info_t processor_info_out, |
111 | mach_msg_type_number_t *processor_info_outCnt |
112 | ); |
113 | |
114 | /* Routine processor_control */ |
115 | #ifdef mig_external |
116 | mig_external |
117 | #else |
118 | extern |
119 | #endif /* mig_external */ |
120 | kern_return_t processor_control |
121 | ( |
122 | processor_t processor, |
123 | processor_info_t processor_cmd, |
124 | mach_msg_type_number_t processor_cmdCnt |
125 | ); |
126 | |
127 | /* Routine processor_assign */ |
128 | #ifdef mig_external |
129 | mig_external |
130 | #else |
131 | extern |
132 | #endif /* mig_external */ |
133 | kern_return_t processor_assign |
134 | ( |
135 | processor_t processor, |
136 | processor_set_t new_set, |
137 | boolean_t wait |
138 | ); |
139 | |
140 | /* Routine processor_get_assignment */ |
141 | #ifdef mig_external |
142 | mig_external |
143 | #else |
144 | extern |
145 | #endif /* mig_external */ |
146 | kern_return_t processor_get_assignment |
147 | ( |
148 | processor_t processor, |
149 | processor_set_name_t *assigned_set |
150 | ); |
151 | |
152 | #ifdef mig_external |
153 | mig_external |
154 | #else |
155 | extern |
156 | #endif /* mig_external */ |
157 | boolean_t processor_server( |
158 | mach_msg_header_t *InHeadP, |
159 | mach_msg_header_t *OutHeadP); |
160 | |
161 | #ifdef mig_external |
162 | mig_external |
163 | #else |
164 | extern |
165 | #endif /* mig_external */ |
166 | mig_routine_t processor_server_routine( |
167 | mach_msg_header_t *InHeadP); |
168 | |
169 | |
170 | /* Description of this subsystem, for use in direct RPC */ |
171 | extern const struct processor_subsystem { |
172 | mig_server_routine_t server; /* Server routine */ |
173 | mach_msg_id_t start; /* Min routine number */ |
174 | mach_msg_id_t end; /* Max routine number + 1 */ |
175 | unsigned int maxsize; /* Max msg size */ |
176 | vm_address_t reserved; /* Reserved */ |
177 | struct routine_descriptor /*Array of routine descriptors */ |
178 | routine[6]; |
179 | } processor_subsystem; |
180 | |
181 | /* typedefs for all requests */ |
182 | |
183 | #ifndef __Request__processor_subsystem__defined |
184 | #define __Request__processor_subsystem__defined |
185 | |
186 | #ifdef __MigPackStructs |
187 | #pragma pack(4) |
188 | #endif |
189 | typedef struct { |
190 | mach_msg_header_t Head; |
191 | } __Request__processor_start_t __attribute__((unused)); |
192 | #ifdef __MigPackStructs |
193 | #pragma pack() |
194 | #endif |
195 | |
196 | #ifdef __MigPackStructs |
197 | #pragma pack(4) |
198 | #endif |
199 | typedef struct { |
200 | mach_msg_header_t Head; |
201 | } __Request__processor_exit_t __attribute__((unused)); |
202 | #ifdef __MigPackStructs |
203 | #pragma pack() |
204 | #endif |
205 | |
206 | #ifdef __MigPackStructs |
207 | #pragma pack(4) |
208 | #endif |
209 | typedef struct { |
210 | mach_msg_header_t Head; |
211 | NDR_record_t NDR; |
212 | processor_flavor_t flavor; |
213 | mach_msg_type_number_t processor_info_outCnt; |
214 | } __Request__processor_info_t __attribute__((unused)); |
215 | #ifdef __MigPackStructs |
216 | #pragma pack() |
217 | #endif |
218 | |
219 | #ifdef __MigPackStructs |
220 | #pragma pack(4) |
221 | #endif |
222 | typedef struct { |
223 | mach_msg_header_t Head; |
224 | NDR_record_t NDR; |
225 | mach_msg_type_number_t processor_cmdCnt; |
226 | integer_t processor_cmd[12]; |
227 | } __Request__processor_control_t __attribute__((unused)); |
228 | #ifdef __MigPackStructs |
229 | #pragma pack() |
230 | #endif |
231 | |
232 | #ifdef __MigPackStructs |
233 | #pragma pack(4) |
234 | #endif |
235 | typedef struct { |
236 | mach_msg_header_t Head; |
237 | /* start of the kernel processed data */ |
238 | mach_msg_body_t msgh_body; |
239 | mach_msg_port_descriptor_t new_set; |
240 | /* end of the kernel processed data */ |
241 | NDR_record_t NDR; |
242 | boolean_t wait; |
243 | } __Request__processor_assign_t __attribute__((unused)); |
244 | #ifdef __MigPackStructs |
245 | #pragma pack() |
246 | #endif |
247 | |
248 | #ifdef __MigPackStructs |
249 | #pragma pack(4) |
250 | #endif |
251 | typedef struct { |
252 | mach_msg_header_t Head; |
253 | } __Request__processor_get_assignment_t __attribute__((unused)); |
254 | #ifdef __MigPackStructs |
255 | #pragma pack() |
256 | #endif |
257 | #endif /* !__Request__processor_subsystem__defined */ |
258 | |
259 | |
260 | /* union of all requests */ |
261 | |
262 | #ifndef __RequestUnion__processor_subsystem__defined |
263 | #define __RequestUnion__processor_subsystem__defined |
264 | union __RequestUnion__processor_subsystem { |
265 | __Request__processor_start_t Request_processor_start; |
266 | __Request__processor_exit_t Request_processor_exit; |
267 | __Request__processor_info_t Request_processor_info; |
268 | __Request__processor_control_t Request_processor_control; |
269 | __Request__processor_assign_t Request_processor_assign; |
270 | __Request__processor_get_assignment_t Request_processor_get_assignment; |
271 | }; |
272 | #endif /* __RequestUnion__processor_subsystem__defined */ |
273 | /* typedefs for all replies */ |
274 | |
275 | #ifndef __Reply__processor_subsystem__defined |
276 | #define __Reply__processor_subsystem__defined |
277 | |
278 | #ifdef __MigPackStructs |
279 | #pragma pack(4) |
280 | #endif |
281 | typedef struct { |
282 | mach_msg_header_t Head; |
283 | NDR_record_t NDR; |
284 | kern_return_t RetCode; |
285 | } __Reply__processor_start_t __attribute__((unused)); |
286 | #ifdef __MigPackStructs |
287 | #pragma pack() |
288 | #endif |
289 | |
290 | #ifdef __MigPackStructs |
291 | #pragma pack(4) |
292 | #endif |
293 | typedef struct { |
294 | mach_msg_header_t Head; |
295 | NDR_record_t NDR; |
296 | kern_return_t RetCode; |
297 | } __Reply__processor_exit_t __attribute__((unused)); |
298 | #ifdef __MigPackStructs |
299 | #pragma pack() |
300 | #endif |
301 | |
302 | #ifdef __MigPackStructs |
303 | #pragma pack(4) |
304 | #endif |
305 | typedef struct { |
306 | mach_msg_header_t Head; |
307 | /* start of the kernel processed data */ |
308 | mach_msg_body_t msgh_body; |
309 | mach_msg_port_descriptor_t host; |
310 | /* end of the kernel processed data */ |
311 | NDR_record_t NDR; |
312 | mach_msg_type_number_t processor_info_outCnt; |
313 | integer_t processor_info_out[12]; |
314 | } __Reply__processor_info_t __attribute__((unused)); |
315 | #ifdef __MigPackStructs |
316 | #pragma pack() |
317 | #endif |
318 | |
319 | #ifdef __MigPackStructs |
320 | #pragma pack(4) |
321 | #endif |
322 | typedef struct { |
323 | mach_msg_header_t Head; |
324 | NDR_record_t NDR; |
325 | kern_return_t RetCode; |
326 | } __Reply__processor_control_t __attribute__((unused)); |
327 | #ifdef __MigPackStructs |
328 | #pragma pack() |
329 | #endif |
330 | |
331 | #ifdef __MigPackStructs |
332 | #pragma pack(4) |
333 | #endif |
334 | typedef struct { |
335 | mach_msg_header_t Head; |
336 | NDR_record_t NDR; |
337 | kern_return_t RetCode; |
338 | } __Reply__processor_assign_t __attribute__((unused)); |
339 | #ifdef __MigPackStructs |
340 | #pragma pack() |
341 | #endif |
342 | |
343 | #ifdef __MigPackStructs |
344 | #pragma pack(4) |
345 | #endif |
346 | typedef struct { |
347 | mach_msg_header_t Head; |
348 | /* start of the kernel processed data */ |
349 | mach_msg_body_t msgh_body; |
350 | mach_msg_port_descriptor_t assigned_set; |
351 | /* end of the kernel processed data */ |
352 | } __Reply__processor_get_assignment_t __attribute__((unused)); |
353 | #ifdef __MigPackStructs |
354 | #pragma pack() |
355 | #endif |
356 | #endif /* !__Reply__processor_subsystem__defined */ |
357 | |
358 | |
359 | /* union of all replies */ |
360 | |
361 | #ifndef __ReplyUnion__processor_subsystem__defined |
362 | #define __ReplyUnion__processor_subsystem__defined |
363 | union __ReplyUnion__processor_subsystem { |
364 | __Reply__processor_start_t Reply_processor_start; |
365 | __Reply__processor_exit_t Reply_processor_exit; |
366 | __Reply__processor_info_t Reply_processor_info; |
367 | __Reply__processor_control_t Reply_processor_control; |
368 | __Reply__processor_assign_t Reply_processor_assign; |
369 | __Reply__processor_get_assignment_t Reply_processor_get_assignment; |
370 | }; |
371 | #endif /* __RequestUnion__processor_subsystem__defined */ |
372 | |
373 | #ifndef subsystem_to_name_map_processor |
374 | #define subsystem_to_name_map_processor \ |
375 | { "processor_start", 3000 },\ |
376 | { "processor_exit", 3001 },\ |
377 | { "processor_info", 3002 },\ |
378 | { "processor_control", 3003 },\ |
379 | { "processor_assign", 3004 },\ |
380 | { "processor_get_assignment", 3005 } |
381 | #endif |
382 | |
383 | #ifdef __AfterMigServerHeader |
384 | __AfterMigServerHeader |
385 | #endif /* __AfterMigServerHeader */ |
386 | |
387 | #endif /* _processor_server_ */ |
388 | |