xref: /onnv-gate/usr/src/uts/common/sys/door_data.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_SYS_DOOR_DATA_H
28*0Sstevel@tonic-gate #define	_SYS_DOOR_DATA_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <sys/types.h>
33*0Sstevel@tonic-gate #include <sys/door.h>
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate #if defined(_KERNEL)
36*0Sstevel@tonic-gate #include <sys/thread.h>
37*0Sstevel@tonic-gate #include <sys/file.h>
38*0Sstevel@tonic-gate #endif
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #ifdef	__cplusplus
41*0Sstevel@tonic-gate extern "C" {
42*0Sstevel@tonic-gate #endif
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate #if defined(_KERNEL)
45*0Sstevel@tonic-gate /* door_return() stack layout */
46*0Sstevel@tonic-gate typedef struct door_layout {
47*0Sstevel@tonic-gate 	caddr_t		dl_descp;	/* start of descriptors (or 0) */
48*0Sstevel@tonic-gate 	caddr_t		dl_datap;	/* start of data (or 0) */
49*0Sstevel@tonic-gate 	caddr_t		dl_infop;	/* start of door_info_t (or 0) */
50*0Sstevel@tonic-gate 	caddr_t		dl_resultsp;	/* start of door_results{32}_t */
51*0Sstevel@tonic-gate 	caddr_t		dl_sp;		/* final stack pointer (non-biased) */
52*0Sstevel@tonic-gate } door_layout_t;
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate /*
55*0Sstevel@tonic-gate  * Per-thread data associated with door invocations.  Each door invocation
56*0Sstevel@tonic-gate  * effects the client structure of one thread and the server structure of
57*0Sstevel@tonic-gate  * another.  This way, the server thread for one door_call() can make door
58*0Sstevel@tonic-gate  * calls of its own without interference.
59*0Sstevel@tonic-gate  */
60*0Sstevel@tonic-gate typedef struct door_client {
61*0Sstevel@tonic-gate 	door_arg_t	d_args;		/* Door arg/results */
62*0Sstevel@tonic-gate 	caddr_t		d_buf;		/* Temp buffer for data transfer */
63*0Sstevel@tonic-gate 	int		d_bufsize;	/* Size of temp buffer */
64*0Sstevel@tonic-gate 	int		d_fpp_size;	/* Number of File ptrs */
65*0Sstevel@tonic-gate 	struct file	**d_fpp;	/* File ptrs  */
66*0Sstevel@tonic-gate 	int		d_error;	/* Error (if any) */
67*0Sstevel@tonic-gate 	kcondvar_t	d_cv;
68*0Sstevel@tonic-gate 	uchar_t		d_hold;		/* Thread needs to stick around */
69*0Sstevel@tonic-gate 	uchar_t		d_upcall;	/* Kernel level upcall */
70*0Sstevel@tonic-gate 	uchar_t		d_noresults;	/* No results allowed */
71*0Sstevel@tonic-gate 	uchar_t		d_overflow;	/* Result overflow occurred */
72*0Sstevel@tonic-gate 	uchar_t		d_kernel;	/* Kernel door server */
73*0Sstevel@tonic-gate } door_client_t;
74*0Sstevel@tonic-gate 
75*0Sstevel@tonic-gate typedef struct door_server {
76*0Sstevel@tonic-gate 	struct _kthread	*d_caller;	/* Door caller */
77*0Sstevel@tonic-gate 	struct _kthread *d_servers;	/* List of door servers */
78*0Sstevel@tonic-gate 	struct door_node *d_active;	/* Active door */
79*0Sstevel@tonic-gate 	struct door_node *d_pool;	/* our server thread pool */
80*0Sstevel@tonic-gate 	door_layout_t	d_layout;
81*0Sstevel@tonic-gate 	caddr_t		d_sp;		/* Saved thread stack base */
82*0Sstevel@tonic-gate 	size_t		d_ssize;	/* Saved thread stack size */
83*0Sstevel@tonic-gate 	kcondvar_t	d_cv;
84*0Sstevel@tonic-gate 	uchar_t		d_hold;		/* Thread needs to stick around */
85*0Sstevel@tonic-gate 	uchar_t		d_invbound;	/* Thread is bound to invalid door */
86*0Sstevel@tonic-gate 	uchar_t		d_layout_done;	/* d_layout has been filled */
87*0Sstevel@tonic-gate } door_server_t;
88*0Sstevel@tonic-gate 
89*0Sstevel@tonic-gate typedef struct door_data {
90*0Sstevel@tonic-gate 	door_client_t d_client;
91*0Sstevel@tonic-gate 	door_server_t d_server;
92*0Sstevel@tonic-gate } door_data_t;
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate #define	DOOR_CLIENT(dp) (&(dp)->d_client)
95*0Sstevel@tonic-gate #define	DOOR_SERVER(dp) (&(dp)->d_server)
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate /*
98*0Sstevel@tonic-gate  * Macros for holding a thread in place.  Takes a door_server_t or
99*0Sstevel@tonic-gate  * door_client_t pointer as an argument.
100*0Sstevel@tonic-gate  */
101*0Sstevel@tonic-gate #define	DOOR_T_HELD(cst)	((cst)->d_hold)
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate #define	DOOR_T_HOLD(cst) \
104*0Sstevel@tonic-gate 	(ASSERT(!DOOR_T_HELD(cst)), ((cst)->d_hold = 1))
105*0Sstevel@tonic-gate #define	DOOR_T_RELEASE(cst) \
106*0Sstevel@tonic-gate 	(ASSERT(DOOR_T_HELD(cst)), ((cst)->d_hold = 0), \
107*0Sstevel@tonic-gate 	    cv_broadcast(&(cst)->d_cv))
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate /*
110*0Sstevel@tonic-gate  * Roundup buffer size when passing/returning data via kernel buffer.
111*0Sstevel@tonic-gate  * This cuts down on the number of overflows that occur on return
112*0Sstevel@tonic-gate  */
113*0Sstevel@tonic-gate #define	DOOR_ROUND	128
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate #endif	/* defined(_KERNEL) */
116*0Sstevel@tonic-gate 
117*0Sstevel@tonic-gate #ifdef	__cplusplus
118*0Sstevel@tonic-gate }
119*0Sstevel@tonic-gate #endif
120*0Sstevel@tonic-gate 
121*0Sstevel@tonic-gate #endif	/* _SYS_DOOR_DATA_H */
122