xref: /titanic_41/usr/src/uts/common/sys/mdesc.h (revision 0681aacec3916ea37917fe3aadb92f03d7b8ea85)
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 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 
37 /*
38  * Each logical domain is detailed via a (Virtual) Machine Description
39  * available to each guest Operating System courtesy of a
40  * Hypervisor service.
41  */
42 
43 
44 
45 #ifdef	_ASM
46 #define	U8(_s)	_s
47 #define	U16(_s)	_s
48 #define	U32(_s)	_s
49 #define	U64(_s)	_s
50 #else
51 #define	U8(_s)	((uint8_t)(_s))
52 #define	U16(_s)	((uint16_t)(_s))
53 #define	U32(_s)	((uint32_t)(_s))
54 #define	U64(_s)	((uint64_t)(_s))
55 #endif
56 
57 
58 
59 
60 
61 	/* the version this library understands */
62 
63 #define	MD_HEADER_VERS_OFF	0x0
64 #define	MD_HEADER_NODE_OFF	0x4
65 #define	MD_HEADER_NAME_OFF	0x8
66 #define	MD_HEADER_DATA_OFF	0xc
67 
68 #define	MD_HEADER_SIZE	0x10
69 
70 #define	MD_TRANSPORT_VERSION	U32(0x10000)
71 
72 #define	MD_ELEMENT_SIZE	0x10
73 
74 #define	MDE_ILLEGAL_IDX		U64(-1)
75 
76 #define	MDET_LIST_END	U8(0x0)
77 #define	MDET_NULL	U8(' ')
78 #define	MDET_NODE	U8('N')
79 #define	MDET_NODE_END	U8('E')
80 #define	MDET_PROP_ARC	U8('a')
81 #define	MDET_PROP_VAL	U8('v')
82 #define	MDET_PROP_STR	U8('s')
83 #define	MDET_PROP_DAT	U8('d')
84 
85 
86 #ifndef _ASM	/* { */
87 
88 typedef uint64_t mde_cookie_t;
89 #define	MDE_INVAL_ELEM_COOKIE	((mde_cookie_t)-1)
90 
91 typedef	uint32_t		mde_str_cookie_t;
92 #define	MDE_INVAL_STR_COOKIE	((mde_str_cookie_t)-1)
93 
94 
95 	/* Opaque structure for handling in functions */
96 typedef void * md_t;
97 
98 
99 
100 
101 extern md_t		*md_init(void *);
102 extern md_t		*md_init_intern(uint64_t *, void*(*)(size_t),
103 				void (*)(void*, size_t));
104 
105 extern int		md_fini(md_t *);
106 
107 extern int		md_node_count(md_t *);
108 
109 extern mde_str_cookie_t md_find_name(md_t *, char *namep);
110 
111 extern mde_cookie_t	md_root_node(md_t *);
112 
113 extern int		md_scan_dag(md_t *,
114 				mde_cookie_t,
115 				mde_str_cookie_t,
116 				mde_str_cookie_t,
117 				mde_cookie_t *);
118 
119 extern int		md_get_prop_val(md_t *,
120 				mde_cookie_t,
121 				char *,
122 				uint64_t *);
123 
124 extern int		md_get_prop_str(md_t *,
125 				mde_cookie_t,
126 				char *,
127 				char **);
128 
129 extern int		md_get_prop_data(md_t *,
130 				mde_cookie_t,
131 				char *,
132 				uint8_t **,
133 				int *);
134 
135 
136 
137 #endif	/* } _ASM */
138 
139 
140 
141 /*
142  * ioctl info for mdesc device
143  */
144 
145 #define	MDESCIOC	('m' << 24 | 'd' << 16 | 'd' << 8)
146 
147 #define	MDESCIOCGSZ	(MDESCIOC | 1)   /* Get quote buffer size */
148 #define	MDESCIOCSSZ	(MDESCIOC | 2)   /* Set new quote buffer size */
149 #define	MDESCIOCDISCARD	(MDESCIOC | 3)   /* Discard quotes and reset */
150 
151 
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif	/* _MDESC_H_ */
157