xref: /titanic_41/usr/src/uts/common/sys/project.h (revision fd9cb95cbb2f626355a60efb9d02c5f0a33c10e6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_PROJECT_H
28 #define	_SYS_PROJECT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/types.h>
37 #include <sys/mutex.h>
38 #include <sys/rctl.h>
39 
40 typedef struct kproject_data {		/* Datum protected by: */
41 	rctl_qty_t	kpd_shmmax;	/* shm's ipcs_lock */
42 	rctl_qty_t	kpd_shmmni;	/* shm's ipcs_lock */
43 	rctl_qty_t	kpd_semmni;	/* sem's ipcs_lock */
44 	rctl_qty_t	kpd_msgmni;	/* msg's ipcs_lock */
45 	rctl_qty_t	kpd_devlockmem;	/* umem_devlockmem_rctl_lock */
46 	rctl_qty_t	kpd_contract;	/* contract_lock */
47 	rctl_qty_t	kpd_crypto_mem;	/* crypto_rctl_lock */
48 } kproject_data_t;
49 
50 /*
51  * The first two fields of this structure must not be reordered.
52  */
53 typedef struct kproject {
54 	projid_t 	kpj_id;		/* project ID		*/
55 	zoneid_t	kpj_zoneid;	/* zone ID		*/
56 	uint_t		kpj_count;	/* reference counter	*/
57 	uint32_t	kpj_shares;	/* number of shares	*/
58 	rctl_set_t	*kpj_rctls;	/* resource control set */
59 	struct kproject	*kpj_prev;	/* previous project	*/
60 	struct kproject	*kpj_next;	/* next project		*/
61 	kproject_data_t	kpj_data;	/* subsystem-specfic data */
62 	kmutex_t	kpj_poolbind;	/* synch. with pools	*/
63 	rctl_qty_t	kpj_nlwps;	/* protected by project's zone's */
64 					/* zone_nlwps_lock */
65 	rctl_qty_t	kpj_nlwps_ctl;	/* protected by kpj_rctls->rcs_lock */
66 	rctl_qty_t	kpj_ntasks;	/* protected by project's zone's */
67 					/* zone_nlwps_lock */
68 	rctl_qty_t	kpj_ntasks_ctl;	/* protected by kpj_rctls->rcs_lock */
69 } kproject_t;
70 
71 #ifdef _KERNEL
72 
73 /*
74  * Flags for project_hold_by_id()
75  */
76 #define	PROJECT_HOLD_FIND	1
77 #define	PROJECT_HOLD_INSERT	2
78 
79 void project_init(void);
80 kproject_t *project_hold(kproject_t *);
81 kproject_t *project_hold_by_id(projid_t, zoneid_t, int);
82 void project_rele(kproject_t *);
83 int project_walk_all(zoneid_t, int (*)(kproject_t *, void *), void *);
84 projid_t curprojid(void);
85 
86 extern kproject_t *proj0p;
87 extern rctl_hndl_t rc_project_nlwps;
88 extern rctl_hndl_t rc_project_ntasks;
89 
90 #endif /* _KERNEL */
91 
92 #ifdef	__cplusplus
93 }
94 #endif
95 
96 #endif	/* _SYS_PROJECT_H */
97