xref: /onnv-gate/usr/src/uts/common/sys/mdesc.h (revision 1991)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1991Sheppo  * Common Development and Distribution License (the "License").
6*1991Sheppo  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*1991Sheppo 
220Sstevel@tonic-gate /*
23*1991Sheppo  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_MDESC_H_
280Sstevel@tonic-gate #define	_MDESC_H_
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
32962Stsien #include <sys/types.h>
33962Stsien 
340Sstevel@tonic-gate #ifdef __cplusplus
350Sstevel@tonic-gate extern "C" {
360Sstevel@tonic-gate #endif
370Sstevel@tonic-gate 
380Sstevel@tonic-gate 
390Sstevel@tonic-gate /*
400Sstevel@tonic-gate  * Each logical domain is detailed via a (Virtual) Machine Description
410Sstevel@tonic-gate  * available to each guest Operating System courtesy of a
420Sstevel@tonic-gate  * Hypervisor service.
430Sstevel@tonic-gate  */
440Sstevel@tonic-gate 
450Sstevel@tonic-gate 
460Sstevel@tonic-gate 
470Sstevel@tonic-gate #ifdef	_ASM
480Sstevel@tonic-gate #define	U8(_s)	_s
490Sstevel@tonic-gate #define	U16(_s)	_s
500Sstevel@tonic-gate #define	U32(_s)	_s
510Sstevel@tonic-gate #define	U64(_s)	_s
520Sstevel@tonic-gate #else
530Sstevel@tonic-gate #define	U8(_s)	((uint8_t)(_s))
540Sstevel@tonic-gate #define	U16(_s)	((uint16_t)(_s))
550Sstevel@tonic-gate #define	U32(_s)	((uint32_t)(_s))
560Sstevel@tonic-gate #define	U64(_s)	((uint64_t)(_s))
570Sstevel@tonic-gate #endif
580Sstevel@tonic-gate 
590Sstevel@tonic-gate 
600Sstevel@tonic-gate 
610Sstevel@tonic-gate 
620Sstevel@tonic-gate 
630Sstevel@tonic-gate 	/* the version this library understands */
640Sstevel@tonic-gate 
650Sstevel@tonic-gate #define	MD_HEADER_VERS_OFF	0x0
660Sstevel@tonic-gate #define	MD_HEADER_NODE_OFF	0x4
670Sstevel@tonic-gate #define	MD_HEADER_NAME_OFF	0x8
680Sstevel@tonic-gate #define	MD_HEADER_DATA_OFF	0xc
690Sstevel@tonic-gate 
700Sstevel@tonic-gate #define	MD_HEADER_SIZE	0x10
710Sstevel@tonic-gate 
720Sstevel@tonic-gate #define	MD_TRANSPORT_VERSION	U32(0x10000)
730Sstevel@tonic-gate 
740Sstevel@tonic-gate #define	MD_ELEMENT_SIZE	0x10
750Sstevel@tonic-gate 
760Sstevel@tonic-gate #define	MDE_ILLEGAL_IDX		U64(-1)
770Sstevel@tonic-gate 
780Sstevel@tonic-gate #define	MDET_LIST_END	U8(0x0)
790Sstevel@tonic-gate #define	MDET_NULL	U8(' ')
800Sstevel@tonic-gate #define	MDET_NODE	U8('N')
810Sstevel@tonic-gate #define	MDET_NODE_END	U8('E')
820Sstevel@tonic-gate #define	MDET_PROP_ARC	U8('a')
830Sstevel@tonic-gate #define	MDET_PROP_VAL	U8('v')
840Sstevel@tonic-gate #define	MDET_PROP_STR	U8('s')
850Sstevel@tonic-gate #define	MDET_PROP_DAT	U8('d')
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 
880Sstevel@tonic-gate #ifndef _ASM	/* { */
890Sstevel@tonic-gate 
90*1991Sheppo /*
91*1991Sheppo  * Opaque handles for use in external interfaces
92*1991Sheppo  */
93*1991Sheppo 
94*1991Sheppo typedef void			*md_t;
95*1991Sheppo 
96*1991Sheppo typedef uint64_t		mde_cookie_t;
970Sstevel@tonic-gate #define	MDE_INVAL_ELEM_COOKIE	((mde_cookie_t)-1)
980Sstevel@tonic-gate 
990Sstevel@tonic-gate typedef	uint32_t		mde_str_cookie_t;
1000Sstevel@tonic-gate #define	MDE_INVAL_STR_COOKIE	((mde_str_cookie_t)-1)
1010Sstevel@tonic-gate 
102*1991Sheppo typedef uint64_t		md_diff_cookie_t;
103*1991Sheppo #define	MD_INVAL_DIFF_COOKIE	((md_diff_cookie_t)-1)
1040Sstevel@tonic-gate 
105*1991Sheppo #define	MDESC_INVAL_GEN		(0)
106*1991Sheppo 
107*1991Sheppo /*
108*1991Sheppo  * External structure for MD diff interface
109*1991Sheppo  */
110*1991Sheppo typedef struct {
111*1991Sheppo 	uint8_t		type;		/* property type */
112*1991Sheppo 	char		*namep;		/* property name */
113*1991Sheppo } md_prop_match_t;
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate 
116*1991Sheppo /*
117*1991Sheppo  * External Interface
118*1991Sheppo  */
1190Sstevel@tonic-gate 
120*1991Sheppo extern md_t		*md_init_intern(uint64_t *,
121*1991Sheppo 				void *(*allocp)(size_t),
122*1991Sheppo 				void (*freep)(void *, size_t));
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate extern int		md_fini(md_t *);
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate extern int		md_node_count(md_t *);
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate extern mde_str_cookie_t md_find_name(md_t *, char *namep);
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate extern mde_cookie_t	md_root_node(md_t *);
1310Sstevel@tonic-gate 
132*1991Sheppo extern uint64_t		md_get_gen(md_t *);
133*1991Sheppo 
134*1991Sheppo extern size_t		md_get_bin_size(md_t *);
135*1991Sheppo 
1360Sstevel@tonic-gate extern int		md_scan_dag(md_t *,
1370Sstevel@tonic-gate 				mde_cookie_t,
1380Sstevel@tonic-gate 				mde_str_cookie_t,
1390Sstevel@tonic-gate 				mde_str_cookie_t,
1400Sstevel@tonic-gate 				mde_cookie_t *);
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate extern int		md_get_prop_val(md_t *,
1430Sstevel@tonic-gate 				mde_cookie_t,
1440Sstevel@tonic-gate 				char *,
1450Sstevel@tonic-gate 				uint64_t *);
1460Sstevel@tonic-gate 
1470Sstevel@tonic-gate extern int		md_get_prop_str(md_t *,
1480Sstevel@tonic-gate 				mde_cookie_t,
1490Sstevel@tonic-gate 				char *,
1500Sstevel@tonic-gate 				char **);
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate extern int		md_get_prop_data(md_t *,
1530Sstevel@tonic-gate 				mde_cookie_t,
1540Sstevel@tonic-gate 				char *,
1550Sstevel@tonic-gate 				uint8_t **,
1560Sstevel@tonic-gate 				int *);
1570Sstevel@tonic-gate 
158*1991Sheppo extern md_diff_cookie_t	md_diff_init(md_t *,
159*1991Sheppo 				mde_cookie_t,
160*1991Sheppo 				md_t *,
161*1991Sheppo 				mde_cookie_t,
162*1991Sheppo 				char *,
163*1991Sheppo 				md_prop_match_t *);
164*1991Sheppo 
165*1991Sheppo extern int		md_diff_added(md_diff_cookie_t,
166*1991Sheppo 				mde_cookie_t **);
167*1991Sheppo 
168*1991Sheppo extern int		md_diff_removed(md_diff_cookie_t,
169*1991Sheppo 				mde_cookie_t **);
170*1991Sheppo 
171*1991Sheppo extern int		md_diff_matched(md_diff_cookie_t,
172*1991Sheppo 				mde_cookie_t **,
173*1991Sheppo 				mde_cookie_t **);
174*1991Sheppo 
175*1991Sheppo extern int		md_diff_fini(md_diff_cookie_t);
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate #endif	/* } _ASM */
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate 
1820Sstevel@tonic-gate /*
1830Sstevel@tonic-gate  * ioctl info for mdesc device
1840Sstevel@tonic-gate  */
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate #define	MDESCIOC	('m' << 24 | 'd' << 16 | 'd' << 8)
1870Sstevel@tonic-gate 
1880Sstevel@tonic-gate #define	MDESCIOCGSZ	(MDESCIOC | 1)   /* Get quote buffer size */
1890Sstevel@tonic-gate #define	MDESCIOCSSZ	(MDESCIOC | 2)   /* Set new quote buffer size */
1900Sstevel@tonic-gate #define	MDESCIOCDISCARD	(MDESCIOC | 3)   /* Discard quotes and reset */
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate #ifdef __cplusplus
1930Sstevel@tonic-gate }
1940Sstevel@tonic-gate #endif
1950Sstevel@tonic-gate 
1960Sstevel@tonic-gate #endif	/* _MDESC_H_ */
197