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