8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libpicltree / picltree.h
blob294a08672e764983b2dc5a176f594d81a1e3525c
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _PICLTREE_H
28 #define _PICLTREE_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
37 * PTree Interface
40 #include <door.h>
43 * Plug-in directories
45 #define PICLD_COMMON_PLUGIN_DIR "/usr/lib/picl/plugins"
46 #define PICLD_PLAT_PLUGIN_DIRF "/usr/platform/%s/lib/picl/plugins/"
48 typedef struct {
49 picl_nodehdl_t nodeh;
50 picl_prophdl_t proph;
51 door_cred_t cred;
52 } ptree_rarg_t;
54 typedef struct {
55 picl_nodehdl_t nodeh;
56 picl_prophdl_t proph;
57 door_cred_t cred;
58 } ptree_warg_t;
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
66 #define PTREE_PROPINFO_VERSION_1 1
67 #define PTREE_PROPINFO_VERSION PTREE_PROPINFO_VERSION_1
69 typedef 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;
77 * --------------------------------------------------
78 * Function prototypes of PTree Interface primitives
79 * --------------------------------------------------
82 * create/destroy/add/delete a node/property instance
84 extern int ptree_get_root(picl_nodehdl_t *nodeh);
85 extern int ptree_create_node(const char *name, const char *clname,
86 picl_nodehdl_t *nodeh);
87 extern int ptree_destroy_node(picl_nodehdl_t nodeh);
88 extern int ptree_add_node(picl_nodehdl_t parh, picl_nodehdl_t chdh);
89 extern int ptree_delete_node(picl_nodehdl_t nodeh);
91 extern int ptree_create_prop(const ptree_propinfo_t *pi, const void *vbuf,
92 picl_prophdl_t *proph);
93 extern int ptree_destroy_prop(picl_prophdl_t proph);
94 extern int ptree_delete_prop(picl_prophdl_t proph);
95 extern int ptree_add_prop(picl_nodehdl_t nodeh, picl_prophdl_t proph);
96 extern int ptree_create_table(picl_prophdl_t *tbl_hdl);
97 extern int ptree_add_row_to_table(picl_prophdl_t tbl, int nprops,
98 const picl_prophdl_t *props);
99 extern int ptree_update_propval_by_name(picl_nodehdl_t nodeh,
100 const char *name, const void *vbuf, size_t sz);
101 extern int ptree_update_propval(picl_prophdl_t proph, const void *buf,
102 size_t sz);
103 extern int ptree_get_propval(picl_prophdl_t proph, void *buf,
104 size_t sz);
105 extern int ptree_get_propval_by_name(picl_nodehdl_t nodeh,
106 const char *name, void *buf, size_t sz);
107 extern int ptree_get_propinfo(picl_prophdl_t proph, ptree_propinfo_t *pi);
108 extern int ptree_get_first_prop(picl_nodehdl_t nodeh,
109 picl_prophdl_t *proph);
110 extern int ptree_get_next_prop(picl_prophdl_t thish,
111 picl_prophdl_t *proph);
112 extern int ptree_get_prop_by_name(picl_nodehdl_t nodeh, const char *name,
113 picl_prophdl_t *proph);
114 extern int ptree_get_next_by_row(picl_prophdl_t proph,
115 picl_prophdl_t *rowh);
116 extern int ptree_get_next_by_col(picl_prophdl_t proph,
117 picl_prophdl_t *colh);
118 extern 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 *));
122 extern int ptree_create_and_add_prop(picl_nodehdl_t nodeh,
123 ptree_propinfo_t *infop, void *vbuf,
124 picl_prophdl_t *proph);
125 extern int ptree_create_and_add_node(picl_nodehdl_t rooth,
126 const char *name, const char *classname,
127 picl_nodehdl_t *nodeh);
128 extern int ptree_get_node_by_path(const char *piclurl,
129 picl_nodehdl_t *handle);
130 extern 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));
133 extern 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);
136 extern 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));
139 extern 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);
142 extern 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);
145 extern int ptree_get_frutree_parent(picl_nodehdl_t nodeh,
146 picl_nodehdl_t *retnodeh);
149 * PICL plug-in revision
151 #define PICLD_PLUGIN_VERSION_1 1
152 #define PICLD_PLUGIN_VERSION_2 2
154 #define PICLD_PLUGIN_VERSION PICLD_PLUGIN_VERSION_1
156 #define PICLD_PLUGIN_NON_CRITICAL 0
157 #define PICLD_PLUGIN_CRITICAL 1
160 * PICL plug-in registration interface
162 typedef 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;
170 extern int picld_plugin_register(picld_plugin_reg_t *regp);
172 #ifdef __cplusplus
174 #endif
176 #endif /* _PICLTREE_H */