]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
8f6c56a5 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
8f6c56a5 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
8ad349bb | 24 | * limitations under the License. |
8f6c56a5 A |
25 | * |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
1c79356b A |
27 | */ |
28 | /* | |
29 | * @OSF_COPYRIGHT@ | |
30 | */ | |
31 | ||
32 | /* | |
33 | * Mach MIG Subsystem Interfaces | |
34 | */ | |
35 | ||
36 | #ifndef _MACH_MIG_H_ | |
37 | #define _MACH_MIG_H_ | |
38 | ||
9bccf70c | 39 | #include <stdint.h> |
1c79356b A |
40 | #include <mach/port.h> |
41 | #include <mach/message.h> | |
9bccf70c | 42 | #include <mach/vm_types.h> |
1c79356b | 43 | |
91447636 A |
44 | #include <sys/cdefs.h> |
45 | ||
46 | #if defined(MACH_KERNEL) | |
47 | ||
48 | /* Turn MIG type checking on by default for kernel */ | |
49 | #define __MigTypeCheck 1 | |
50 | #define __MigKernelSpecificCode 1 | |
51 | #define _MIG_KERNEL_SPECIFIC_CODE_ 1 | |
52 | ||
53 | /* Otherwise check legacy setting (temporary) */ | |
54 | #elif defined(TypeCheck) | |
55 | ||
56 | #define __MigTypeCheck TypeCheck | |
57 | ||
58 | #endif /* defined(TypeCheck) */ | |
59 | ||
60 | /* | |
89b3af67 | 61 | * Pack MIG message structs. |
91447636 A |
62 | * This is an indicator of the need to view shared structs in a |
63 | * binary-compatible format - and MIG message structs are no different. | |
64 | */ | |
91447636 | 65 | #define __MigPackStructs 1 |
91447636 | 66 | |
1c79356b A |
67 | /* |
68 | * Definition for MIG-generated server stub routines. These routines | |
69 | * unpack the request message, call the server procedure, and pack the | |
70 | * reply message. | |
71 | */ | |
72 | typedef void (*mig_stub_routine_t) (mach_msg_header_t *InHeadP, | |
73 | mach_msg_header_t *OutHeadP); | |
74 | ||
75 | typedef mig_stub_routine_t mig_routine_t; | |
76 | ||
77 | /* | |
0b4e3aa0 A |
78 | * Definition for MIG-generated server routine. This routine takes a |
79 | * message, and returns the appropriate stub function for handling that | |
80 | * message. | |
81 | */ | |
82 | typedef mig_routine_t (*mig_server_routine_t) (mach_msg_header_t *InHeadP); | |
83 | ||
84 | /* | |
85 | * Generic definition for implementation routines. These routines do | |
86 | * the real work associated with this request. This generic type is | |
87 | * used for keeping the pointers in the subsystem array. | |
1c79356b A |
88 | */ |
89 | typedef kern_return_t (*mig_impl_routine_t)(void); | |
90 | ||
9bccf70c A |
91 | typedef mach_msg_type_descriptor_t routine_arg_descriptor; |
92 | typedef mach_msg_type_descriptor_t *routine_arg_descriptor_t; | |
93 | typedef mach_msg_type_descriptor_t *mig_routine_arg_descriptor_t; | |
94 | ||
95 | #define MIG_ROUTINE_ARG_DESCRIPTOR_NULL ((mig_routine_arg_descriptor_t)0) | |
96 | ||
97 | struct routine_descriptor { | |
98 | mig_impl_routine_t impl_routine; /* Server work func pointer */ | |
99 | mig_stub_routine_t stub_routine; /* Unmarshalling func pointer */ | |
100 | unsigned int argc; /* Number of argument words */ | |
101 | unsigned int descr_count; /* Number complex descriptors */ | |
102 | routine_arg_descriptor_t | |
103 | arg_descr; /* pointer to descriptor array*/ | |
104 | unsigned int max_reply_msg; /* Max size for reply msg */ | |
105 | }; | |
106 | typedef struct routine_descriptor *routine_descriptor_t; | |
107 | ||
108 | typedef struct routine_descriptor mig_routine_descriptor; | |
109 | typedef mig_routine_descriptor *mig_routine_descriptor_t; | |
110 | ||
111 | #define MIG_ROUTINE_DESCRIPTOR_NULL ((mig_routine_descriptor_t)0) | |
0b4e3aa0 A |
112 | |
113 | typedef struct mig_subsystem { | |
9bccf70c A |
114 | mig_server_routine_t server; /* pointer to demux routine */ |
115 | mach_msg_id_t start; /* Min routine number */ | |
116 | mach_msg_id_t end; /* Max routine number + 1 */ | |
117 | mach_msg_size_t maxsize; /* Max reply message size */ | |
118 | vm_address_t reserved; /* reserved for MIG use */ | |
119 | mig_routine_descriptor | |
120 | routine[1]; /* Routine descriptor array */ | |
0b4e3aa0 A |
121 | } *mig_subsystem_t; |
122 | ||
9bccf70c A |
123 | #define MIG_SUBSYSTEM_NULL ((mig_subsystem_t)0) |
124 | ||
125 | typedef struct mig_symtab { | |
126 | char *ms_routine_name; | |
127 | int ms_routine_number; | |
128 | void (*ms_routine)(void); /* Since the functions in the | |
129 | * symbol table have unknown | |
130 | * signatures, this is the best | |
131 | * we can do... | |
132 | */ | |
133 | } mig_symtab_t; | |
134 | ||
91447636 | 135 | #ifdef PRIVATE |
9bccf70c | 136 | |
91447636 | 137 | /* MIG object runtime - not ready for public consumption */ |
9bccf70c | 138 | |
91447636 | 139 | #ifdef KERNEL_PRIVATE |
9bccf70c | 140 | |
0b4e3aa0 A |
141 | /* |
142 | * MIG object runtime definitions | |
143 | * | |
144 | * Conforming MIG subsystems may enable this support to get | |
145 | * significant assistance from the base mig_object_t implementation. | |
146 | * | |
147 | * Support includes: | |
148 | * - Transparency from port manipulation. | |
149 | * - Dymanic port allocation on first "remoting" of an object. | |
150 | * - Reference conversions from object to port and vice versa. | |
151 | * - Automatic port deallocation on no-more-senders. | |
152 | * - Support for multiple server implementations in a single space. | |
153 | * - Messaging bypass for local servers. | |
154 | * - Automatic hookup to base dispatch mechanism. | |
155 | * - General notification support | |
156 | * Coming soon: | |
157 | * - User-level support | |
158 | */ | |
9bccf70c | 159 | typedef unsigned int mig_notify_type_t; |
0b4e3aa0 A |
160 | |
161 | typedef struct MIGIID { | |
162 | unsigned long data1; | |
163 | unsigned short data2; | |
164 | unsigned short data3; | |
165 | unsigned char data4[8]; | |
166 | } MIGIID; | |
167 | ||
168 | typedef struct IMIGObjectVtbl IMIGObjectVtbl; | |
169 | typedef struct IMIGNotifyObjectVtbl IMIGNotifyObjectVtbl; | |
170 | ||
171 | typedef struct IMIGObject { | |
91447636 | 172 | const IMIGObjectVtbl *pVtbl; |
0b4e3aa0 A |
173 | } IMIGObject; |
174 | ||
175 | typedef struct IMIGNotifyObject { | |
91447636 | 176 | const IMIGNotifyObjectVtbl *pVtbl; |
0b4e3aa0 A |
177 | } IMIGNotifyObject; |
178 | ||
179 | struct IMIGObjectVtbl { | |
180 | kern_return_t (*QueryInterface)( | |
181 | IMIGObject *object, | |
182 | const MIGIID *iid, | |
183 | void **ppv); | |
184 | ||
185 | unsigned long (*AddRef)( | |
186 | IMIGObject *object); | |
187 | ||
188 | unsigned long (*Release)( | |
189 | IMIGObject *object); | |
190 | ||
191 | unsigned long (*GetServer)( | |
192 | IMIGObject *object, | |
193 | mig_server_routine_t *server); | |
194 | ||
195 | boolean_t (*RaiseNotification)( | |
196 | IMIGObject *object, | |
197 | mig_notify_type_t notify_type); | |
198 | ||
199 | boolean_t (*RequestNotification)( | |
200 | IMIGObject *object, | |
201 | IMIGNotifyObject *notify, | |
202 | mig_notify_type_t notify_type); | |
203 | }; | |
204 | ||
205 | /* | |
206 | * IMIGNotifyObject | |
207 | * | |
208 | * A variant of the IMIGObject interface that is a sink for | |
209 | * MIG notifications. | |
210 | * | |
211 | * A reference is held on both the subject MIGObject and the target | |
212 | * MIGNotifyObject. Because of this, care must be exercised to avoid | |
213 | * reference cycles. Once a notification is raised, the object | |
214 | * reference is returned and the request must be re-requested (if | |
215 | * desired). | |
216 | * | |
217 | * One interesting note: because this interface is itself a MIG | |
218 | * object, one may request notification about state changes in | |
219 | * the MIGNotifyObject itself. | |
220 | */ | |
221 | struct IMIGNotifyObjectVtbl { | |
222 | kern_return_t (*QueryInterface)( | |
223 | IMIGNotifyObject *notify, | |
224 | const MIGIID *iid, | |
225 | void **ppv); | |
226 | ||
227 | unsigned long (*AddRef)( | |
228 | IMIGNotifyObject *notify); | |
229 | ||
230 | unsigned long (*Release)( | |
231 | IMIGNotifyObject *notify); | |
232 | ||
233 | unsigned long (*GetServer)( | |
234 | IMIGNotifyObject *notify, | |
235 | mig_server_routine_t *server); | |
236 | ||
237 | boolean_t (*RaiseNotification)( | |
238 | IMIGNotifyObject *notify, | |
239 | mig_notify_type_t notify_type); | |
240 | ||
241 | boolean_t (*RequestNotification)( | |
242 | IMIGNotifyObject *notify, | |
243 | IMIGNotifyObject *notify_notify, | |
244 | mig_notify_type_t notify_type); | |
245 | ||
246 | void (*HandleNotification)( | |
247 | IMIGNotifyObject *notify, | |
248 | IMIGObject *object, | |
249 | mig_notify_type_t notify_type); | |
250 | }; | |
251 | ||
91447636 A |
252 | #endif /* KERNEL_PRIVATE */ |
253 | #endif /* PRIVATE */ | |
254 | ||
255 | __BEGIN_DECLS | |
256 | ||
257 | /* Client side reply port allocate */ | |
258 | extern mach_port_t mig_get_reply_port(void); | |
259 | ||
260 | /* Client side reply port deallocate */ | |
261 | extern void mig_dealloc_reply_port(mach_port_t reply_port); | |
262 | ||
263 | /* Client side reply port "deallocation" */ | |
264 | extern void mig_put_reply_port(mach_port_t reply_port); | |
265 | ||
266 | /* Bounded string copy */ | |
267 | extern int mig_strncpy(char *dest, const char *src, int len); | |
268 | ||
269 | #ifdef KERNEL_PRIVATE | |
270 | ||
271 | /* Allocate memory for out-of-stack mig structures */ | |
272 | extern char *mig_user_allocate(vm_size_t size); | |
273 | ||
274 | /* Deallocate memory used for out-of-stack mig structures */ | |
275 | extern void mig_user_deallocate(char *data, vm_size_t size); | |
276 | ||
277 | #else | |
278 | ||
279 | /* Allocate memory for out-of-line mig structures */ | |
280 | extern void mig_allocate(vm_address_t *, vm_size_t); | |
281 | ||
282 | /* Deallocate memory used for out-of-line mig structures */ | |
283 | extern void mig_deallocate(vm_address_t, vm_size_t); | |
9bccf70c | 284 | |
0b4e3aa0 | 285 | #endif /* KERNEL_PRIVATE */ |
1c79356b | 286 | |
91447636 A |
287 | __END_DECLS |
288 | ||
289 | #endif /* _MACH_MIG_H_ */ |