-/*
- * New RPC declarations
- *
- * First pass at definitions and types for the new rpc service.
- * This is subject to revision.
- */
-
-/*
- * RPC macros
- */
-
-#define RPC_MASK(shift,last) \
- ( ((1 << ((last)-(shift)))-1) << (shift) )
-
-#define RPC_FIELD(field,shift,last) \
- ( (field) & (((1 << ((last)-(shift)))-1) << (shift)) )
-
-#define RPC_BOUND(dsc) \
- (((RPC_FIELD((dsc).type,TYPE_SHIFT+1,TYPE_SHIFT+3) == \
- MACH_RPC_ARRAY_VARIABLE) && (dsc).count != 0) ? MACH_RPC_BOUND : 0)
-
-#define ROUNDUP2(x,n) ((((unsigned)(x)) + (n) - 1) & ~((n)-1))
-#define ROUNDWORD(x) ROUNDUP2(x,sizeof(int))
-
-/*
- * RPC errors
- *
- * Display and process errors of different severity, from just for
- * information only to fatal (panic). Error code colors indicate how
- * difficult it is for the subsystem to handle the error correctly.
- * The implication is that, for example, early versions of the code may
- * not be handling code red errors properly. The code should use this
- * facility instead of regular printf's.
- */
-
-#define MACH_RPC_DEBUG 1
-
-#define ERR_INFO 1 /* purely informational */
-#define ERR_GREEN 2 /* easily handled error */
-#define ERR_YELLOW 3 /* medium difficult error */
-#define ERR_RED 4 /* difficult to handle error */
-#define ERR_FATAL 5 /* unrecoverable error, panic */
-
-#if MACH_RPC_DEBUG > 1
-#define rpc_error(E,S) \
- printf("RPC error "); \
- rpc_error_show_severity(S); \
- printf("in file \"%s\", line %d: ", __FILE__, __LINE__); \
- printf E ; \
- printf("\n"); \
- rpc_error_severity(S)
-#else
-#define rpc_error(E,S) \
- if ((S) == ERR_FATAL || (S) == ERR_RED) { \
- printf("RPC error "); \
- rpc_error_show_severity(S); \
- printf("in file \"%s\", line %d: ", __FILE__, __LINE__); \
- printf E ; \
- printf("\n"); \
- rpc_error_severity(S); \
- }
-#endif /* MACH_RPC_DEBUG */
-
-/*
- * RPC buffer size and break points
- *
- * These values define the rpc buffer size on the kernel stack,
- * and break point values for switching to virtual copy (cow).
- * This should be in a machine dependent include file. All sizes
- * are in word (sizeof(int)) units.
- */
-
-#define RPC_KBUF_SIZE 16 /* kernel stack buffer size (ints) */
-#define RPC_COW_SIZE 1024 /* size where COW is a win (ints) */
-#define RPC_DESC_COUNT 4 /* default descriptor count */
-
-
-/*
- * RPC copy state
- *
- * Record the rpc copy state for arrays, so we can unwind our state
- * during error processing. There is one entry per complex (signatured)
- * argument. The first entry is marked COPY_TYPE_ALLOC_KRN if this record
- * itself was kalloc'd because the number of complex arg descriptors
- * exceeded the default value (RPC_DESC_COUNT). This is not a conflict
- * since the first argument is always the destination port, never an array.
- */
-
-#define COPY_TYPE_NO_COPY 0 /* nothing special */
-#define COPY_TYPE_ON_KSTACK 1 /* array is on kernel stack */
-#define COPY_TYPE_ON_SSTACK 2 /* array is on server stack */
-#define COPY_TYPE_VIRTUAL_IN 3 /* vm_map_copyin part of cow */
-#define COPY_TYPE_VIRTUAL_OUT_SVR 4 /* map cpyout svr part of cow */
-#define COPY_TYPE_VIRTUAL_OUT_CLN 5 /* map cpyout cln part of cow */
-#define COPY_TYPE_ALLOC_KRN 6 /* kernel kalloc'd for array */
-#define COPY_TYPE_ALLOC_SVR 7 /* vm_alloc'd in server space */
-#define COPY_TYPE_ALLOC_CLN 8 /* vm_alloc'd in client space */
-#define COPY_TYPE_PORT 9 /* plain port translated */
-#define COPY_TYPE_PORT_ARRAY 10 /* port array translated */
-
-
-/*
- * RPC types
- */
-typedef int rpc_id_t;
-typedef int rpc_return_t;
-typedef unsigned int rpc_size_t;
-typedef unsigned int rpc_offset_t;
-
-struct rpc_copy_state {
- unsigned copy_type; /* what kind of copy */
- vm_offset_t alloc_addr; /* address to free */
-};
-typedef struct rpc_copy_state *rpc_copy_state_t;
-typedef struct rpc_copy_state rpc_copy_state_data_t;
-
-typedef boolean_t (*copyfunc_t)(const char *, char *, vm_size_t);
-
-
-/*
- * RPC function declarations
- */
-
-#ifdef CALLOUT_RPC_MODEL
-
-extern
-void rpc_bootstrap( void );
-
-extern
-void rpc_remote_bootstrap( void );
-
-extern
-rpc_return_t mach_rpc_trap(
- mach_port_name_t dest_port,
- rpc_id_t routine_num,
- rpc_signature_t signature_ptr,
- rpc_size_t signature_size );
-
-extern
-rpc_return_t mach_rpc_return_trap( void );
-
-extern
-rpc_return_t mach_rpc_return_error( void );
-
-void mach_rpc_return_wrapper( void );
-
-void rpc_upcall(
- vm_offset_t stack,
- vm_offset_t new_stack,
- vm_offset_t server_func,
- int return_code );
-
-void rpc_error_severity( int severity );
-void rpc_error_show_severity( int severity );
-unsigned int name_rpc_to_ipc( unsigned int action );
-
-void clean_port_array(
- ipc_object_t * array,
- unsigned count,
- unsigned cooked,
- unsigned direct );
-
-void unwind_rpc_state(
- routine_descriptor_t routine,
- rpc_copy_state_t state,
- int * arg_buf );
-
-kern_return_t unwind_invoke_state(
- thread_act_t thr_act );
-
-kern_return_t rpc_invke_args_in(
- routine_descriptor_t routine,
- rpc_copy_state_t state,
- int * arg_buf,
- copyfunc_t infunc );
-
-kern_return_t rpc_invke_args_out(
- routine_descriptor_t routine,
- rpc_copy_state_t state,
- int * arg_buf,
- int ** new_sp,
- copyfunc_t outfunc );
-
-kern_return_t rpc_reply_args_in(
- routine_descriptor_t routine,
- rpc_copy_state_t state,
- int * svr_buf,
- copyfunc_t infunc );
-
-kern_return_t rpc_reply_args_out(
- routine_descriptor_t routine,
- rpc_copy_state_t state,
- int * svr_buf,
- int * cln_buf,
- copyfunc_t outfunc );
-
-#endif /* CALLOUT_RPC_MODEL */
-
-/*
- * libmach helper functions:
- */
-extern rpc_subsystem_t mach_subsystem_join(
- rpc_subsystem_t,
- rpc_subsystem_t,
- unsigned int *,
- void *(* )(int));