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