1 /* 2 * Copyright 1991-1998 by Open Software Foundation, Inc. 3 * All Rights Reserved 4 * 5 * Permission to use, copy, modify, and distribute this software and 6 * its documentation for any purpose and without fee is hereby granted, 7 * provided that the above copyright notice appears in all copies and 8 * that both the copyright notice and this permission notice appear in 9 * supporting documentation. 10 * 11 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 12 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 * FOR A PARTICULAR PURPOSE. 14 * 15 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR 16 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 17 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, 18 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 19 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 */ 21 /* 22 * cmk1.1 23 */ 24 /* 25 * Mach Operating System 26 * Copyright (c) 1991,1990 Carnegie Mellon University 27 * All Rights Reserved. 28 * 29 * Permission to use, copy, modify and distribute this software and its 30 * documentation is hereby granted, provided that both the copyright 31 * notice and this permission notice appear in all copies of the 32 * software, derivative works or modified versions, and any portions 33 * thereof, and that both notices appear in supporting documentation. 34 * 35 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 36 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 37 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 38 * 39 * Carnegie Mellon requests users of this software to return to 40 * 41 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 42 * School of Computer Science 43 * Carnegie Mellon University 44 * Pittsburgh PA 15213-3890 45 * 46 * any improvements or extensions that they make and grant Carnegie Mellon 47 * the rights to redistribute these changes. 48 */ 49 /* 50 * 92/03/03 16:25:29 jeffreyh 51 * Changes from TRUNK 52 * [92/02/26 12:32:47 jeffreyh] 53 * 54 * 92/01/14 16:46:51 rpd 55 * Added itCheckFlags, itCheckDeallocate, itCheckIsLong. 56 * Removed itServerCopy. 57 * [92/01/09 rpd] 58 * 59 * 92/01/03 20:30:23 dbg 60 * Add flCountInOut. 61 * [91/11/11 dbg] 62 * 63 * 91/08/28 11:17:30 jsb 64 * Removed itMsgKindType. 65 * [91/08/12 rpd] 66 * 67 * 91/07/31 18:11:22 dbg 68 * Add flServerCopy. 69 * [91/06/05 dbg] 70 * 71 * Add itIndefinite. 72 * [91/04/10 dbg] 73 * 74 * Change itDeallocate to an enumerated type, to allow for 75 * user-specified deallocate flag. 76 * 77 * Add itCStringDecl. 78 * [91/04/03 dbg] 79 * 80 * 91/02/05 17:56:13 mrt 81 * Changed to new Mach copyright 82 * [91/02/01 17:56:19 mrt] 83 * 84 * 90/06/02 15:05:59 rpd 85 * Created for new IPC. 86 * [90/03/26 21:14:28 rpd] 87 * 88 * 07-Apr-89 Richard Draves (rpd) at Carnegie-Mellon University 89 * Extensive revamping. Added polymorphic arguments. 90 * Allow multiple variable-sized inline arguments in messages. 91 * 92 * 16-Nov-87 David Golub (dbg) at Carnegie-Mellon University 93 * Changed itVarArrayDecl to take a 'max' parameter. 94 * Added itDestructor. 95 * 96 * 18-Aug-87 Mary Thompson @ Carnegie Mellon 97 * Added itPortType 98 * Added itTidType 99 */ 100 101 #ifndef _TYPE_H 102 #define _TYPE_H 103 104 #include <sys/types.h> 105 #include <sys/param.h> 106 typedef u_int ipc_flags_t; 107 #include "strdefs.h" 108 109 110 /* 111 * MIG built-in types 112 */ 113 #define MACH_MSG_TYPE_UNSTRUCTURED 0 114 #define MACH_MSG_TYPE_BIT 0 115 #define MACH_MSG_TYPE_BOOLEAN 0 116 #define MACH_MSG_TYPE_INTEGER_8 9 117 #define MACH_MSG_TYPE_INTEGER_16 1 118 #define MACH_MSG_TYPE_INTEGER_32 2 119 #define MACH_MSG_TYPE_INTEGER_64 3 120 #define MACH_MSG_TYPE_CHAR 8 121 #define MACH_MSG_TYPE_BYTE 9 122 #define MACH_MSG_TYPE_REAL_32 10 123 #define MACH_MSG_TYPE_REAL_64 11 124 #define MACH_MSG_TYPE_STRING 12 125 #define MACH_MSG_TYPE_STRING_C 12 126 127 #define flNone (0x00) 128 #define flPhysicalCopy (0x01) /* Physical Copy specified */ 129 #define flOverwrite (0x02) /* Overwrite mode specified */ 130 #define flDealloc (0x04) /* Dealloc specified */ 131 #define flNotDealloc (0x08) /* NotDealloc specified */ 132 #define flMaybeDealloc (0x10) /* Dealloc[] specified */ 133 #define flSameCount (0x20) /* SamCount specified, used by co-bounded arrays */ 134 #define flCountInOut (0x40) /* CountInOut specified */ 135 #define flRetCode (0x80) /* RetCode specified */ 136 #define flAuto (0x100) /* Will not be referenced by server after RPC */ 137 #define flConst (0x200) /* Will not be modified by server during RPC */ 138 139 140 typedef enum dealloc { 141 d_NO, /* do not deallocate */ 142 d_YES, /* always deallocate */ 143 d_MAYBE /* deallocate according to parameter */ 144 } dealloc_t; 145 146 /* Convert dealloc_t to TRUE/FALSE */ 147 #define strdealloc(d) (strbool(d == d_YES)) 148 149 /* 150 * itName and itNext are internal fields (not used for code generation). 151 * They are only meaningful for types entered into the symbol table. 152 * The symbol table is a simple self-organizing linked list. 153 * 154 * The function itCheckDecl checks & fills in computed information. 155 * Every type actually used (pointed at by argType) is so processed. 156 * 157 * The itInName, itOutName, itSize, itNumber, fields correspond directly 158 * to mach_msg_type_t fields. 159 * For out-of-line variable sized types, itNumber is zero. For 160 * in-line variable sized types, itNumber is the maximum size of the 161 * array. itInName is the name value supplied to the kernel, 162 * and itOutName is the name value received from the kernel. 163 * When the type describes a MACH port, either or both may be 164 * MACH_MSG_TYPE_POLYMORPHIC, indicating a "polymorphic" name. 165 * For itInName, this means the user supplies the value with an argument. 166 * For itOutName, this means the value is returned in an argument. 167 * 168 * The itInNameStr and itOutNameStr fields contain "printing" versions 169 * of the itInName and itOutName values. The mapping from number->string 170 * is not into (eg, MACH_MSG_TYPE_UNSTRUCTURED/MACH_MSG_TYPE_BOOLEAN/ 171 * MACH_MSG_TYPE_BIT). These fields are used for code-generation and 172 * pretty-printing. 173 * 174 * itTypeSize is the calculated size of the C type, in bytes. 175 * itPadSize is the size of any padded needed after the data field. 176 * itMinTypeSize is the minimum size of the data field, including padding. 177 * For variable-length inline data, it is zero. 178 * 179 * itUserType, itServerType, itTransType are the C types used in 180 * code generation. itUserType is the C type passed to the user-side stub 181 * and used for msg declarations in the user-side stub. itServerType 182 * is the C type used for msg declarations in the server-side stub. 183 * itTransType is the C type passed to the server function by the 184 * server-side stub. Normally it differs from itServerType only when 185 * translation functions are defined. 186 * 187 * itInTrans and itOutTrans are translation functions. itInTrans 188 * takes itServerType values and returns itTransType values. itOutTrans 189 * takes itTransType vaulues and returns itServerType values. 190 * itDestructor is a finalization function applied to In arguments 191 * after the server-side stub calls the server function. It takes 192 * itTransType values. Any combination of these may be defined. 193 * 194 * The following type specification syntax modifies these values: 195 * type new = old 196 * ctype: name // itUserType and itServerType 197 * cusertype: itUserType 198 * cservertype: itServerType 199 * intran: itTransType itInTrans(itServerType) 200 * outtran: itServerType itOutTrans(itTransType) 201 * destructor: itDestructor(itTransType); 202 * 203 * At most one of itStruct and itString should be TRUE. If both are 204 * false, then this is assumed to be an array type (msg data is passed 205 * by reference). If itStruct is TRUE, then msg data is passed by value 206 * and can be assigned with =. If itString is TRUE, then the msg_data 207 * is a null-terminated string, assigned with strncpy. The itNumber 208 * value is a maximum length for the string; the msg field always 209 * takes up this much space. 210 * NoOptArray has been introduced for the cases where the special 211 * code generated for array assignments would not work (either because 212 * there is not a ctype (array of automagically generated MiG variables) 213 * or because we need to reference the single elements of the array 214 * (array of variable sized ool regions). 215 * 216 * itVarArray means this is a variable-sized array. If it is inline, 217 * then itStruct and itString are FALSE. If it is out-of-line, then 218 * itStruct is TRUE (because pointers can be assigned). 219 * 220 * itMigInLine means this is an indefinite-length array. Although the 221 * argument was not specified as out-of-line, MIG will send it anyway 222 * os an out-of-line. 223 * 224 * itUserKPDType (itServerKPDType) identify the type of Kernel Processed 225 * Data that we must deal with: it can be either "mach_msg_port_descriptor_t" 226 * or "mach_msg_ool_ports_descriptor_t" or "mach_msg_ool_descriptor_t". 227 * 228 * itKPD_Number is used any time a single argument require more than 229 * one Kernel Processed Data entry: i.e., an in-line array of ports, an array 230 * of pointers (out-of-line data) 231 * 232 * itElement points to any substructure that the type may have. 233 * It is only used with variable-sized array types. 234 */ 235 236 typedef struct ipc_type 237 { 238 identifier_t itName; /* Mig's name for this type */ 239 struct ipc_type *itNext; /* next type in symbol table */ 240 241 u_int itTypeSize; /* size of the C type */ 242 u_int itPadSize; /* amount of padding after data */ 243 u_int itMinTypeSize; /* minimal amount of space occupied by data */ 244 245 u_int itInName; /* name supplied to kernel in sent msg */ 246 u_int itOutName; /* name in received msg */ 247 u_int itSize; 248 u_int itNumber; 249 u_int itKPD_Number; /* number of Kernel Processed Data entries */ 250 boolean_t itInLine; 251 boolean_t itMigInLine; /* MiG presents data as InLine, although it is sent OOL */ 252 boolean_t itPortType; 253 254 string_t itInNameStr; /* string form of itInName */ 255 string_t itOutNameStr; /* string form of itOutName */ 256 257 boolean_t itStruct; 258 boolean_t itString; 259 boolean_t itVarArray; 260 boolean_t itNoOptArray; 261 boolean_t itNative; /* User specified a native (C) type. */ 262 boolean_t itNativePointer; /* The user will pass a pointer to the */ 263 /* native C type. */ 264 265 struct ipc_type *itElement; /* may be NULL */ 266 267 identifier_t itUserType; 268 identifier_t itServerType; 269 identifier_t itTransType; 270 271 identifier_t itKPDType; /* descriptors for KPD type of arguments */ 272 273 274 identifier_t itInTrans; /* may be NULL */ 275 identifier_t itOutTrans; /* may be NULL */ 276 identifier_t itDestructor; /* may be NULL */ 277 identifier_t itBadValue; /* Excluded value for PointerToIfNot. May 278 be NULL. */ 279 } ipc_type_t; 280 281 #define itNULL ((ipc_type_t *) 0) 282 283 #define itWordAlign (sizeof(void *)) 284 285 extern ipc_type_t *itLookUp(identifier_t name); 286 extern void itInsert(identifier_t name, ipc_type_t *it); 287 extern void itTypeDecl(identifier_t name, ipc_type_t *it); 288 289 extern ipc_type_t *itShortDecl(u_int inname, string_t instr, 290 u_int outname, string_t outstr, 291 u_int dfault); 292 extern ipc_type_t *itPrevDecl(identifier_t name); 293 extern ipc_type_t *itResetType(ipc_type_t *it); 294 extern ipc_type_t *itVarArrayDecl(u_int number, ipc_type_t *it); 295 extern ipc_type_t *itArrayDecl(u_int number, ipc_type_t *it); 296 extern ipc_type_t *itPtrDecl(ipc_type_t *it); 297 extern ipc_type_t *itStructDecl(u_int number, ipc_type_t *it); 298 extern ipc_type_t *itCStringDecl(u_int number, boolean_t varying); 299 extern ipc_type_t *itNativeType(identifier_t CType, boolean_t pointer, 300 identifier_t NotVal); 301 302 extern ipc_type_t *itRetCodeType; 303 extern ipc_type_t *itNdrCodeType; 304 extern ipc_type_t *itDummyType; 305 extern ipc_type_t *itTidType; 306 extern ipc_type_t *itRequestPortType; 307 extern ipc_type_t *itZeroReplyPortType; 308 extern ipc_type_t *itRealReplyPortType; 309 extern ipc_type_t *itWaitTimeType; 310 extern ipc_type_t *itMsgOptionType; 311 extern ipc_type_t *itMakeCountType(void); 312 extern ipc_type_t *itMakeSubCountType(u_int count, boolean_t varying, string_t name); 313 extern ipc_type_t *itMakePolyType(void); 314 extern ipc_type_t *itMakeDeallocType(void); 315 316 extern void init_type(void); 317 318 extern void itCheckReturnType(identifier_t name, ipc_type_t *it); 319 extern void itCheckRequestPortType(identifier_t name, ipc_type_t *it); 320 extern void itCheckReplyPortType(identifier_t name, ipc_type_t *it); 321 extern void itCheckIntType(identifier_t name, ipc_type_t *it); 322 extern void itCheckTokenType(identifier_t name, ipc_type_t *it); 323 324 #include "statement.h" 325 326 #endif /* _TYPE_H */ 327