2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
27 * Mach MIG Subsystem Interfaces
34 #include <mach/port.h>
35 #include <mach/message.h>
36 #include <mach/vm_types.h>
39 * Definition for MIG-generated server stub routines. These routines
40 * unpack the request message, call the server procedure, and pack the
43 typedef void (*mig_stub_routine_t
) (mach_msg_header_t
*InHeadP
,
44 mach_msg_header_t
*OutHeadP
);
46 typedef mig_stub_routine_t mig_routine_t
;
49 * Definition for MIG-generated server routine. This routine takes a
50 * message, and returns the appropriate stub function for handling that
53 typedef mig_routine_t (*mig_server_routine_t
) (mach_msg_header_t
*InHeadP
);
56 * Generic definition for implementation routines. These routines do
57 * the real work associated with this request. This generic type is
58 * used for keeping the pointers in the subsystem array.
60 typedef kern_return_t (*mig_impl_routine_t
)(void);
62 typedef mach_msg_type_descriptor_t routine_arg_descriptor
;
63 typedef mach_msg_type_descriptor_t
*routine_arg_descriptor_t
;
64 typedef mach_msg_type_descriptor_t
*mig_routine_arg_descriptor_t
;
66 #define MIG_ROUTINE_ARG_DESCRIPTOR_NULL ((mig_routine_arg_descriptor_t)0)
68 struct routine_descriptor
{
69 mig_impl_routine_t impl_routine
; /* Server work func pointer */
70 mig_stub_routine_t stub_routine
; /* Unmarshalling func pointer */
71 unsigned int argc
; /* Number of argument words */
72 unsigned int descr_count
; /* Number complex descriptors */
73 routine_arg_descriptor_t
74 arg_descr
; /* pointer to descriptor array*/
75 unsigned int max_reply_msg
; /* Max size for reply msg */
77 typedef struct routine_descriptor
*routine_descriptor_t
;
79 typedef struct routine_descriptor mig_routine_descriptor
;
80 typedef mig_routine_descriptor
*mig_routine_descriptor_t
;
82 #define MIG_ROUTINE_DESCRIPTOR_NULL ((mig_routine_descriptor_t)0)
84 typedef struct mig_subsystem
{
85 mig_server_routine_t server
; /* pointer to demux routine */
86 mach_msg_id_t start
; /* Min routine number */
87 mach_msg_id_t end
; /* Max routine number + 1 */
88 mach_msg_size_t maxsize
; /* Max reply message size */
89 vm_address_t reserved
; /* reserved for MIG use */
90 mig_routine_descriptor
91 routine
[1]; /* Routine descriptor array */
94 #define MIG_SUBSYSTEM_NULL ((mig_subsystem_t)0)
96 typedef struct mig_symtab
{
97 char *ms_routine_name
;
98 int ms_routine_number
;
99 void (*ms_routine
)(void); /* Since the functions in the
100 * symbol table have unknown
101 * signatures, this is the best
106 /* Client side reply port allocate */
107 extern mach_port_t
mig_get_reply_port(void);
109 /* Client side reply port deallocate */
110 extern void mig_dealloc_reply_port(mach_port_t reply_port
);
112 /* Client side reply port "deallocation" */
113 extern void mig_put_reply_port(mach_port_t reply_port
);
115 /* Bounded string copy */
116 extern int mig_strncpy(char *dest
, const char *src
, int len
);
118 #ifdef KERNEL_PRIVATE
119 #include <sys/appleapiopts.h>
121 /* Allocate memory for out-of-stack mig structures */
122 extern char *mig_user_allocate(vm_size_t size
);
124 /* Deallocate memory used for out-of-stack mig structures */
125 extern void mig_user_deallocate(char *data
, vm_size_t size
);
127 #ifdef __APPLE_API_EVOLVING
129 * MIG object runtime definitions
131 * Conforming MIG subsystems may enable this support to get
132 * significant assistance from the base mig_object_t implementation.
135 * - Transparency from port manipulation.
136 * - Dymanic port allocation on first "remoting" of an object.
137 * - Reference conversions from object to port and vice versa.
138 * - Automatic port deallocation on no-more-senders.
139 * - Support for multiple server implementations in a single space.
140 * - Messaging bypass for local servers.
141 * - Automatic hookup to base dispatch mechanism.
142 * - General notification support
144 * - User-level support
146 typedef unsigned int mig_notify_type_t
;
148 typedef struct MIGIID
{
150 unsigned short data2
;
151 unsigned short data3
;
152 unsigned char data4
[8];
155 typedef struct IMIGObjectVtbl IMIGObjectVtbl
;
156 typedef struct IMIGNotifyObjectVtbl IMIGNotifyObjectVtbl
;
158 typedef struct IMIGObject
{
159 IMIGObjectVtbl
*pVtbl
;
162 typedef struct IMIGNotifyObject
{
163 IMIGNotifyObjectVtbl
*pVtbl
;
166 struct IMIGObjectVtbl
{
167 kern_return_t (*QueryInterface
)(
172 unsigned long (*AddRef
)(
175 unsigned long (*Release
)(
178 unsigned long (*GetServer
)(
180 mig_server_routine_t
*server
);
182 boolean_t (*RaiseNotification
)(
184 mig_notify_type_t notify_type
);
186 boolean_t (*RequestNotification
)(
188 IMIGNotifyObject
*notify
,
189 mig_notify_type_t notify_type
);
195 * A variant of the IMIGObject interface that is a sink for
198 * A reference is held on both the subject MIGObject and the target
199 * MIGNotifyObject. Because of this, care must be exercised to avoid
200 * reference cycles. Once a notification is raised, the object
201 * reference is returned and the request must be re-requested (if
204 * One interesting note: because this interface is itself a MIG
205 * object, one may request notification about state changes in
206 * the MIGNotifyObject itself.
208 struct IMIGNotifyObjectVtbl
{
209 kern_return_t (*QueryInterface
)(
210 IMIGNotifyObject
*notify
,
214 unsigned long (*AddRef
)(
215 IMIGNotifyObject
*notify
);
217 unsigned long (*Release
)(
218 IMIGNotifyObject
*notify
);
220 unsigned long (*GetServer
)(
221 IMIGNotifyObject
*notify
,
222 mig_server_routine_t
*server
);
224 boolean_t (*RaiseNotification
)(
225 IMIGNotifyObject
*notify
,
226 mig_notify_type_t notify_type
);
228 boolean_t (*RequestNotification
)(
229 IMIGNotifyObject
*notify
,
230 IMIGNotifyObject
*notify_notify
,
231 mig_notify_type_t notify_type
);
233 void (*HandleNotification
)(
234 IMIGNotifyObject
*notify
,
236 mig_notify_type_t notify_type
);
239 #endif /* __APPLE_API_EVOLVING */
241 #endif /* KERNEL_PRIVATE */
243 #endif /* _MACH_MIG_H_ */