xref: /titanic_52/usr/src/uts/common/sys/mdesc.h (revision b6c3f7863936abeae522e48a13887dddeb691a45)
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 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_MDESC_H_
28 #define	_MDESC_H_
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 
39 /*
40  * Each logical domain is detailed via a (Virtual) Machine Description
41  * available to each guest Operating System courtesy of a
42  * Hypervisor service.
43  */
44 
45 
46 
47 #ifdef	_ASM
48 #define	U8(_s)	_s
49 #define	U16(_s)	_s
50 #define	U32(_s)	_s
51 #define	U64(_s)	_s
52 #else
53 #define	U8(_s)	((uint8_t)(_s))
54 #define	U16(_s)	((uint16_t)(_s))
55 #define	U32(_s)	((uint32_t)(_s))
56 #define	U64(_s)	((uint64_t)(_s))
57 #endif
58 
59 
60 
61 
62 
63 	/* the version this library understands */
64 
65 #define	MD_HEADER_VERS_OFF	0x0
66 #define	MD_HEADER_NODE_OFF	0x4
67 #define	MD_HEADER_NAME_OFF	0x8
68 #define	MD_HEADER_DATA_OFF	0xc
69 
70 #define	MD_HEADER_SIZE	0x10
71 
72 #define	MD_TRANSPORT_VERSION	U32(0x10000)
73 
74 #define	MD_ELEMENT_SIZE	0x10
75 
76 #define	MDE_ILLEGAL_IDX		U64(-1)
77 
78 #define	MDET_LIST_END	U8(0x0)
79 #define	MDET_NULL	U8(' ')
80 #define	MDET_NODE	U8('N')
81 #define	MDET_NODE_END	U8('E')
82 #define	MDET_PROP_ARC	U8('a')
83 #define	MDET_PROP_VAL	U8('v')
84 #define	MDET_PROP_STR	U8('s')
85 #define	MDET_PROP_DAT	U8('d')
86 
87 
88 #ifndef _ASM	/* { */
89 
90 /*
91  * Opaque handles for use in external interfaces
92  */
93 
94 typedef void			*md_t;
95 
96 typedef uint64_t		mde_cookie_t;
97 #define	MDE_INVAL_ELEM_COOKIE	((mde_cookie_t)-1)
98 
99 typedef	uint32_t		mde_str_cookie_t;
100 #define	MDE_INVAL_STR_COOKIE	((mde_str_cookie_t)-1)
101 
102 typedef uint64_t		md_diff_cookie_t;
103 #define	MD_INVAL_DIFF_COOKIE	((md_diff_cookie_t)-1)
104 
105 #define	MDESC_INVAL_GEN		(0)
106 
107 /*
108  * External structure for MD diff interface
109  */
110 typedef struct {
111 	uint8_t		type;		/* property type */
112 	char		*namep;		/* property name */
113 } md_prop_match_t;
114 
115 
116 /*
117  * External Interface
118  */
119 
120 extern md_t		*md_init_intern(uint64_t *,
121 				void *(*allocp)(size_t),
122 				void (*freep)(void *, size_t));
123 
124 extern int		md_fini(md_t *);
125 
126 extern int		md_node_count(md_t *);
127 
128 extern mde_str_cookie_t md_find_name(md_t *, char *namep);
129 
130 extern mde_cookie_t	md_root_node(md_t *);
131 
132 extern uint64_t		md_get_gen(md_t *);
133 
134 extern size_t		md_get_bin_size(md_t *);
135 
136 extern int		md_scan_dag(md_t *,
137 				mde_cookie_t,
138 				mde_str_cookie_t,
139 				mde_str_cookie_t,
140 				mde_cookie_t *);
141 
142 extern int		md_get_prop_val(md_t *,
143 				mde_cookie_t,
144 				char *,
145 				uint64_t *);
146 
147 extern int		md_get_prop_str(md_t *,
148 				mde_cookie_t,
149 				char *,
150 				char **);
151 
152 extern int		md_get_prop_data(md_t *,
153 				mde_cookie_t,
154 				char *,
155 				uint8_t **,
156 				int *);
157 
158 extern md_diff_cookie_t	md_diff_init(md_t *,
159 				mde_cookie_t,
160 				md_t *,
161 				mde_cookie_t,
162 				char *,
163 				md_prop_match_t *);
164 
165 extern int		md_diff_added(md_diff_cookie_t,
166 				mde_cookie_t **);
167 
168 extern int		md_diff_removed(md_diff_cookie_t,
169 				mde_cookie_t **);
170 
171 extern int		md_diff_matched(md_diff_cookie_t,
172 				mde_cookie_t **,
173 				mde_cookie_t **);
174 
175 extern int		md_diff_fini(md_diff_cookie_t);
176 
177 
178 #endif	/* } _ASM */
179 
180 
181 
182 /*
183  * ioctl info for mdesc device
184  */
185 
186 #define	MDESCIOC	('m' << 24 | 'd' << 16 | 'd' << 8)
187 
188 #define	MDESCIOCGSZ	(MDESCIOC | 1)   /* Get quote buffer size */
189 #define	MDESCIOCSSZ	(MDESCIOC | 2)   /* Set new quote buffer size */
190 #define	MDESCIOCDISCARD	(MDESCIOC | 3)   /* Discard quotes and reset */
191 
192 #ifdef __cplusplus
193 }
194 #endif
195 
196 #endif	/* _MDESC_H_ */
197