xref: /titanic_50/usr/src/uts/common/sys/mdesc.h (revision fd845fc0cb4fbc8e85f974e2e4eaacca1cc26e81)
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 2005 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 typedef uint64_t mde_cookie_t;
91 #define	MDE_INVAL_ELEM_COOKIE	((mde_cookie_t)-1)
92 
93 typedef	uint32_t		mde_str_cookie_t;
94 #define	MDE_INVAL_STR_COOKIE	((mde_str_cookie_t)-1)
95 
96 
97 	/* Opaque structure for handling in functions */
98 typedef void * md_t;
99 
100 
101 
102 
103 extern md_t		*md_init(void *);
104 extern md_t		*md_init_intern(uint64_t *, void*(*)(size_t),
105 				void (*)(void*, size_t));
106 
107 extern int		md_fini(md_t *);
108 
109 extern int		md_node_count(md_t *);
110 
111 extern mde_str_cookie_t md_find_name(md_t *, char *namep);
112 
113 extern mde_cookie_t	md_root_node(md_t *);
114 
115 extern int		md_scan_dag(md_t *,
116 				mde_cookie_t,
117 				mde_str_cookie_t,
118 				mde_str_cookie_t,
119 				mde_cookie_t *);
120 
121 extern int		md_get_prop_val(md_t *,
122 				mde_cookie_t,
123 				char *,
124 				uint64_t *);
125 
126 extern int		md_get_prop_str(md_t *,
127 				mde_cookie_t,
128 				char *,
129 				char **);
130 
131 extern int		md_get_prop_data(md_t *,
132 				mde_cookie_t,
133 				char *,
134 				uint8_t **,
135 				int *);
136 
137 
138 
139 #endif	/* } _ASM */
140 
141 
142 
143 /*
144  * ioctl info for mdesc device
145  */
146 
147 #define	MDESCIOC	('m' << 24 | 'd' << 16 | 'd' << 8)
148 
149 #define	MDESCIOCGSZ	(MDESCIOC | 1)   /* Get quote buffer size */
150 #define	MDESCIOCSSZ	(MDESCIOC | 2)   /* Set new quote buffer size */
151 #define	MDESCIOCDISCARD	(MDESCIOC | 3)   /* Discard quotes and reset */
152 
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 #endif	/* _MDESC_H_ */
159