2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
23 * @APPLE_LICENSE_HEADER_END@
30 * Mach MIG Subsystem Interfaces
37 #include <mach/port.h>
38 #include <mach/message.h>
39 #include <mach/vm_types.h>
42 * Definition for MIG-generated server stub routines. These routines
43 * unpack the request message, call the server procedure, and pack the
46 typedef void (*mig_stub_routine_t
) (mach_msg_header_t
*InHeadP
,
47 mach_msg_header_t
*OutHeadP
);
49 typedef mig_stub_routine_t mig_routine_t
;
52 * Definition for MIG-generated server routine. This routine takes a
53 * message, and returns the appropriate stub function for handling that
56 typedef mig_routine_t (*mig_server_routine_t
) (mach_msg_header_t
*InHeadP
);
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.
63 typedef kern_return_t (*mig_impl_routine_t
)(void);
65 typedef mach_msg_type_descriptor_t routine_arg_descriptor
;
66 typedef mach_msg_type_descriptor_t
*routine_arg_descriptor_t
;
67 typedef mach_msg_type_descriptor_t
*mig_routine_arg_descriptor_t
;
69 #define MIG_ROUTINE_ARG_DESCRIPTOR_NULL ((mig_routine_arg_descriptor_t)0)
71 struct 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 */
80 typedef struct routine_descriptor
*routine_descriptor_t
;
82 typedef struct routine_descriptor mig_routine_descriptor
;
83 typedef mig_routine_descriptor
*mig_routine_descriptor_t
;
85 #define MIG_ROUTINE_DESCRIPTOR_NULL ((mig_routine_descriptor_t)0)
87 typedef struct mig_subsystem
{
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 */
97 #define MIG_SUBSYSTEM_NULL ((mig_subsystem_t)0)
99 typedef 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
109 /* Client side reply port allocate */
110 extern mach_port_t
mig_get_reply_port(void);
112 /* Client side reply port deallocate */
113 extern void mig_dealloc_reply_port(mach_port_t reply_port
);
115 /* Client side reply port "deallocation" */
116 extern void mig_put_reply_port(mach_port_t reply_port
);
118 /* Bounded string copy */
119 extern int mig_strncpy(char *dest
, const char *src
, int len
);
121 #ifdef KERNEL_PRIVATE
122 #include <sys/appleapiopts.h>
124 /* Allocate memory for out-of-stack mig structures */
125 extern char *mig_user_allocate(vm_size_t size
);
127 /* Deallocate memory used for out-of-stack mig structures */
128 extern void mig_user_deallocate(char *data
, vm_size_t size
);
130 #ifdef __APPLE_API_EVOLVING
132 * MIG object runtime definitions
134 * Conforming MIG subsystems may enable this support to get
135 * significant assistance from the base mig_object_t implementation.
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
147 * - User-level support
149 typedef unsigned int mig_notify_type_t
;
151 typedef struct MIGIID
{
153 unsigned short data2
;
154 unsigned short data3
;
155 unsigned char data4
[8];
158 typedef struct IMIGObjectVtbl IMIGObjectVtbl
;
159 typedef struct IMIGNotifyObjectVtbl IMIGNotifyObjectVtbl
;
161 typedef struct IMIGObject
{
162 IMIGObjectVtbl
*pVtbl
;
165 typedef struct IMIGNotifyObject
{
166 IMIGNotifyObjectVtbl
*pVtbl
;
169 struct IMIGObjectVtbl
{
170 kern_return_t (*QueryInterface
)(
175 unsigned long (*AddRef
)(
178 unsigned long (*Release
)(
181 unsigned long (*GetServer
)(
183 mig_server_routine_t
*server
);
185 boolean_t (*RaiseNotification
)(
187 mig_notify_type_t notify_type
);
189 boolean_t (*RequestNotification
)(
191 IMIGNotifyObject
*notify
,
192 mig_notify_type_t notify_type
);
198 * A variant of the IMIGObject interface that is a sink for
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
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.
211 struct IMIGNotifyObjectVtbl
{
212 kern_return_t (*QueryInterface
)(
213 IMIGNotifyObject
*notify
,
217 unsigned long (*AddRef
)(
218 IMIGNotifyObject
*notify
);
220 unsigned long (*Release
)(
221 IMIGNotifyObject
*notify
);
223 unsigned long (*GetServer
)(
224 IMIGNotifyObject
*notify
,
225 mig_server_routine_t
*server
);
227 boolean_t (*RaiseNotification
)(
228 IMIGNotifyObject
*notify
,
229 mig_notify_type_t notify_type
);
231 boolean_t (*RequestNotification
)(
232 IMIGNotifyObject
*notify
,
233 IMIGNotifyObject
*notify_notify
,
234 mig_notify_type_t notify_type
);
236 void (*HandleNotification
)(
237 IMIGNotifyObject
*notify
,
239 mig_notify_type_t notify_type
);
242 #endif /* __APPLE_API_EVOLVING */
244 #endif /* KERNEL_PRIVATE */
246 #endif /* _MACH_MIG_H_ */