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