]>
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 | /* | |
8f6c56a5 | 61 | * Pack MIG message structs if we have Power alignment of 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 | */ | |
8f6c56a5 | 65 | #if __DARWIN_ALIGN_POWER |
91447636 | 66 | #define __MigPackStructs 1 |
8f6c56a5 | 67 | #endif |
91447636 | 68 | |
1c79356b A |
69 | /* |
70 | * Definition for MIG-generated server stub routines. These routines | |
71 | * unpack the request message, call the server procedure, and pack the | |
72 | * reply message. | |
73 | */ | |
74 | typedef void (*mig_stub_routine_t) (mach_msg_header_t *InHeadP, | |
75 | mach_msg_header_t *OutHeadP); | |
76 | ||
77 | typedef mig_stub_routine_t mig_routine_t; | |
78 | ||
79 | /* | |
0b4e3aa0 A |
80 | * Definition for MIG-generated server routine. This routine takes a |
81 | * message, and returns the appropriate stub function for handling that | |
82 | * message. | |
83 | */ | |
84 | typedef mig_routine_t (*mig_server_routine_t) (mach_msg_header_t *InHeadP); | |
85 | ||
86 | /* | |
87 | * Generic definition for implementation routines. These routines do | |
88 | * the real work associated with this request. This generic type is | |
89 | * used for keeping the pointers in the subsystem array. | |
1c79356b A |
90 | */ |
91 | typedef kern_return_t (*mig_impl_routine_t)(void); | |
92 | ||
9bccf70c A |
93 | typedef mach_msg_type_descriptor_t routine_arg_descriptor; |
94 | typedef mach_msg_type_descriptor_t *routine_arg_descriptor_t; | |
95 | typedef mach_msg_type_descriptor_t *mig_routine_arg_descriptor_t; | |
96 | ||
97 | #define MIG_ROUTINE_ARG_DESCRIPTOR_NULL ((mig_routine_arg_descriptor_t)0) | |
98 | ||
99 | struct routine_descriptor { | |
100 | mig_impl_routine_t impl_routine; /* Server work func pointer */ | |
101 | mig_stub_routine_t stub_routine; /* Unmarshalling func pointer */ | |
102 | unsigned int argc; /* Number of argument words */ | |
103 | unsigned int descr_count; /* Number complex descriptors */ | |
104 | routine_arg_descriptor_t | |
105 | arg_descr; /* pointer to descriptor array*/ | |
106 | unsigned int max_reply_msg; /* Max size for reply msg */ | |
107 | }; | |
108 | typedef struct routine_descriptor *routine_descriptor_t; | |
109 | ||
110 | typedef struct routine_descriptor mig_routine_descriptor; | |
111 | typedef mig_routine_descriptor *mig_routine_descriptor_t; | |
112 | ||
113 | #define MIG_ROUTINE_DESCRIPTOR_NULL ((mig_routine_descriptor_t)0) | |
0b4e3aa0 A |
114 | |
115 | typedef struct mig_subsystem { | |
9bccf70c A |
116 | mig_server_routine_t server; /* pointer to demux routine */ |
117 | mach_msg_id_t start; /* Min routine number */ | |
118 | mach_msg_id_t end; /* Max routine number + 1 */ | |
119 | mach_msg_size_t maxsize; /* Max reply message size */ | |
120 | vm_address_t reserved; /* reserved for MIG use */ | |
121 | mig_routine_descriptor | |
122 | routine[1]; /* Routine descriptor array */ | |
0b4e3aa0 A |
123 | } *mig_subsystem_t; |
124 | ||
9bccf70c A |
125 | #define MIG_SUBSYSTEM_NULL ((mig_subsystem_t)0) |
126 | ||
127 | typedef struct mig_symtab { | |
128 | char *ms_routine_name; | |
129 | int ms_routine_number; | |
130 | void (*ms_routine)(void); /* Since the functions in the | |
131 | * symbol table have unknown | |
132 | * signatures, this is the best | |
133 | * we can do... | |
134 | */ | |
135 | } mig_symtab_t; | |
136 | ||
91447636 | 137 | #ifdef PRIVATE |
9bccf70c | 138 | |
91447636 | 139 | /* MIG object runtime - not ready for public consumption */ |
9bccf70c | 140 | |
91447636 | 141 | #ifdef KERNEL_PRIVATE |
9bccf70c | 142 | |
0b4e3aa0 A |
143 | /* |
144 | * MIG object runtime definitions | |
145 | * | |
146 | * Conforming MIG subsystems may enable this support to get | |
147 | * significant assistance from the base mig_object_t implementation. | |
148 | * | |
149 | * Support includes: | |
150 | * - Transparency from port manipulation. | |
151 | * - Dymanic port allocation on first "remoting" of an object. | |
152 | * - Reference conversions from object to port and vice versa. | |
153 | * - Automatic port deallocation on no-more-senders. | |
154 | * - Support for multiple server implementations in a single space. | |
155 | * - Messaging bypass for local servers. | |
156 | * - Automatic hookup to base dispatch mechanism. | |
157 | * - General notification support | |
158 | * Coming soon: | |
159 | * - User-level support | |
160 | */ | |
9bccf70c | 161 | typedef unsigned int mig_notify_type_t; |
0b4e3aa0 A |
162 | |
163 | typedef struct MIGIID { | |
164 | unsigned long data1; | |
165 | unsigned short data2; | |
166 | unsigned short data3; | |
167 | unsigned char data4[8]; | |
168 | } MIGIID; | |
169 | ||
170 | typedef struct IMIGObjectVtbl IMIGObjectVtbl; | |
171 | typedef struct IMIGNotifyObjectVtbl IMIGNotifyObjectVtbl; | |
172 | ||
173 | typedef struct IMIGObject { | |
91447636 | 174 | const IMIGObjectVtbl *pVtbl; |
0b4e3aa0 A |
175 | } IMIGObject; |
176 | ||
177 | typedef struct IMIGNotifyObject { | |
91447636 | 178 | const IMIGNotifyObjectVtbl *pVtbl; |
0b4e3aa0 A |
179 | } IMIGNotifyObject; |
180 | ||
181 | struct IMIGObjectVtbl { | |
182 | kern_return_t (*QueryInterface)( | |
183 | IMIGObject *object, | |
184 | const MIGIID *iid, | |
185 | void **ppv); | |
186 | ||
187 | unsigned long (*AddRef)( | |
188 | IMIGObject *object); | |
189 | ||
190 | unsigned long (*Release)( | |
191 | IMIGObject *object); | |
192 | ||
193 | unsigned long (*GetServer)( | |
194 | IMIGObject *object, | |
195 | mig_server_routine_t *server); | |
196 | ||
197 | boolean_t (*RaiseNotification)( | |
198 | IMIGObject *object, | |
199 | mig_notify_type_t notify_type); | |
200 | ||
201 | boolean_t (*RequestNotification)( | |
202 | IMIGObject *object, | |
203 | IMIGNotifyObject *notify, | |
204 | mig_notify_type_t notify_type); | |
205 | }; | |
206 | ||
207 | /* | |
208 | * IMIGNotifyObject | |
209 | * | |
210 | * A variant of the IMIGObject interface that is a sink for | |
211 | * MIG notifications. | |
212 | * | |
213 | * A reference is held on both the subject MIGObject and the target | |
214 | * MIGNotifyObject. Because of this, care must be exercised to avoid | |
215 | * reference cycles. Once a notification is raised, the object | |
216 | * reference is returned and the request must be re-requested (if | |
217 | * desired). | |
218 | * | |
219 | * One interesting note: because this interface is itself a MIG | |
220 | * object, one may request notification about state changes in | |
221 | * the MIGNotifyObject itself. | |
222 | */ | |
223 | struct IMIGNotifyObjectVtbl { | |
224 | kern_return_t (*QueryInterface)( | |
225 | IMIGNotifyObject *notify, | |
226 | const MIGIID *iid, | |
227 | void **ppv); | |
228 | ||
229 | unsigned long (*AddRef)( | |
230 | IMIGNotifyObject *notify); | |
231 | ||
232 | unsigned long (*Release)( | |
233 | IMIGNotifyObject *notify); | |
234 | ||
235 | unsigned long (*GetServer)( | |
236 | IMIGNotifyObject *notify, | |
237 | mig_server_routine_t *server); | |
238 | ||
239 | boolean_t (*RaiseNotification)( | |
240 | IMIGNotifyObject *notify, | |
241 | mig_notify_type_t notify_type); | |
242 | ||
243 | boolean_t (*RequestNotification)( | |
244 | IMIGNotifyObject *notify, | |
245 | IMIGNotifyObject *notify_notify, | |
246 | mig_notify_type_t notify_type); | |
247 | ||
248 | void (*HandleNotification)( | |
249 | IMIGNotifyObject *notify, | |
250 | IMIGObject *object, | |
251 | mig_notify_type_t notify_type); | |
252 | }; | |
253 | ||
91447636 A |
254 | #endif /* KERNEL_PRIVATE */ |
255 | #endif /* PRIVATE */ | |
256 | ||
257 | __BEGIN_DECLS | |
258 | ||
259 | /* Client side reply port allocate */ | |
260 | extern mach_port_t mig_get_reply_port(void); | |
261 | ||
262 | /* Client side reply port deallocate */ | |
263 | extern void mig_dealloc_reply_port(mach_port_t reply_port); | |
264 | ||
265 | /* Client side reply port "deallocation" */ | |
266 | extern void mig_put_reply_port(mach_port_t reply_port); | |
267 | ||
268 | /* Bounded string copy */ | |
269 | extern int mig_strncpy(char *dest, const char *src, int len); | |
270 | ||
271 | #ifdef KERNEL_PRIVATE | |
272 | ||
273 | /* Allocate memory for out-of-stack mig structures */ | |
274 | extern char *mig_user_allocate(vm_size_t size); | |
275 | ||
276 | /* Deallocate memory used for out-of-stack mig structures */ | |
277 | extern void mig_user_deallocate(char *data, vm_size_t size); | |
278 | ||
279 | #else | |
280 | ||
281 | /* Allocate memory for out-of-line mig structures */ | |
282 | extern void mig_allocate(vm_address_t *, vm_size_t); | |
283 | ||
284 | /* Deallocate memory used for out-of-line mig structures */ | |
285 | extern void mig_deallocate(vm_address_t, vm_size_t); | |
9bccf70c | 286 | |
0b4e3aa0 | 287 | #endif /* KERNEL_PRIVATE */ |
1c79356b | 288 | |
91447636 A |
289 | __END_DECLS |
290 | ||
291 | #endif /* _MACH_MIG_H_ */ |