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 2004 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 _PICLTREE_H 28*7c478bd9Sstevel@tonic-gate #define _PICLTREE_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 31*7c478bd9Sstevel@tonic-gate extern "C" { 32*7c478bd9Sstevel@tonic-gate #endif 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate /* 35*7c478bd9Sstevel@tonic-gate * PTree Interface 36*7c478bd9Sstevel@tonic-gate */ 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #include <door.h> 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate /* 41*7c478bd9Sstevel@tonic-gate * Plug-in directories 42*7c478bd9Sstevel@tonic-gate */ 43*7c478bd9Sstevel@tonic-gate #define PICLD_COMMON_PLUGIN_DIR "/usr/lib/picl/plugins" 44*7c478bd9Sstevel@tonic-gate #define PICLD_PLAT_PLUGIN_DIRF "/usr/platform/%s/lib/picl/plugins/" 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate typedef struct { 47*7c478bd9Sstevel@tonic-gate picl_nodehdl_t nodeh; 48*7c478bd9Sstevel@tonic-gate picl_prophdl_t proph; 49*7c478bd9Sstevel@tonic-gate door_cred_t cred; 50*7c478bd9Sstevel@tonic-gate } ptree_rarg_t; 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate typedef struct { 53*7c478bd9Sstevel@tonic-gate picl_nodehdl_t nodeh; 54*7c478bd9Sstevel@tonic-gate picl_prophdl_t proph; 55*7c478bd9Sstevel@tonic-gate door_cred_t cred; 56*7c478bd9Sstevel@tonic-gate } ptree_warg_t; 57*7c478bd9Sstevel@tonic-gate /* 58*7c478bd9Sstevel@tonic-gate * Volatile type properties must specify their maximum size in 'size' 59*7c478bd9Sstevel@tonic-gate * of propinfo_t at the time of creation. That guarantees clients 60*7c478bd9Sstevel@tonic-gate * accessing those properties an upper limit on value size. 61*7c478bd9Sstevel@tonic-gate * The two property types that have to specify a maximum are: 62*7c478bd9Sstevel@tonic-gate * PICL_PTYPE_BYTEARRAY, and PICL_PTYPE_CHARSTRING 63*7c478bd9Sstevel@tonic-gate */ 64*7c478bd9Sstevel@tonic-gate #define PTREE_PROPINFO_VERSION_1 1 65*7c478bd9Sstevel@tonic-gate #define PTREE_PROPINFO_VERSION PTREE_PROPINFO_VERSION_1 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate typedef struct { 68*7c478bd9Sstevel@tonic-gate int version; 69*7c478bd9Sstevel@tonic-gate picl_propinfo_t piclinfo; /* client info */ 70*7c478bd9Sstevel@tonic-gate int (*read)(ptree_rarg_t *arg, void *buf); 71*7c478bd9Sstevel@tonic-gate int (*write)(ptree_warg_t *arg, const void *buf); 72*7c478bd9Sstevel@tonic-gate } ptree_propinfo_t; 73*7c478bd9Sstevel@tonic-gate 74*7c478bd9Sstevel@tonic-gate /* 75*7c478bd9Sstevel@tonic-gate * -------------------------------------------------- 76*7c478bd9Sstevel@tonic-gate * Function prototypes of PTree Interface primitives 77*7c478bd9Sstevel@tonic-gate * -------------------------------------------------- 78*7c478bd9Sstevel@tonic-gate */ 79*7c478bd9Sstevel@tonic-gate /* 80*7c478bd9Sstevel@tonic-gate * create/destroy/add/delete a node/property instance 81*7c478bd9Sstevel@tonic-gate */ 82*7c478bd9Sstevel@tonic-gate extern int ptree_get_root(picl_nodehdl_t *nodeh); 83*7c478bd9Sstevel@tonic-gate extern int ptree_create_node(const char *name, const char *clname, 84*7c478bd9Sstevel@tonic-gate picl_nodehdl_t *nodeh); 85*7c478bd9Sstevel@tonic-gate extern int ptree_destroy_node(picl_nodehdl_t nodeh); 86*7c478bd9Sstevel@tonic-gate extern int ptree_add_node(picl_nodehdl_t parh, picl_nodehdl_t chdh); 87*7c478bd9Sstevel@tonic-gate extern int ptree_delete_node(picl_nodehdl_t nodeh); 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate extern int ptree_create_prop(const ptree_propinfo_t *pi, const void *vbuf, 90*7c478bd9Sstevel@tonic-gate picl_prophdl_t *proph); 91*7c478bd9Sstevel@tonic-gate extern int ptree_destroy_prop(picl_prophdl_t proph); 92*7c478bd9Sstevel@tonic-gate extern int ptree_delete_prop(picl_prophdl_t proph); 93*7c478bd9Sstevel@tonic-gate extern int ptree_add_prop(picl_nodehdl_t nodeh, picl_prophdl_t proph); 94*7c478bd9Sstevel@tonic-gate extern int ptree_create_table(picl_prophdl_t *tbl_hdl); 95*7c478bd9Sstevel@tonic-gate extern int ptree_add_row_to_table(picl_prophdl_t tbl, int nprops, 96*7c478bd9Sstevel@tonic-gate const picl_prophdl_t *props); 97*7c478bd9Sstevel@tonic-gate extern int ptree_update_propval_by_name(picl_nodehdl_t nodeh, 98*7c478bd9Sstevel@tonic-gate const char *name, const void *vbuf, size_t sz); 99*7c478bd9Sstevel@tonic-gate extern int ptree_update_propval(picl_prophdl_t proph, const void *buf, 100*7c478bd9Sstevel@tonic-gate size_t sz); 101*7c478bd9Sstevel@tonic-gate extern int ptree_get_propval(picl_prophdl_t proph, void *buf, 102*7c478bd9Sstevel@tonic-gate size_t sz); 103*7c478bd9Sstevel@tonic-gate extern int ptree_get_propval_by_name(picl_nodehdl_t nodeh, 104*7c478bd9Sstevel@tonic-gate const char *name, void *buf, size_t sz); 105*7c478bd9Sstevel@tonic-gate extern int ptree_get_propinfo(picl_prophdl_t proph, ptree_propinfo_t *pi); 106*7c478bd9Sstevel@tonic-gate extern int ptree_get_first_prop(picl_nodehdl_t nodeh, 107*7c478bd9Sstevel@tonic-gate picl_prophdl_t *proph); 108*7c478bd9Sstevel@tonic-gate extern int ptree_get_next_prop(picl_prophdl_t thish, 109*7c478bd9Sstevel@tonic-gate picl_prophdl_t *proph); 110*7c478bd9Sstevel@tonic-gate extern int ptree_get_prop_by_name(picl_nodehdl_t nodeh, const char *name, 111*7c478bd9Sstevel@tonic-gate picl_prophdl_t *proph); 112*7c478bd9Sstevel@tonic-gate extern int ptree_get_next_by_row(picl_prophdl_t proph, 113*7c478bd9Sstevel@tonic-gate picl_prophdl_t *rowh); 114*7c478bd9Sstevel@tonic-gate extern int ptree_get_next_by_col(picl_prophdl_t proph, 115*7c478bd9Sstevel@tonic-gate picl_prophdl_t *colh); 116*7c478bd9Sstevel@tonic-gate extern int ptree_init_propinfo(ptree_propinfo_t *infop, int version, 117*7c478bd9Sstevel@tonic-gate int ptype, int pmode, size_t psize, char *pname, 118*7c478bd9Sstevel@tonic-gate int (*readfn)(ptree_rarg_t *, void *), 119*7c478bd9Sstevel@tonic-gate int (*writefn)(ptree_warg_t *, const void *)); 120*7c478bd9Sstevel@tonic-gate extern int ptree_create_and_add_prop(picl_nodehdl_t nodeh, 121*7c478bd9Sstevel@tonic-gate ptree_propinfo_t *infop, void *vbuf, 122*7c478bd9Sstevel@tonic-gate picl_prophdl_t *proph); 123*7c478bd9Sstevel@tonic-gate extern int ptree_create_and_add_node(picl_nodehdl_t rooth, 124*7c478bd9Sstevel@tonic-gate const char *name, const char *classname, 125*7c478bd9Sstevel@tonic-gate picl_nodehdl_t *nodeh); 126*7c478bd9Sstevel@tonic-gate extern int ptree_get_node_by_path(const char *piclurl, 127*7c478bd9Sstevel@tonic-gate picl_nodehdl_t *handle); 128*7c478bd9Sstevel@tonic-gate extern int ptree_walk_tree_by_class(picl_nodehdl_t rooth, 129*7c478bd9Sstevel@tonic-gate const char *classname, void *c_args, 130*7c478bd9Sstevel@tonic-gate int (*callback_fn)(picl_nodehdl_t hdl, void *args)); 131*7c478bd9Sstevel@tonic-gate extern int ptree_find_node(picl_nodehdl_t rooth, char *pname, 132*7c478bd9Sstevel@tonic-gate picl_prop_type_t ptype, void *pval, size_t valsize, 133*7c478bd9Sstevel@tonic-gate picl_nodehdl_t *retnodeh); 134*7c478bd9Sstevel@tonic-gate extern int ptree_post_event(const char *ename, const void *earg, 135*7c478bd9Sstevel@tonic-gate size_t size, void (*completion_handler)(char *ename, 136*7c478bd9Sstevel@tonic-gate void *earg, size_t size)); 137*7c478bd9Sstevel@tonic-gate extern int ptree_register_handler(const char *ename, 138*7c478bd9Sstevel@tonic-gate void (*evt_handler)(const char *ename, const void *earg, 139*7c478bd9Sstevel@tonic-gate size_t size, void *cookie), void *cookie); 140*7c478bd9Sstevel@tonic-gate extern void ptree_unregister_handler(const char *ename, 141*7c478bd9Sstevel@tonic-gate void (*evt_handler)(const char *ename, const void *earg, 142*7c478bd9Sstevel@tonic-gate size_t size, void *cookie), void *cookie); 143*7c478bd9Sstevel@tonic-gate extern int ptree_get_frutree_parent(picl_nodehdl_t nodeh, 144*7c478bd9Sstevel@tonic-gate picl_nodehdl_t *retnodeh); 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate /* 147*7c478bd9Sstevel@tonic-gate * PICL plug-in revision 148*7c478bd9Sstevel@tonic-gate */ 149*7c478bd9Sstevel@tonic-gate #define PICLD_PLUGIN_VERSION_1 1 150*7c478bd9Sstevel@tonic-gate #define PICLD_PLUGIN_VERSION_2 2 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate #define PICLD_PLUGIN_VERSION PICLD_PLUGIN_VERSION_1 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate #define PICLD_PLUGIN_NON_CRITICAL 0 155*7c478bd9Sstevel@tonic-gate #define PICLD_PLUGIN_CRITICAL 1 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate /* 158*7c478bd9Sstevel@tonic-gate * PICL plug-in registration interface 159*7c478bd9Sstevel@tonic-gate */ 160*7c478bd9Sstevel@tonic-gate typedef struct { 161*7c478bd9Sstevel@tonic-gate int version; 162*7c478bd9Sstevel@tonic-gate int critical; 163*7c478bd9Sstevel@tonic-gate char *name; 164*7c478bd9Sstevel@tonic-gate void (*plugin_init)(void); 165*7c478bd9Sstevel@tonic-gate void (*plugin_fini)(void); 166*7c478bd9Sstevel@tonic-gate } picld_plugin_reg_t; 167*7c478bd9Sstevel@tonic-gate 168*7c478bd9Sstevel@tonic-gate extern int picld_plugin_register(picld_plugin_reg_t *regp); 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 171*7c478bd9Sstevel@tonic-gate } 172*7c478bd9Sstevel@tonic-gate #endif 173*7c478bd9Sstevel@tonic-gate 174*7c478bd9Sstevel@tonic-gate #endif /* _PICLTREE_H */ 175