xref: /illumos-gate/usr/src/uts/common/sys/contract.h (revision fafb665d337b69015870e0bcdb516fd2f869693f)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_CONTRACT_H
27 #define	_SYS_CONTRACT_H
28 
29 #include <sys/types.h>
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 typedef uint64_t	ctevid_t;
36 
37 /*
38  * Contract parameter maximum size, in bytes
39  */
40 #define	CT_PARAM_MAX_SIZE	8192
41 
42 /*
43  * Common event types
44  */
45 #define	CT_EV_NEGEND	0
46 
47 /*
48  * Level of status detail requested
49  */
50 #define	CTD_COMMON	0	/* No additional detail */
51 #define	CTD_FIXED	1	/* O(1) info */
52 #define	CTD_ALL		2	/* O(n) info */
53 
54 /*
55  * Values for ctev_flags.
56  */
57 #define	CTE_ACK		0x1
58 #define	CTE_INFO	0x2
59 #define	CTE_NEG		0x4
60 
61 #define	CTP_EV_CRITICAL	100
62 #define	CTP_EV_INFO	101
63 #define	CTP_COOKIE	102
64 
65 #define	CTS_NEWCT	"cts_newct"
66 #define	CTS_NEVID	"cts_nevid"
67 
68 typedef enum ctstate {
69 	CTS_OWNED,	/* contract is owned by a process */
70 	CTS_INHERITED,	/* contract has been inherited by its parent */
71 	CTS_ORPHAN,	/* contract has no parent */
72 	CTS_DEAD	/* contract has been destroyed */
73 } ctstate_t;
74 
75 typedef enum ct_typeid {
76 	CTT_PROCESS,	/* process contract */
77 	CTT_DEVICE,	/* device contract */
78 	CTT_MAXTYPE
79 } ct_typeid_t;
80 
81 typedef struct ct_event {
82 	ctid_t	ctev_id;
83 	uint32_t ctev_pad1;
84 	ctevid_t ctev_evid;
85 	ct_typeid_t ctev_cttype;
86 	uint32_t ctev_flags;
87 	uint32_t ctev_type;
88 	uint32_t ctev_nbytes;
89 	uint32_t ctev_goffset;
90 	uint32_t ctev_pad2;
91 	char	*ctev_buffer;
92 } ct_event_t;
93 
94 typedef struct ct_status {
95 	ctid_t	ctst_id;
96 	zoneid_t ctst_zoneid;
97 	ct_typeid_t ctst_type;
98 	pid_t	ctst_holder;
99 	ctstate_t ctst_state;
100 	int	ctst_nevents;
101 	int	ctst_ntime;
102 	int	ctst_qtime;
103 	uint64_t ctst_nevid;
104 	uint_t	ctst_detail;
105 	size_t	ctst_nbytes;
106 	uint_t	ctst_critical;
107 	uint_t	ctst_informative;
108 	uint64_t ctst_cookie;
109 	char	*ctst_buffer;
110 } ct_status_t;
111 
112 typedef struct ct_param {
113 	uint32_t ctpm_id;
114 	uint32_t ctpm_size;
115 	void	 *ctpm_value;
116 } ct_param_t;
117 
118 #ifdef	__cplusplus
119 }
120 #endif
121 
122 #endif	/* _SYS_CONTRACT_H */
123