17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5024b0a25Sseb * Common Development and Distribution License (the "License"). 6024b0a25Sseb * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22024b0a25Sseb * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_DOOR_DATA_H 277c478bd9Sstevel@tonic-gate #define _SYS_DOOR_DATA_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/types.h> 327c478bd9Sstevel@tonic-gate #include <sys/door.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 357c478bd9Sstevel@tonic-gate #include <sys/thread.h> 367c478bd9Sstevel@tonic-gate #include <sys/file.h> 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef __cplusplus 407c478bd9Sstevel@tonic-gate extern "C" { 417c478bd9Sstevel@tonic-gate #endif 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 447c478bd9Sstevel@tonic-gate /* door_return() stack layout */ 457c478bd9Sstevel@tonic-gate typedef struct door_layout { 467c478bd9Sstevel@tonic-gate caddr_t dl_descp; /* start of descriptors (or 0) */ 477c478bd9Sstevel@tonic-gate caddr_t dl_datap; /* start of data (or 0) */ 487c478bd9Sstevel@tonic-gate caddr_t dl_infop; /* start of door_info_t (or 0) */ 497c478bd9Sstevel@tonic-gate caddr_t dl_resultsp; /* start of door_results{32}_t */ 507c478bd9Sstevel@tonic-gate caddr_t dl_sp; /* final stack pointer (non-biased) */ 517c478bd9Sstevel@tonic-gate } door_layout_t; 527c478bd9Sstevel@tonic-gate 53*323a81d9Sjwadams /* upcall invocation information */ 54*323a81d9Sjwadams typedef struct door_upcall_data { 55*323a81d9Sjwadams cred_t *du_cred; /* Credential associated w/ upcall */ 56*323a81d9Sjwadams size_t du_max_data; /* Maximum amount of reply data */ 57*323a81d9Sjwadams uint_t du_max_descs; /* Maximum number of reply descs */ 58*323a81d9Sjwadams } door_upcall_t; 59*323a81d9Sjwadams 607c478bd9Sstevel@tonic-gate /* 617c478bd9Sstevel@tonic-gate * Per-thread data associated with door invocations. Each door invocation 627c478bd9Sstevel@tonic-gate * effects the client structure of one thread and the server structure of 637c478bd9Sstevel@tonic-gate * another. This way, the server thread for one door_call() can make door 647c478bd9Sstevel@tonic-gate * calls of its own without interference. 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate typedef struct door_client { 677c478bd9Sstevel@tonic-gate door_arg_t d_args; /* Door arg/results */ 68*323a81d9Sjwadams door_upcall_t *d_upcall; /* upcall information */ 697c478bd9Sstevel@tonic-gate caddr_t d_buf; /* Temp buffer for data transfer */ 707c478bd9Sstevel@tonic-gate int d_bufsize; /* Size of temp buffer */ 717c478bd9Sstevel@tonic-gate int d_fpp_size; /* Number of File ptrs */ 727c478bd9Sstevel@tonic-gate struct file **d_fpp; /* File ptrs */ 737c478bd9Sstevel@tonic-gate int d_error; /* Error (if any) */ 747c478bd9Sstevel@tonic-gate kcondvar_t d_cv; 75289175a0Sjwadams uchar_t d_args_done; /* server has processed client's args */ 767c478bd9Sstevel@tonic-gate uchar_t d_hold; /* Thread needs to stick around */ 777c478bd9Sstevel@tonic-gate uchar_t d_noresults; /* No results allowed */ 787c478bd9Sstevel@tonic-gate uchar_t d_overflow; /* Result overflow occurred */ 797c478bd9Sstevel@tonic-gate uchar_t d_kernel; /* Kernel door server */ 807c478bd9Sstevel@tonic-gate } door_client_t; 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate typedef struct door_server { 837c478bd9Sstevel@tonic-gate struct _kthread *d_caller; /* Door caller */ 847c478bd9Sstevel@tonic-gate struct _kthread *d_servers; /* List of door servers */ 857c478bd9Sstevel@tonic-gate struct door_node *d_active; /* Active door */ 867c478bd9Sstevel@tonic-gate struct door_node *d_pool; /* our server thread pool */ 877c478bd9Sstevel@tonic-gate door_layout_t d_layout; 887c478bd9Sstevel@tonic-gate caddr_t d_sp; /* Saved thread stack base */ 897c478bd9Sstevel@tonic-gate size_t d_ssize; /* Saved thread stack size */ 907c478bd9Sstevel@tonic-gate kcondvar_t d_cv; 917c478bd9Sstevel@tonic-gate uchar_t d_hold; /* Thread needs to stick around */ 927c478bd9Sstevel@tonic-gate uchar_t d_invbound; /* Thread is bound to invalid door */ 937c478bd9Sstevel@tonic-gate uchar_t d_layout_done; /* d_layout has been filled */ 947c478bd9Sstevel@tonic-gate } door_server_t; 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate typedef struct door_data { 977c478bd9Sstevel@tonic-gate door_client_t d_client; 987c478bd9Sstevel@tonic-gate door_server_t d_server; 997c478bd9Sstevel@tonic-gate } door_data_t; 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate #define DOOR_CLIENT(dp) (&(dp)->d_client) 1027c478bd9Sstevel@tonic-gate #define DOOR_SERVER(dp) (&(dp)->d_server) 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate /* 1057c478bd9Sstevel@tonic-gate * Macros for holding a thread in place. Takes a door_server_t or 1067c478bd9Sstevel@tonic-gate * door_client_t pointer as an argument. 1077c478bd9Sstevel@tonic-gate */ 1087c478bd9Sstevel@tonic-gate #define DOOR_T_HELD(cst) ((cst)->d_hold) 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate #define DOOR_T_HOLD(cst) \ 1117c478bd9Sstevel@tonic-gate (ASSERT(!DOOR_T_HELD(cst)), ((cst)->d_hold = 1)) 1127c478bd9Sstevel@tonic-gate #define DOOR_T_RELEASE(cst) \ 1137c478bd9Sstevel@tonic-gate (ASSERT(DOOR_T_HELD(cst)), ((cst)->d_hold = 0), \ 1147c478bd9Sstevel@tonic-gate cv_broadcast(&(cst)->d_cv)) 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* 1177c478bd9Sstevel@tonic-gate * Roundup buffer size when passing/returning data via kernel buffer. 1187c478bd9Sstevel@tonic-gate * This cuts down on the number of overflows that occur on return 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate #define DOOR_ROUND 128 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate #endif /* defined(_KERNEL) */ 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1257c478bd9Sstevel@tonic-gate } 1267c478bd9Sstevel@tonic-gate #endif 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate #endif /* _SYS_DOOR_DATA_H */ 129