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