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 51991Sheppo * Common Development and Distribution License (the "License"). 61991Sheppo * 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 */ 211991Sheppo 220Sstevel@tonic-gate /* 23*7205Ssd77468 * Copyright 2008 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 901991Sheppo /* 911991Sheppo * Opaque handles for use in external interfaces 921991Sheppo */ 931991Sheppo 941991Sheppo typedef void *md_t; 951991Sheppo 961991Sheppo 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 1021991Sheppo typedef uint64_t md_diff_cookie_t; 1031991Sheppo #define MD_INVAL_DIFF_COOKIE ((md_diff_cookie_t)-1) 1040Sstevel@tonic-gate 1051991Sheppo #define MDESC_INVAL_GEN (0) 1061991Sheppo 1071991Sheppo /* 1081991Sheppo * External structure for MD diff interface 1091991Sheppo */ 1101991Sheppo typedef struct { 1111991Sheppo uint8_t type; /* property type */ 1121991Sheppo char *namep; /* property name */ 1131991Sheppo } md_prop_match_t; 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate 1161991Sheppo /* 117*7205Ssd77468 * Walk callback function return codes 118*7205Ssd77468 */ 119*7205Ssd77468 #define MDE_WALK_ERROR -1 /* Terminate walk with error */ 120*7205Ssd77468 #define MDE_WALK_NEXT 0 /* Continue to next node */ 121*7205Ssd77468 #define MDE_WALK_DONE 1 /* Terminate walk with success */ 122*7205Ssd77468 123*7205Ssd77468 /* 124*7205Ssd77468 * The function prototype for a walker callback function. 125*7205Ssd77468 * The machine description session, parent node, current node, 126*7205Ssd77468 * and private data are given to the callback. 127*7205Ssd77468 * 128*7205Ssd77468 * The parent node is given to the callback to provide context 129*7205Ssd77468 * on how the walker arrived at this location. While the node 130*7205Ssd77468 * may have many parents, it will be visited only once, this 131*7205Ssd77468 * provides context on how the walker arrived at the node. 132*7205Ssd77468 * 133*7205Ssd77468 * Input Description 134*7205Ssd77468 * ------------------- ---------------------------------------- 135*7205Ssd77468 * md_t * Pointer to md session 136*7205Ssd77468 * mde_cookie_t Index of parent node to provide context 137*7205Ssd77468 * mde_cookie_t The current node in the walk 138*7205Ssd77468 * void * Private data for the walking function 139*7205Ssd77468 */ 140*7205Ssd77468 typedef int md_walk_fn_t(md_t *, mde_cookie_t, mde_cookie_t, void *); 141*7205Ssd77468 142*7205Ssd77468 143*7205Ssd77468 /* 1441991Sheppo * External Interface 1451991Sheppo */ 1460Sstevel@tonic-gate 1471991Sheppo extern md_t *md_init_intern(uint64_t *, 1481991Sheppo void *(*allocp)(size_t), 1491991Sheppo void (*freep)(void *, size_t)); 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate extern int md_fini(md_t *); 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate extern int md_node_count(md_t *); 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate extern mde_str_cookie_t md_find_name(md_t *, char *namep); 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate extern mde_cookie_t md_root_node(md_t *); 1580Sstevel@tonic-gate 1591991Sheppo extern uint64_t md_get_gen(md_t *); 1601991Sheppo 1611991Sheppo extern size_t md_get_bin_size(md_t *); 1621991Sheppo 1630Sstevel@tonic-gate extern int md_scan_dag(md_t *, 1640Sstevel@tonic-gate mde_cookie_t, 1650Sstevel@tonic-gate mde_str_cookie_t, 1660Sstevel@tonic-gate mde_str_cookie_t, 1670Sstevel@tonic-gate mde_cookie_t *); 1680Sstevel@tonic-gate 169*7205Ssd77468 extern int md_walk_dag(md_t *, 170*7205Ssd77468 mde_cookie_t, 171*7205Ssd77468 mde_str_cookie_t, 172*7205Ssd77468 mde_str_cookie_t, 173*7205Ssd77468 md_walk_fn_t, 174*7205Ssd77468 void *); 175*7205Ssd77468 1760Sstevel@tonic-gate extern int md_get_prop_val(md_t *, 1770Sstevel@tonic-gate mde_cookie_t, 1780Sstevel@tonic-gate char *, 1790Sstevel@tonic-gate uint64_t *); 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate extern int md_get_prop_str(md_t *, 1820Sstevel@tonic-gate mde_cookie_t, 1830Sstevel@tonic-gate char *, 1840Sstevel@tonic-gate char **); 1850Sstevel@tonic-gate 1860Sstevel@tonic-gate extern int md_get_prop_data(md_t *, 1870Sstevel@tonic-gate mde_cookie_t, 1880Sstevel@tonic-gate char *, 1890Sstevel@tonic-gate uint8_t **, 1900Sstevel@tonic-gate int *); 1910Sstevel@tonic-gate 192*7205Ssd77468 extern int md_get_prop_arcs(md_t *, 193*7205Ssd77468 mde_cookie_t, 194*7205Ssd77468 char *, 195*7205Ssd77468 mde_cookie_t *, 196*7205Ssd77468 size_t); 197*7205Ssd77468 198*7205Ssd77468 1991991Sheppo extern md_diff_cookie_t md_diff_init(md_t *, 2001991Sheppo mde_cookie_t, 2011991Sheppo md_t *, 2021991Sheppo mde_cookie_t, 2031991Sheppo char *, 2041991Sheppo md_prop_match_t *); 2051991Sheppo 2061991Sheppo extern int md_diff_added(md_diff_cookie_t, 2071991Sheppo mde_cookie_t **); 2081991Sheppo 2091991Sheppo extern int md_diff_removed(md_diff_cookie_t, 2101991Sheppo mde_cookie_t **); 2111991Sheppo 2121991Sheppo extern int md_diff_matched(md_diff_cookie_t, 2131991Sheppo mde_cookie_t **, 2141991Sheppo mde_cookie_t **); 2151991Sheppo 2161991Sheppo extern int md_diff_fini(md_diff_cookie_t); 2170Sstevel@tonic-gate 2180Sstevel@tonic-gate 2190Sstevel@tonic-gate #endif /* } _ASM */ 2200Sstevel@tonic-gate 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate /* 2240Sstevel@tonic-gate * ioctl info for mdesc device 2250Sstevel@tonic-gate */ 2260Sstevel@tonic-gate 2270Sstevel@tonic-gate #define MDESCIOC ('m' << 24 | 'd' << 16 | 'd' << 8) 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate #define MDESCIOCGSZ (MDESCIOC | 1) /* Get quote buffer size */ 2300Sstevel@tonic-gate #define MDESCIOCSSZ (MDESCIOC | 2) /* Set new quote buffer size */ 2310Sstevel@tonic-gate #define MDESCIOCDISCARD (MDESCIOC | 3) /* Discard quotes and reset */ 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate #ifdef __cplusplus 2340Sstevel@tonic-gate } 2350Sstevel@tonic-gate #endif 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate #endif /* _MDESC_H_ */ 238