1#ifndef _task_restartable_server_
2#define _task_restartable_server_
3
4/* Module task_restartable */
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 task_restartable_MSG_COUNT
55#define task_restartable_MSG_COUNT 2
56#endif /* task_restartable_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#include <mach_debug/mach_debug_types.h>
78#include <kern/restartable.h>
79
80#ifdef __BeforeMigServerHeader
81__BeforeMigServerHeader
82#endif /* __BeforeMigServerHeader */
83
84#ifndef MIG_SERVER_ROUTINE
85#define MIG_SERVER_ROUTINE
86#endif
87
88
89/* Routine task_restartable_ranges_register */
90#ifdef mig_external
91mig_external
92#else
93extern
94#endif /* mig_external */
95MIG_SERVER_ROUTINE
96kern_return_t task_restartable_ranges_register
97(
98 task_t target_task,
99 task_restartable_range_array_t ranges,
100 mach_msg_type_number_t rangesCnt
101);
102
103/* Routine task_restartable_ranges_synchronize */
104#ifdef mig_external
105mig_external
106#else
107extern
108#endif /* mig_external */
109MIG_SERVER_ROUTINE
110kern_return_t task_restartable_ranges_synchronize
111(
112 task_t target_task
113);
114
115#ifdef mig_external
116mig_external
117#else
118extern
119#endif /* mig_external */
120boolean_t task_restartable_server(
121 mach_msg_header_t *InHeadP,
122 void *InDataP,
123 mach_msg_max_trailer_t *InTrailerP,
124 mach_msg_header_t *OutHeadP,
125 void *OutDataP);
126
127#ifdef mig_external
128mig_external
129#else
130extern
131#endif /* mig_external */
132mig_kern_routine_t task_restartable_server_routine(
133 mach_msg_header_t *InHeadP);
134
135
136/* Description of this kernel subsystem, for use in direct RPC */
137extern const struct task_restartable_subsystem {
138 mig_kern_server_routine_t kserver; /* Server routine */
139 mach_msg_id_t start; /* Min routine number */
140 mach_msg_id_t end; /* Max routine number + 1 */
141 unsigned int maxsize; /* Max msg size */
142 vm_address_t reserved; /* Reserved */
143 struct kern_routine_descriptor /* Array of routine descriptors */
144 kroutine[2];
145} task_restartable_subsystem;
146
147/* typedefs for all requests */
148
149#ifndef __Request__task_restartable_subsystem__defined
150#define __Request__task_restartable_subsystem__defined
151
152#ifdef __MigPackStructs
153#pragma pack(push, 4)
154#endif
155 typedef struct {
156 mach_msg_header_t Head;
157 NDR_record_t NDR;
158 mach_msg_type_number_t rangesCnt;
159 task_restartable_range_t ranges[64];
160 } __Request__task_restartable_ranges_register_t __attribute__((unused));
161#ifdef __MigPackStructs
162#pragma pack(pop)
163#endif
164/* Struct for kernel processed data (Header + Descriptors) */
165#ifdef __MigPackStructs
166#pragma pack(push, 4)
167#endif
168 typedef struct {
169 mach_msg_header_t Head;
170 } __RequestKData__task_restartable_ranges_register_t __attribute__((unused));
171#ifdef __MigPackStructs
172#pragma pack(pop)
173#endif
174/* Struct for pure user data */
175#ifdef __MigPackStructs
176#pragma pack(push, 4)
177#endif
178 typedef struct {
179 NDR_record_t NDR;
180 mach_msg_type_number_t rangesCnt;
181 task_restartable_range_t ranges[64];
182 char padding[0]; /* Avoid generating empty UData structs */
183 } __RequestUData__task_restartable_ranges_register_t __attribute__((unused));
184#ifdef __MigPackStructs
185#pragma pack(pop)
186#endif
187
188#ifdef __MigPackStructs
189#pragma pack(push, 4)
190#endif
191 typedef struct {
192 mach_msg_header_t Head;
193 } __Request__task_restartable_ranges_synchronize_t __attribute__((unused));
194#ifdef __MigPackStructs
195#pragma pack(pop)
196#endif
197/* Struct for kernel processed data (Header + Descriptors) */
198#ifdef __MigPackStructs
199#pragma pack(push, 4)
200#endif
201 typedef struct {
202 mach_msg_header_t Head;
203 } __RequestKData__task_restartable_ranges_synchronize_t __attribute__((unused));
204#ifdef __MigPackStructs
205#pragma pack(pop)
206#endif
207/* Struct for pure user data */
208#ifdef __MigPackStructs
209#pragma pack(push, 4)
210#endif
211 typedef struct {
212 char padding[0]; /* Avoid generating empty UData structs */
213 } __RequestUData__task_restartable_ranges_synchronize_t __attribute__((unused));
214#ifdef __MigPackStructs
215#pragma pack(pop)
216#endif
217#endif /* !__Request__task_restartable_subsystem__defined */
218
219
220/* union of all requests */
221
222#ifndef __RequestUnion__task_restartable_subsystem__defined
223#define __RequestUnion__task_restartable_subsystem__defined
224union __RequestUnion__task_restartable_subsystem {
225 __Request__task_restartable_ranges_register_t Request_task_restartable_ranges_register;
226 __Request__task_restartable_ranges_synchronize_t Request_task_restartable_ranges_synchronize;
227};
228#endif /* __RequestUnion__task_restartable_subsystem__defined */
229/* typedefs for all replies */
230
231#ifndef __Reply__task_restartable_subsystem__defined
232#define __Reply__task_restartable_subsystem__defined
233
234#ifdef __MigPackStructs
235#pragma pack(push, 4)
236#endif
237 typedef struct {
238 mach_msg_header_t Head;
239 NDR_record_t NDR;
240 kern_return_t RetCode;
241 } __Reply__task_restartable_ranges_register_t __attribute__((unused));
242#ifdef __MigPackStructs
243#pragma pack(pop)
244#endif
245/* Struct for kernel processed data (Header + Descriptors) */
246#ifdef __MigPackStructs
247#pragma pack(push, 4)
248#endif
249 typedef struct {
250 mach_msg_header_t Head;
251 } __ReplyKData__task_restartable_ranges_register_t __attribute__((unused));
252#ifdef __MigPackStructs
253#pragma pack(pop)
254#endif
255/* Struct for pure user data */
256#ifdef __MigPackStructs
257#pragma pack(push, 4)
258#endif
259 typedef struct {
260 NDR_record_t NDR;
261 kern_return_t RetCode;
262 char padding[0]; /* Avoid generating empty UData structs */
263 } __ReplyUData__task_restartable_ranges_register_t __attribute__((unused));
264#ifdef __MigPackStructs
265#pragma pack(pop)
266#endif
267
268#ifdef __MigPackStructs
269#pragma pack(push, 4)
270#endif
271 typedef struct {
272 mach_msg_header_t Head;
273 NDR_record_t NDR;
274 kern_return_t RetCode;
275 } __Reply__task_restartable_ranges_synchronize_t __attribute__((unused));
276#ifdef __MigPackStructs
277#pragma pack(pop)
278#endif
279/* Struct for kernel processed data (Header + Descriptors) */
280#ifdef __MigPackStructs
281#pragma pack(push, 4)
282#endif
283 typedef struct {
284 mach_msg_header_t Head;
285 } __ReplyKData__task_restartable_ranges_synchronize_t __attribute__((unused));
286#ifdef __MigPackStructs
287#pragma pack(pop)
288#endif
289/* Struct for pure user data */
290#ifdef __MigPackStructs
291#pragma pack(push, 4)
292#endif
293 typedef struct {
294 NDR_record_t NDR;
295 kern_return_t RetCode;
296 char padding[0]; /* Avoid generating empty UData structs */
297 } __ReplyUData__task_restartable_ranges_synchronize_t __attribute__((unused));
298#ifdef __MigPackStructs
299#pragma pack(pop)
300#endif
301#endif /* !__Reply__task_restartable_subsystem__defined */
302
303
304/* union of all replies */
305
306#ifndef __ReplyUnion__task_restartable_subsystem__defined
307#define __ReplyUnion__task_restartable_subsystem__defined
308union __ReplyUnion__task_restartable_subsystem {
309 __Reply__task_restartable_ranges_register_t Reply_task_restartable_ranges_register;
310 __Reply__task_restartable_ranges_synchronize_t Reply_task_restartable_ranges_synchronize;
311};
312#endif /* __ReplyUnion__task_restartable_subsystem__defined */
313
314#ifndef subsystem_to_name_map_task_restartable
315#define subsystem_to_name_map_task_restartable \
316 { "task_restartable_ranges_register", 8000 },\
317 { "task_restartable_ranges_synchronize", 8001 }
318#endif
319
320#ifdef __AfterMigServerHeader
321__AfterMigServerHeader
322#endif /* __AfterMigServerHeader */
323
324#endif /* _task_restartable_server_ */
325