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