xref: /titanic_53/usr/src/uts/common/sys/mdesc.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_MDESC_H_
28*7c478bd9Sstevel@tonic-gate #define	_MDESC_H_
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate /*
38*7c478bd9Sstevel@tonic-gate  * Each logical domain is detailed via a (Virtual) Machine Description
39*7c478bd9Sstevel@tonic-gate  * available to each guest Operating System courtesy of a
40*7c478bd9Sstevel@tonic-gate  * Hypervisor service.
41*7c478bd9Sstevel@tonic-gate  */
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #ifdef	_ASM
46*7c478bd9Sstevel@tonic-gate #define	U8(_s)	_s
47*7c478bd9Sstevel@tonic-gate #define	U16(_s)	_s
48*7c478bd9Sstevel@tonic-gate #define	U32(_s)	_s
49*7c478bd9Sstevel@tonic-gate #define	U64(_s)	_s
50*7c478bd9Sstevel@tonic-gate #else
51*7c478bd9Sstevel@tonic-gate #define	U8(_s)	((uint8_t)(_s))
52*7c478bd9Sstevel@tonic-gate #define	U16(_s)	((uint16_t)(_s))
53*7c478bd9Sstevel@tonic-gate #define	U32(_s)	((uint32_t)(_s))
54*7c478bd9Sstevel@tonic-gate #define	U64(_s)	((uint64_t)(_s))
55*7c478bd9Sstevel@tonic-gate #endif
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate 	/* the version this library understands */
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate #define	MD_HEADER_VERS_OFF	0x0
64*7c478bd9Sstevel@tonic-gate #define	MD_HEADER_NODE_OFF	0x4
65*7c478bd9Sstevel@tonic-gate #define	MD_HEADER_NAME_OFF	0x8
66*7c478bd9Sstevel@tonic-gate #define	MD_HEADER_DATA_OFF	0xc
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate #define	MD_HEADER_SIZE	0x10
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate #define	MD_TRANSPORT_VERSION	U32(0x10000)
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate #define	MD_ELEMENT_SIZE	0x10
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate #define	MDE_ILLEGAL_IDX		U64(-1)
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate #define	MDET_LIST_END	U8(0x0)
77*7c478bd9Sstevel@tonic-gate #define	MDET_NULL	U8(' ')
78*7c478bd9Sstevel@tonic-gate #define	MDET_NODE	U8('N')
79*7c478bd9Sstevel@tonic-gate #define	MDET_NODE_END	U8('E')
80*7c478bd9Sstevel@tonic-gate #define	MDET_PROP_ARC	U8('a')
81*7c478bd9Sstevel@tonic-gate #define	MDET_PROP_VAL	U8('v')
82*7c478bd9Sstevel@tonic-gate #define	MDET_PROP_STR	U8('s')
83*7c478bd9Sstevel@tonic-gate #define	MDET_PROP_DAT	U8('d')
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate #ifndef _ASM	/* { */
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate typedef uint64_t mde_cookie_t;
89*7c478bd9Sstevel@tonic-gate #define	MDE_INVAL_ELEM_COOKIE	((mde_cookie_t)-1)
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate typedef	uint32_t		mde_str_cookie_t;
92*7c478bd9Sstevel@tonic-gate #define	MDE_INVAL_STR_COOKIE	((mde_str_cookie_t)-1)
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate 	/* Opaque structure for handling in functions */
96*7c478bd9Sstevel@tonic-gate typedef void * md_t;
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate extern md_t		*md_init(void *);
102*7c478bd9Sstevel@tonic-gate extern md_t		*md_init_intern(uint64_t *, void*(*)(size_t),
103*7c478bd9Sstevel@tonic-gate 				void (*)(void*));
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate extern int		md_fini(md_t *);
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate extern int		md_node_count(md_t *);
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate extern mde_str_cookie_t md_find_name(md_t *, char *namep);
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate extern mde_cookie_t	md_root_node(md_t *);
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate extern int		md_scan_dag(md_t *,
114*7c478bd9Sstevel@tonic-gate 				mde_cookie_t,
115*7c478bd9Sstevel@tonic-gate 				mde_str_cookie_t,
116*7c478bd9Sstevel@tonic-gate 				mde_str_cookie_t,
117*7c478bd9Sstevel@tonic-gate 				mde_cookie_t *);
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate extern int		md_get_prop_val(md_t *,
120*7c478bd9Sstevel@tonic-gate 				mde_cookie_t,
121*7c478bd9Sstevel@tonic-gate 				char *,
122*7c478bd9Sstevel@tonic-gate 				uint64_t *);
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate extern int		md_get_prop_str(md_t *,
125*7c478bd9Sstevel@tonic-gate 				mde_cookie_t,
126*7c478bd9Sstevel@tonic-gate 				char *,
127*7c478bd9Sstevel@tonic-gate 				char **);
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate extern int		md_get_prop_data(md_t *,
130*7c478bd9Sstevel@tonic-gate 				mde_cookie_t,
131*7c478bd9Sstevel@tonic-gate 				char *,
132*7c478bd9Sstevel@tonic-gate 				uint8_t **,
133*7c478bd9Sstevel@tonic-gate 				int *);
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate #endif	/* } _ASM */
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate /*
142*7c478bd9Sstevel@tonic-gate  * ioctl info for mdesc device
143*7c478bd9Sstevel@tonic-gate  */
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate #define	MDESCIOC	('m' << 24 | 'd' << 16 | 'd' << 8)
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate #define	MDESCIOCGSZ	(MDESCIOC | 1)   /* Get quote buffer size */
148*7c478bd9Sstevel@tonic-gate #define	MDESCIOCSSZ	(MDESCIOC | 2)   /* Set new quote buffer size */
149*7c478bd9Sstevel@tonic-gate #define	MDESCIOCDISCARD	(MDESCIOC | 3)   /* Discard quotes and reset */
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate 
152*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
153*7c478bd9Sstevel@tonic-gate }
154*7c478bd9Sstevel@tonic-gate #endif
155*7c478bd9Sstevel@tonic-gate 
156*7c478bd9Sstevel@tonic-gate #endif	/* _MDESC_H_ */
157