xref: /onnv-gate/usr/src/uts/common/sys/door_data.h (revision 6997:056043f166c6)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
56263Sseb  * Common Development and Distribution License (the "License").
66263Sseb  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
226263Sseb  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_DOOR_DATA_H
270Sstevel@tonic-gate #define	_SYS_DOOR_DATA_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/types.h>
320Sstevel@tonic-gate #include <sys/door.h>
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #if defined(_KERNEL)
350Sstevel@tonic-gate #include <sys/thread.h>
360Sstevel@tonic-gate #include <sys/file.h>
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifdef	__cplusplus
400Sstevel@tonic-gate extern "C" {
410Sstevel@tonic-gate #endif
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #if defined(_KERNEL)
440Sstevel@tonic-gate /* door_return() stack layout */
450Sstevel@tonic-gate typedef struct door_layout {
460Sstevel@tonic-gate 	caddr_t		dl_descp;	/* start of descriptors (or 0) */
470Sstevel@tonic-gate 	caddr_t		dl_datap;	/* start of data (or 0) */
480Sstevel@tonic-gate 	caddr_t		dl_infop;	/* start of door_info_t (or 0) */
490Sstevel@tonic-gate 	caddr_t		dl_resultsp;	/* start of door_results{32}_t */
500Sstevel@tonic-gate 	caddr_t		dl_sp;		/* final stack pointer (non-biased) */
510Sstevel@tonic-gate } door_layout_t;
520Sstevel@tonic-gate 
53*6997Sjwadams /* upcall invocation information */
54*6997Sjwadams typedef struct door_upcall_data {
55*6997Sjwadams 	cred_t		*du_cred;	/* Credential associated w/ upcall */
56*6997Sjwadams 	size_t		du_max_data;	/* Maximum amount of reply data */
57*6997Sjwadams 	uint_t		du_max_descs;	/* Maximum number of reply descs */
58*6997Sjwadams } door_upcall_t;
59*6997Sjwadams 
600Sstevel@tonic-gate /*
610Sstevel@tonic-gate  * Per-thread data associated with door invocations.  Each door invocation
620Sstevel@tonic-gate  * effects the client structure of one thread and the server structure of
630Sstevel@tonic-gate  * another.  This way, the server thread for one door_call() can make door
640Sstevel@tonic-gate  * calls of its own without interference.
650Sstevel@tonic-gate  */
660Sstevel@tonic-gate typedef struct door_client {
670Sstevel@tonic-gate 	door_arg_t	d_args;		/* Door arg/results */
68*6997Sjwadams 	door_upcall_t	*d_upcall;	/* upcall information */
690Sstevel@tonic-gate 	caddr_t		d_buf;		/* Temp buffer for data transfer */
700Sstevel@tonic-gate 	int		d_bufsize;	/* Size of temp buffer */
710Sstevel@tonic-gate 	int		d_fpp_size;	/* Number of File ptrs */
720Sstevel@tonic-gate 	struct file	**d_fpp;	/* File ptrs  */
730Sstevel@tonic-gate 	int		d_error;	/* Error (if any) */
740Sstevel@tonic-gate 	kcondvar_t	d_cv;
756655Sjwadams 	uchar_t		d_args_done;	/* server has processed client's args */
760Sstevel@tonic-gate 	uchar_t		d_hold;		/* Thread needs to stick around */
770Sstevel@tonic-gate 	uchar_t		d_noresults;	/* No results allowed */
780Sstevel@tonic-gate 	uchar_t		d_overflow;	/* Result overflow occurred */
790Sstevel@tonic-gate 	uchar_t		d_kernel;	/* Kernel door server */
800Sstevel@tonic-gate } door_client_t;
810Sstevel@tonic-gate 
820Sstevel@tonic-gate typedef struct door_server {
830Sstevel@tonic-gate 	struct _kthread	*d_caller;	/* Door caller */
840Sstevel@tonic-gate 	struct _kthread *d_servers;	/* List of door servers */
850Sstevel@tonic-gate 	struct door_node *d_active;	/* Active door */
860Sstevel@tonic-gate 	struct door_node *d_pool;	/* our server thread pool */
870Sstevel@tonic-gate 	door_layout_t	d_layout;
880Sstevel@tonic-gate 	caddr_t		d_sp;		/* Saved thread stack base */
890Sstevel@tonic-gate 	size_t		d_ssize;	/* Saved thread stack size */
900Sstevel@tonic-gate 	kcondvar_t	d_cv;
910Sstevel@tonic-gate 	uchar_t		d_hold;		/* Thread needs to stick around */
920Sstevel@tonic-gate 	uchar_t		d_invbound;	/* Thread is bound to invalid door */
930Sstevel@tonic-gate 	uchar_t		d_layout_done;	/* d_layout has been filled */
940Sstevel@tonic-gate } door_server_t;
950Sstevel@tonic-gate 
960Sstevel@tonic-gate typedef struct door_data {
970Sstevel@tonic-gate 	door_client_t d_client;
980Sstevel@tonic-gate 	door_server_t d_server;
990Sstevel@tonic-gate } door_data_t;
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate #define	DOOR_CLIENT(dp) (&(dp)->d_client)
1020Sstevel@tonic-gate #define	DOOR_SERVER(dp) (&(dp)->d_server)
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate /*
1050Sstevel@tonic-gate  * Macros for holding a thread in place.  Takes a door_server_t or
1060Sstevel@tonic-gate  * door_client_t pointer as an argument.
1070Sstevel@tonic-gate  */
1080Sstevel@tonic-gate #define	DOOR_T_HELD(cst)	((cst)->d_hold)
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate #define	DOOR_T_HOLD(cst) \
1110Sstevel@tonic-gate 	(ASSERT(!DOOR_T_HELD(cst)), ((cst)->d_hold = 1))
1120Sstevel@tonic-gate #define	DOOR_T_RELEASE(cst) \
1130Sstevel@tonic-gate 	(ASSERT(DOOR_T_HELD(cst)), ((cst)->d_hold = 0), \
1140Sstevel@tonic-gate 	    cv_broadcast(&(cst)->d_cv))
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate /*
1170Sstevel@tonic-gate  * Roundup buffer size when passing/returning data via kernel buffer.
1180Sstevel@tonic-gate  * This cuts down on the number of overflows that occur on return
1190Sstevel@tonic-gate  */
1200Sstevel@tonic-gate #define	DOOR_ROUND	128
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate #endif	/* defined(_KERNEL) */
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate #ifdef	__cplusplus
1250Sstevel@tonic-gate }
1260Sstevel@tonic-gate #endif
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate #endif	/* _SYS_DOOR_DATA_H */
129