1#ifndef _memory_entry_server_
2#define _memory_entry_server_
3
4/* Module memory_entry */
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 memory_entry_MSG_COUNT
55#define memory_entry_MSG_COUNT 3
56#endif /* memory_entry_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
79#ifdef __BeforeMigServerHeader
80__BeforeMigServerHeader
81#endif /* __BeforeMigServerHeader */
82
83#ifndef MIG_SERVER_ROUTINE
84#define MIG_SERVER_ROUTINE
85#endif
86
87
88/* Routine mach_memory_entry_purgable_control */
89#ifdef mig_external
90mig_external
91#else
92extern
93#endif /* mig_external */
94MIG_SERVER_ROUTINE
95kern_return_t mach_memory_entry_purgable_control
96(
97 mem_entry_name_port_t mem_entry,
98 vm_purgable_t control,
99 int *state
100);
101
102/* Routine mach_memory_entry_access_tracking */
103#ifdef mig_external
104mig_external
105#else
106extern
107#endif /* mig_external */
108MIG_SERVER_ROUTINE
109kern_return_t mach_memory_entry_access_tracking
110(
111 mem_entry_name_port_t mem_entry,
112 int *access_tracking,
113 uint32_t *access_tracking_reads,
114 uint32_t *access_tracking_writes
115);
116
117/* Routine mach_memory_entry_ownership_from_user */
118#ifdef mig_external
119mig_external
120#else
121extern
122#endif /* mig_external */
123MIG_SERVER_ROUTINE
124kern_return_t mach_memory_entry_ownership_from_user
125(
126 mem_entry_name_port_t mem_entry,
127 mach_port_t owner,
128 int ledger_tag,
129 int ledger_flags
130);
131
132#ifdef mig_external
133mig_external
134#else
135extern
136#endif /* mig_external */
137boolean_t memory_entry_server(
138 mach_msg_header_t *InHeadP,
139 void *InDataP,
140 mach_msg_max_trailer_t *InTrailerP,
141 mach_msg_header_t *OutHeadP,
142 void *OutDataP);
143
144#ifdef mig_external
145mig_external
146#else
147extern
148#endif /* mig_external */
149mig_kern_routine_t memory_entry_server_routine(
150 mach_msg_header_t *InHeadP);
151
152
153/* Description of this kernel subsystem, for use in direct RPC */
154extern const struct memory_entry_subsystem {
155 mig_kern_server_routine_t kserver; /* Server routine */
156 mach_msg_id_t start; /* Min routine number */
157 mach_msg_id_t end; /* Max routine number + 1 */
158 unsigned int maxsize; /* Max msg size */
159 vm_address_t reserved; /* Reserved */
160 struct kern_routine_descriptor /* Array of routine descriptors */
161 kroutine[3];
162} memory_entry_subsystem;
163
164/* typedefs for all requests */
165
166#ifndef __Request__memory_entry_subsystem__defined
167#define __Request__memory_entry_subsystem__defined
168
169#ifdef __MigPackStructs
170#pragma pack(push, 4)
171#endif
172 typedef struct {
173 mach_msg_header_t Head;
174 NDR_record_t NDR;
175 vm_purgable_t control;
176 int state;
177 } __Request__mach_memory_entry_purgable_control_t __attribute__((unused));
178#ifdef __MigPackStructs
179#pragma pack(pop)
180#endif
181/* Struct for kernel processed data (Header + Descriptors) */
182#ifdef __MigPackStructs
183#pragma pack(push, 4)
184#endif
185 typedef struct {
186 mach_msg_header_t Head;
187 } __RequestKData__mach_memory_entry_purgable_control_t __attribute__((unused));
188#ifdef __MigPackStructs
189#pragma pack(pop)
190#endif
191/* Struct for pure user data */
192#ifdef __MigPackStructs
193#pragma pack(push, 4)
194#endif
195 typedef struct {
196 NDR_record_t NDR;
197 vm_purgable_t control;
198 int state;
199 char padding[0]; /* Avoid generating empty UData structs */
200 } __RequestUData__mach_memory_entry_purgable_control_t __attribute__((unused));
201#ifdef __MigPackStructs
202#pragma pack(pop)
203#endif
204
205#ifdef __MigPackStructs
206#pragma pack(push, 4)
207#endif
208 typedef struct {
209 mach_msg_header_t Head;
210 NDR_record_t NDR;
211 int access_tracking;
212 } __Request__mach_memory_entry_access_tracking_t __attribute__((unused));
213#ifdef __MigPackStructs
214#pragma pack(pop)
215#endif
216/* Struct for kernel processed data (Header + Descriptors) */
217#ifdef __MigPackStructs
218#pragma pack(push, 4)
219#endif
220 typedef struct {
221 mach_msg_header_t Head;
222 } __RequestKData__mach_memory_entry_access_tracking_t __attribute__((unused));
223#ifdef __MigPackStructs
224#pragma pack(pop)
225#endif
226/* Struct for pure user data */
227#ifdef __MigPackStructs
228#pragma pack(push, 4)
229#endif
230 typedef struct {
231 NDR_record_t NDR;
232 int access_tracking;
233 char padding[0]; /* Avoid generating empty UData structs */
234 } __RequestUData__mach_memory_entry_access_tracking_t __attribute__((unused));
235#ifdef __MigPackStructs
236#pragma pack(pop)
237#endif
238
239#ifdef __MigPackStructs
240#pragma pack(push, 4)
241#endif
242 typedef struct {
243 mach_msg_header_t Head;
244 /* start of the kernel processed data */
245 mach_msg_body_t msgh_body;
246 mach_msg_port_descriptor_t owner;
247 /* end of the kernel processed data */
248 NDR_record_t NDR;
249 int ledger_tag;
250 int ledger_flags;
251 } __Request__mach_memory_entry_ownership_from_user_t __attribute__((unused));
252#ifdef __MigPackStructs
253#pragma pack(pop)
254#endif
255/* Struct for kernel processed data (Header + Descriptors) */
256#ifdef __MigPackStructs
257#pragma pack(push, 4)
258#endif
259 typedef struct {
260 mach_msg_header_t Head;
261 mach_msg_body_t msgh_body;
262 mach_msg_port_descriptor_t owner;
263 } __RequestKData__mach_memory_entry_ownership_from_user_t __attribute__((unused));
264#ifdef __MigPackStructs
265#pragma pack(pop)
266#endif
267/* Struct for pure user data */
268#ifdef __MigPackStructs
269#pragma pack(push, 4)
270#endif
271 typedef struct {
272 NDR_record_t NDR;
273 int ledger_tag;
274 int ledger_flags;
275 char padding[0]; /* Avoid generating empty UData structs */
276 } __RequestUData__mach_memory_entry_ownership_from_user_t __attribute__((unused));
277#ifdef __MigPackStructs
278#pragma pack(pop)
279#endif
280#endif /* !__Request__memory_entry_subsystem__defined */
281
282
283/* union of all requests */
284
285#ifndef __RequestUnion__memory_entry_subsystem__defined
286#define __RequestUnion__memory_entry_subsystem__defined
287union __RequestUnion__memory_entry_subsystem {
288 __Request__mach_memory_entry_purgable_control_t Request_mach_memory_entry_purgable_control;
289 __Request__mach_memory_entry_access_tracking_t Request_mach_memory_entry_access_tracking;
290 __Request__mach_memory_entry_ownership_from_user_t Request_mach_memory_entry_ownership_from_user;
291};
292#endif /* __RequestUnion__memory_entry_subsystem__defined */
293/* typedefs for all replies */
294
295#ifndef __Reply__memory_entry_subsystem__defined
296#define __Reply__memory_entry_subsystem__defined
297
298#ifdef __MigPackStructs
299#pragma pack(push, 4)
300#endif
301 typedef struct {
302 mach_msg_header_t Head;
303 NDR_record_t NDR;
304 kern_return_t RetCode;
305 int state;
306 } __Reply__mach_memory_entry_purgable_control_t __attribute__((unused));
307#ifdef __MigPackStructs
308#pragma pack(pop)
309#endif
310/* Struct for kernel processed data (Header + Descriptors) */
311#ifdef __MigPackStructs
312#pragma pack(push, 4)
313#endif
314 typedef struct {
315 mach_msg_header_t Head;
316 } __ReplyKData__mach_memory_entry_purgable_control_t __attribute__((unused));
317#ifdef __MigPackStructs
318#pragma pack(pop)
319#endif
320/* Struct for pure user data */
321#ifdef __MigPackStructs
322#pragma pack(push, 4)
323#endif
324 typedef struct {
325 NDR_record_t NDR;
326 kern_return_t RetCode;
327 int state;
328 char padding[0]; /* Avoid generating empty UData structs */
329 } __ReplyUData__mach_memory_entry_purgable_control_t __attribute__((unused));
330#ifdef __MigPackStructs
331#pragma pack(pop)
332#endif
333
334#ifdef __MigPackStructs
335#pragma pack(push, 4)
336#endif
337 typedef struct {
338 mach_msg_header_t Head;
339 NDR_record_t NDR;
340 kern_return_t RetCode;
341 int access_tracking;
342 uint32_t access_tracking_reads;
343 uint32_t access_tracking_writes;
344 } __Reply__mach_memory_entry_access_tracking_t __attribute__((unused));
345#ifdef __MigPackStructs
346#pragma pack(pop)
347#endif
348/* Struct for kernel processed data (Header + Descriptors) */
349#ifdef __MigPackStructs
350#pragma pack(push, 4)
351#endif
352 typedef struct {
353 mach_msg_header_t Head;
354 } __ReplyKData__mach_memory_entry_access_tracking_t __attribute__((unused));
355#ifdef __MigPackStructs
356#pragma pack(pop)
357#endif
358/* Struct for pure user data */
359#ifdef __MigPackStructs
360#pragma pack(push, 4)
361#endif
362 typedef struct {
363 NDR_record_t NDR;
364 kern_return_t RetCode;
365 int access_tracking;
366 uint32_t access_tracking_reads;
367 uint32_t access_tracking_writes;
368 char padding[0]; /* Avoid generating empty UData structs */
369 } __ReplyUData__mach_memory_entry_access_tracking_t __attribute__((unused));
370#ifdef __MigPackStructs
371#pragma pack(pop)
372#endif
373
374#ifdef __MigPackStructs
375#pragma pack(push, 4)
376#endif
377 typedef struct {
378 mach_msg_header_t Head;
379 NDR_record_t NDR;
380 kern_return_t RetCode;
381 } __Reply__mach_memory_entry_ownership_from_user_t __attribute__((unused));
382#ifdef __MigPackStructs
383#pragma pack(pop)
384#endif
385/* Struct for kernel processed data (Header + Descriptors) */
386#ifdef __MigPackStructs
387#pragma pack(push, 4)
388#endif
389 typedef struct {
390 mach_msg_header_t Head;
391 } __ReplyKData__mach_memory_entry_ownership_from_user_t __attribute__((unused));
392#ifdef __MigPackStructs
393#pragma pack(pop)
394#endif
395/* Struct for pure user data */
396#ifdef __MigPackStructs
397#pragma pack(push, 4)
398#endif
399 typedef struct {
400 NDR_record_t NDR;
401 kern_return_t RetCode;
402 char padding[0]; /* Avoid generating empty UData structs */
403 } __ReplyUData__mach_memory_entry_ownership_from_user_t __attribute__((unused));
404#ifdef __MigPackStructs
405#pragma pack(pop)
406#endif
407#endif /* !__Reply__memory_entry_subsystem__defined */
408
409
410/* union of all replies */
411
412#ifndef __ReplyUnion__memory_entry_subsystem__defined
413#define __ReplyUnion__memory_entry_subsystem__defined
414union __ReplyUnion__memory_entry_subsystem {
415 __Reply__mach_memory_entry_purgable_control_t Reply_mach_memory_entry_purgable_control;
416 __Reply__mach_memory_entry_access_tracking_t Reply_mach_memory_entry_access_tracking;
417 __Reply__mach_memory_entry_ownership_from_user_t Reply_mach_memory_entry_ownership_from_user;
418};
419#endif /* __ReplyUnion__memory_entry_subsystem__defined */
420
421#ifndef subsystem_to_name_map_memory_entry
422#define subsystem_to_name_map_memory_entry \
423 { "mach_memory_entry_purgable_control", 4900 },\
424 { "mach_memory_entry_access_tracking", 4901 },\
425 { "mach_memory_entry_ownership_from_user", 4902 }
426#endif
427
428#ifdef __AfterMigServerHeader
429__AfterMigServerHeader
430#endif /* __AfterMigServerHeader */
431
432#endif /* _memory_entry_server_ */
433