1#ifndef _upl_server_
2#define _upl_server_
3
4/* Module upl */
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 upl_MSG_COUNT
55#define upl_MSG_COUNT 4
56#endif /* upl_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 upl_abort */
88#ifdef mig_external
89mig_external
90#else
91extern
92#endif /* mig_external */
93MIG_SERVER_ROUTINE
94kern_return_t upl_abort
95(
96 upl_t upl_object,
97 integer_t abort_cond
98);
99
100/* Routine upl_abort_range */
101#ifdef mig_external
102mig_external
103#else
104extern
105#endif /* mig_external */
106MIG_SERVER_ROUTINE
107kern_return_t upl_abort_range
108(
109 upl_t upl_object,
110 upl_offset_t offset,
111 upl_size_t size,
112 integer_t abort_cond,
113 boolean_t *empty
114);
115
116/* Routine upl_commit */
117#ifdef mig_external
118mig_external
119#else
120extern
121#endif /* mig_external */
122MIG_SERVER_ROUTINE
123kern_return_t upl_commit
124(
125 upl_t upl_object,
126 upl_page_info_array_t page_list,
127 mach_msg_type_number_t page_listCnt
128);
129
130/* Routine upl_commit_range */
131#ifdef mig_external
132mig_external
133#else
134extern
135#endif /* mig_external */
136MIG_SERVER_ROUTINE
137kern_return_t upl_commit_range
138(
139 upl_t upl_object,
140 upl_offset_t offset,
141 upl_size_t size,
142 integer_t cntrl_flags,
143 upl_page_info_array_t page_list,
144 mach_msg_type_number_t page_listCnt,
145 boolean_t *empty
146);
147
148#ifdef mig_external
149mig_external
150#else
151extern
152#endif /* mig_external */
153boolean_t upl_server(
154 mach_msg_header_t *InHeadP,
155 void *InDataP,
156 mach_msg_max_trailer_t *InTrailerP,
157 mach_msg_header_t *OutHeadP,
158 void *OutDataP);
159
160#ifdef mig_external
161mig_external
162#else
163extern
164#endif /* mig_external */
165mig_kern_routine_t upl_server_routine(
166 mach_msg_header_t *InHeadP);
167
168
169/* Description of this kernel subsystem, for use in direct RPC */
170extern const struct upl_subsystem {
171 mig_kern_server_routine_t kserver; /* Server routine */
172 mach_msg_id_t start; /* Min routine number */
173 mach_msg_id_t end; /* Max routine number + 1 */
174 unsigned int maxsize; /* Max msg size */
175 vm_address_t reserved; /* Reserved */
176 struct kern_routine_descriptor /* Array of routine descriptors */
177 kroutine[4];
178} upl_subsystem;
179
180/* typedefs for all requests */
181
182#ifndef __Request__upl_subsystem__defined
183#define __Request__upl_subsystem__defined
184
185#ifdef __MigPackStructs
186#pragma pack(push, 4)
187#endif
188 typedef struct {
189 mach_msg_header_t Head;
190 NDR_record_t NDR;
191 integer_t abort_cond;
192 } __Request__upl_abort_t __attribute__((unused));
193#ifdef __MigPackStructs
194#pragma pack(pop)
195#endif
196/* Struct for kernel processed data (Header + Descriptors) */
197#ifdef __MigPackStructs
198#pragma pack(push, 4)
199#endif
200 typedef struct {
201 mach_msg_header_t Head;
202 } __RequestKData__upl_abort_t __attribute__((unused));
203#ifdef __MigPackStructs
204#pragma pack(pop)
205#endif
206/* Struct for pure user data */
207#ifdef __MigPackStructs
208#pragma pack(push, 4)
209#endif
210 typedef struct {
211 NDR_record_t NDR;
212 integer_t abort_cond;
213 char padding[0]; /* Avoid generating empty UData structs */
214 } __RequestUData__upl_abort_t __attribute__((unused));
215#ifdef __MigPackStructs
216#pragma pack(pop)
217#endif
218
219#ifdef __MigPackStructs
220#pragma pack(push, 4)
221#endif
222 typedef struct {
223 mach_msg_header_t Head;
224 NDR_record_t NDR;
225 upl_offset_t offset;
226 upl_size_t size;
227 integer_t abort_cond;
228 } __Request__upl_abort_range_t __attribute__((unused));
229#ifdef __MigPackStructs
230#pragma pack(pop)
231#endif
232/* Struct for kernel processed data (Header + Descriptors) */
233#ifdef __MigPackStructs
234#pragma pack(push, 4)
235#endif
236 typedef struct {
237 mach_msg_header_t Head;
238 } __RequestKData__upl_abort_range_t __attribute__((unused));
239#ifdef __MigPackStructs
240#pragma pack(pop)
241#endif
242/* Struct for pure user data */
243#ifdef __MigPackStructs
244#pragma pack(push, 4)
245#endif
246 typedef struct {
247 NDR_record_t NDR;
248 upl_offset_t offset;
249 upl_size_t size;
250 integer_t abort_cond;
251 char padding[0]; /* Avoid generating empty UData structs */
252 } __RequestUData__upl_abort_range_t __attribute__((unused));
253#ifdef __MigPackStructs
254#pragma pack(pop)
255#endif
256
257#ifdef __MigPackStructs
258#pragma pack(push, 4)
259#endif
260 typedef struct {
261 mach_msg_header_t Head;
262 NDR_record_t NDR;
263 mach_msg_type_number_t page_listCnt;
264 upl_page_info_t page_list[256];
265 } __Request__upl_commit_t __attribute__((unused));
266#ifdef __MigPackStructs
267#pragma pack(pop)
268#endif
269/* Struct for kernel processed data (Header + Descriptors) */
270#ifdef __MigPackStructs
271#pragma pack(push, 4)
272#endif
273 typedef struct {
274 mach_msg_header_t Head;
275 } __RequestKData__upl_commit_t __attribute__((unused));
276#ifdef __MigPackStructs
277#pragma pack(pop)
278#endif
279/* Struct for pure user data */
280#ifdef __MigPackStructs
281#pragma pack(push, 4)
282#endif
283 typedef struct {
284 NDR_record_t NDR;
285 mach_msg_type_number_t page_listCnt;
286 upl_page_info_t page_list[256];
287 char padding[0]; /* Avoid generating empty UData structs */
288 } __RequestUData__upl_commit_t __attribute__((unused));
289#ifdef __MigPackStructs
290#pragma pack(pop)
291#endif
292
293#ifdef __MigPackStructs
294#pragma pack(push, 4)
295#endif
296 typedef struct {
297 mach_msg_header_t Head;
298 NDR_record_t NDR;
299 upl_offset_t offset;
300 upl_size_t size;
301 integer_t cntrl_flags;
302 mach_msg_type_number_t page_listCnt;
303 upl_page_info_t page_list[256];
304 } __Request__upl_commit_range_t __attribute__((unused));
305#ifdef __MigPackStructs
306#pragma pack(pop)
307#endif
308/* Struct for kernel processed data (Header + Descriptors) */
309#ifdef __MigPackStructs
310#pragma pack(push, 4)
311#endif
312 typedef struct {
313 mach_msg_header_t Head;
314 } __RequestKData__upl_commit_range_t __attribute__((unused));
315#ifdef __MigPackStructs
316#pragma pack(pop)
317#endif
318/* Struct for pure user data */
319#ifdef __MigPackStructs
320#pragma pack(push, 4)
321#endif
322 typedef struct {
323 NDR_record_t NDR;
324 upl_offset_t offset;
325 upl_size_t size;
326 integer_t cntrl_flags;
327 mach_msg_type_number_t page_listCnt;
328 upl_page_info_t page_list[256];
329 char padding[0]; /* Avoid generating empty UData structs */
330 } __RequestUData__upl_commit_range_t __attribute__((unused));
331#ifdef __MigPackStructs
332#pragma pack(pop)
333#endif
334#endif /* !__Request__upl_subsystem__defined */
335
336
337/* union of all requests */
338
339#ifndef __RequestUnion__upl_subsystem__defined
340#define __RequestUnion__upl_subsystem__defined
341union __RequestUnion__upl_subsystem {
342 __Request__upl_abort_t Request_upl_abort;
343 __Request__upl_abort_range_t Request_upl_abort_range;
344 __Request__upl_commit_t Request_upl_commit;
345 __Request__upl_commit_range_t Request_upl_commit_range;
346};
347#endif /* __RequestUnion__upl_subsystem__defined */
348/* typedefs for all replies */
349
350#ifndef __Reply__upl_subsystem__defined
351#define __Reply__upl_subsystem__defined
352
353#ifdef __MigPackStructs
354#pragma pack(push, 4)
355#endif
356 typedef struct {
357 mach_msg_header_t Head;
358 NDR_record_t NDR;
359 kern_return_t RetCode;
360 } __Reply__upl_abort_t __attribute__((unused));
361#ifdef __MigPackStructs
362#pragma pack(pop)
363#endif
364/* Struct for kernel processed data (Header + Descriptors) */
365#ifdef __MigPackStructs
366#pragma pack(push, 4)
367#endif
368 typedef struct {
369 mach_msg_header_t Head;
370 } __ReplyKData__upl_abort_t __attribute__((unused));
371#ifdef __MigPackStructs
372#pragma pack(pop)
373#endif
374/* Struct for pure user data */
375#ifdef __MigPackStructs
376#pragma pack(push, 4)
377#endif
378 typedef struct {
379 NDR_record_t NDR;
380 kern_return_t RetCode;
381 char padding[0]; /* Avoid generating empty UData structs */
382 } __ReplyUData__upl_abort_t __attribute__((unused));
383#ifdef __MigPackStructs
384#pragma pack(pop)
385#endif
386
387#ifdef __MigPackStructs
388#pragma pack(push, 4)
389#endif
390 typedef struct {
391 mach_msg_header_t Head;
392 NDR_record_t NDR;
393 kern_return_t RetCode;
394 boolean_t empty;
395 } __Reply__upl_abort_range_t __attribute__((unused));
396#ifdef __MigPackStructs
397#pragma pack(pop)
398#endif
399/* Struct for kernel processed data (Header + Descriptors) */
400#ifdef __MigPackStructs
401#pragma pack(push, 4)
402#endif
403 typedef struct {
404 mach_msg_header_t Head;
405 } __ReplyKData__upl_abort_range_t __attribute__((unused));
406#ifdef __MigPackStructs
407#pragma pack(pop)
408#endif
409/* Struct for pure user data */
410#ifdef __MigPackStructs
411#pragma pack(push, 4)
412#endif
413 typedef struct {
414 NDR_record_t NDR;
415 kern_return_t RetCode;
416 boolean_t empty;
417 char padding[0]; /* Avoid generating empty UData structs */
418 } __ReplyUData__upl_abort_range_t __attribute__((unused));
419#ifdef __MigPackStructs
420#pragma pack(pop)
421#endif
422
423#ifdef __MigPackStructs
424#pragma pack(push, 4)
425#endif
426 typedef struct {
427 mach_msg_header_t Head;
428 NDR_record_t NDR;
429 kern_return_t RetCode;
430 } __Reply__upl_commit_t __attribute__((unused));
431#ifdef __MigPackStructs
432#pragma pack(pop)
433#endif
434/* Struct for kernel processed data (Header + Descriptors) */
435#ifdef __MigPackStructs
436#pragma pack(push, 4)
437#endif
438 typedef struct {
439 mach_msg_header_t Head;
440 } __ReplyKData__upl_commit_t __attribute__((unused));
441#ifdef __MigPackStructs
442#pragma pack(pop)
443#endif
444/* Struct for pure user data */
445#ifdef __MigPackStructs
446#pragma pack(push, 4)
447#endif
448 typedef struct {
449 NDR_record_t NDR;
450 kern_return_t RetCode;
451 char padding[0]; /* Avoid generating empty UData structs */
452 } __ReplyUData__upl_commit_t __attribute__((unused));
453#ifdef __MigPackStructs
454#pragma pack(pop)
455#endif
456
457#ifdef __MigPackStructs
458#pragma pack(push, 4)
459#endif
460 typedef struct {
461 mach_msg_header_t Head;
462 NDR_record_t NDR;
463 kern_return_t RetCode;
464 boolean_t empty;
465 } __Reply__upl_commit_range_t __attribute__((unused));
466#ifdef __MigPackStructs
467#pragma pack(pop)
468#endif
469/* Struct for kernel processed data (Header + Descriptors) */
470#ifdef __MigPackStructs
471#pragma pack(push, 4)
472#endif
473 typedef struct {
474 mach_msg_header_t Head;
475 } __ReplyKData__upl_commit_range_t __attribute__((unused));
476#ifdef __MigPackStructs
477#pragma pack(pop)
478#endif
479/* Struct for pure user data */
480#ifdef __MigPackStructs
481#pragma pack(push, 4)
482#endif
483 typedef struct {
484 NDR_record_t NDR;
485 kern_return_t RetCode;
486 boolean_t empty;
487 char padding[0]; /* Avoid generating empty UData structs */
488 } __ReplyUData__upl_commit_range_t __attribute__((unused));
489#ifdef __MigPackStructs
490#pragma pack(pop)
491#endif
492#endif /* !__Reply__upl_subsystem__defined */
493
494
495/* union of all replies */
496
497#ifndef __ReplyUnion__upl_subsystem__defined
498#define __ReplyUnion__upl_subsystem__defined
499union __ReplyUnion__upl_subsystem {
500 __Reply__upl_abort_t Reply_upl_abort;
501 __Reply__upl_abort_range_t Reply_upl_abort_range;
502 __Reply__upl_commit_t Reply_upl_commit;
503 __Reply__upl_commit_range_t Reply_upl_commit_range;
504};
505#endif /* __ReplyUnion__upl_subsystem__defined */
506
507#ifndef subsystem_to_name_map_upl
508#define subsystem_to_name_map_upl \
509 { "upl_abort", 2050 },\
510 { "upl_abort_range", 2051 },\
511 { "upl_commit", 2052 },\
512 { "upl_commit_range", 2053 }
513#endif
514
515#ifdef __AfterMigServerHeader
516__AfterMigServerHeader
517#endif /* __AfterMigServerHeader */
518
519#endif /* _upl_server_ */
520