xref: /illumos-gate/usr/src/lib/libpicl/picl2door.h (revision 89b2a9fbeabf42fa54594df0e5927bcc50a07cc9)
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	_PICL2DOOR_H
28 #define	_PICL2DOOR_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #define	PICLD_DOOR_VERSION	1
37 #define	PICLD_DOOR	"/var/run/picld_door"
38 #define	PICLD_DOOR_COOKIE	((void *)(0xdeaffeed ^ PICLD_DOOR_VERSION))
39 
40 /*
41  * PICL service calls
42  */
43 typedef enum {
44 	PICL_CNUM_INIT = 0x1,		/* initialize */
45 	PICL_CNUM_FINI,			/* fini */
46 	PICL_CNUM_GETROOT,		/* get root node */
47 	PICL_CNUM_GETATTRVAL, 		/* get attr val */
48 	PICL_CNUM_GETATTRVALBYNAME,	/* get attr val by name */
49 	PICL_CNUM_GETATTRINFO,		/* get attribute information */
50 	PICL_CNUM_GETFIRSTATTR, 	/* get first attribute */
51 	PICL_CNUM_GETNEXTATTR, 		/* get next attribute */
52 	PICL_CNUM_GETATTRBYNAME,	/* get attr by name */
53 	PICL_CNUM_GETATTRBYROW,		/* get attr by row */
54 	PICL_CNUM_GETATTRBYCOL,		/* get attr by column */
55 	PICL_CNUM_SETATTRVAL, 		/* set attribute's value */
56 	PICL_CNUM_SETATTRVALBYNAME,	/* set attr val by name */
57 	PICL_CNUM_PING,			/* ping daemon */
58 	PICL_CNUM_WAIT,			/* wait n seconds for refresh */
59 	PICL_CNUM_ERROR,		/* error response */
60 	PICL_CNUM_FINDNODE,		/* find node */
61 	PICL_CNUM_NODEBYPATH,		/* get node by path */
62 	PICL_CNUM_FRUTREEPARENT		/* get frutree parent */
63 } picl_callnumber_t;
64 
65 typedef	union {
66 		picl_nodehdl_t	nodeh;
67 		picl_prophdl_t	proph;
68 		char		str[1];
69 } propval_t;
70 #define	ret_buf		u.str
71 #define	ret_nodeh	u.nodeh
72 #define	ret_proph	u.proph
73 
74 /*
75  * Generic picl service request argument
76  */
77 typedef struct {
78 	picl_callnumber_t	cnum;	/* service call number */
79 	char			buf[4];	/* buffer containing input arguments */
80 } picl_req_t;
81 
82 typedef struct {
83 	picl_callnumber_t	cnum;	/* service call number */
84 	char			buf[4];	/* buffer containing the results */
85 } picl_ret_t;
86 
87 	/*
88 	 * PICL initialize
89 	 */
90 typedef struct {
91 	picl_callnumber_t	cnum;	/* PICL_CNUM_INIT */
92 	unsigned int		clrev;	/* client's ID and revision number */
93 } picl_reqinit_t;
94 
95 typedef struct {
96 	picl_callnumber_t	cnum;	/* PICL_CNUM_INIT */
97 	int			rev;	/* PICL daemon's revision number */
98 } picl_retinit_t;
99 
100 
101 	/*
102 	 * PICL shutdown
103 	 */
104 typedef struct {
105 	picl_callnumber_t	cnum;		/* PICL_CNUM_FINI */
106 } picl_reqfini_t;
107 
108 typedef struct {
109 	picl_callnumber_t	cnum;		/* PICL_CNUM_FINI */
110 } picl_retfini_t;
111 
112 	/*
113 	 * PICL get root
114 	 */
115 typedef struct {
116 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETROOT */
117 } picl_reqroot_t;
118 
119 typedef struct {
120 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETROOT */
121 	picl_nodehdl_t		rnode;		/* root handle */
122 } picl_retroot_t;
123 
124 	/*
125 	 * PICL get attr val
126 	 */
127 typedef struct {
128 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETATTRVAL */
129 	picl_prophdl_t		attr;		/* attribute handle */
130 	uint32_t		bufsize;	/* value buffer size */
131 } picl_reqattrval_t;
132 
133 typedef struct {
134 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETATTRVAL */
135 	picl_prophdl_t		attr;		/* attribute handle */
136 	uint32_t		nbytes;		/* return value size */
137 	propval_t 		u;
138 } picl_retattrval_t;
139 
140 	/*
141 	 * PICL get attr val by name
142 	 */
143 typedef struct {
144 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETATTRVALBYNAME */
145 	picl_nodehdl_t		nodeh;		/* node handle */
146 						/* attribute name */
147 	char			propname[PICL_PROPNAMELEN_MAX];
148 	uint32_t		bufsize;	/* buffer size */
149 } picl_reqattrvalbyname_t;
150 
151 typedef struct {
152 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETATTRVALBYNAME */
153 	picl_nodehdl_t		nodeh;		/* node handle */
154 						/* attribute name */
155 	char			propname[PICL_PROPNAMELEN_MAX];
156 	uint32_t		nbytes;		/* return value size */
157 	propval_t		u;		/* return value */
158 } picl_retattrvalbyname_t;
159 
160 	/*
161 	 * PICL get attr info
162 	 */
163 typedef struct {
164 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETATTRINFO */
165 	picl_prophdl_t		attr;		/* attribute handle */
166 } picl_reqattrinfo_t;
167 
168 typedef struct {
169 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETATTRINFO */
170 	picl_prophdl_t		attr;		/* attribute handle */
171 	picl_prop_type_t	type;		/* attribute type */
172 	unsigned int		accessmode;	/* access mode */
173 	uint32_t		size;		/* value size */
174 						/* attr name */
175 	char			name[PICL_PROPNAMELEN_MAX];
176 } picl_retattrinfo_t;
177 
178 	/*
179 	 * PICL get first attr
180 	 */
181 typedef struct {
182 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETFIRSTATTR */
183 	picl_nodehdl_t		nodeh;		/* node handle */
184 } picl_reqfirstattr_t;
185 
186 typedef struct {
187 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETFIRSTATTR */
188 	picl_nodehdl_t		nodeh;		/* node handle */
189 	picl_prophdl_t		attr;		/* first attribute handle */
190 } picl_retfirstattr_t;
191 
192 	/*
193 	 * PICL get next attr
194 	 */
195 typedef struct {
196 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETNEXTATTR */
197 	picl_prophdl_t		attr;		/* attribute handle */
198 } picl_reqnextattr_t;
199 
200 typedef struct {
201 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETNEXTATTR */
202 	picl_prophdl_t		attr;		/* attribute handle */
203 	picl_prophdl_t		nextattr;	/* next attribute handle */
204 } picl_retnextattr_t;
205 
206 	/*
207 	 * PICL get attr by name
208 	 */
209 typedef struct {
210 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETATTRBYNAME */
211 	picl_nodehdl_t		nodeh;		/* node handle */
212 						/* attr name */
213 	char			propname[PICL_PROPNAMELEN_MAX];
214 } picl_reqattrbyname_t;
215 
216 typedef struct {
217 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETATTRBYNAME */
218 	picl_nodehdl_t		nodeh;		/* node handle */
219 						/* attr name */
220 	char			propname[PICL_PROPNAMELEN_MAX];
221 	picl_prophdl_t		attr;		/* attr handle */
222 } picl_retattrbyname_t;
223 
224 	/*
225 	 * PICL get attr by row
226 	 */
227 typedef struct {
228 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETATTRBYROW */
229 	picl_prophdl_t		attr;		/* attr handle */
230 } picl_reqattrbyrow_t;
231 
232 typedef struct {
233 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETATTRBYROW */
234 	picl_prophdl_t		attr;		/* attr handle */
235 	picl_prophdl_t		rowattr;	/* attr by row handle */
236 } picl_retattrbyrow_t;
237 
238 	/*
239 	 * PICL get attr by column
240 	 */
241 typedef struct {
242 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETATTRBYCOL */
243 	picl_prophdl_t		attr;		/* attr handle */
244 } picl_reqattrbycol_t;
245 
246 typedef struct {
247 	picl_callnumber_t	cnum;		/* PICL_CNUM_GETATTRBYCOL */
248 	picl_prophdl_t		attr;		/* attr handle */
249 	picl_prophdl_t		colattr;	/* attr by col handle */
250 } picl_retattrbycol_t;
251 
252 	/*
253 	 * PICL set attr val
254 	 */
255 typedef struct {
256 	picl_callnumber_t	cnum;		/* PICL_CNUM_SETATTRVAL */
257 	picl_prophdl_t		attr;		/* attribute handle */
258 	uint32_t		bufsize;	/* value buffer size */
259 	char			valbuf[1];
260 } picl_reqsetattrval_t;
261 
262 typedef struct {
263 	picl_callnumber_t	cnum;		/* PICL_CNUM_SETATTRVAL */
264 	picl_prophdl_t		attr;		/* attribute handle */
265 } picl_retsetattrval_t;
266 
267 	/*
268 	 * PICL set attr val by name
269 	 */
270 typedef struct {
271 	picl_callnumber_t	cnum;		/* PICL_CNUM_SETATTRVALBYNAME */
272 	picl_nodehdl_t		nodeh;		/* node handle */
273 						/* attr name */
274 	char			propname[PICL_PROPNAMELEN_MAX];
275 	uint32_t		bufsize;	/* buffer size */
276 	char			valbuf[1];
277 } picl_reqsetattrvalbyname_t;
278 
279 typedef struct {
280 	picl_callnumber_t	cnum;		/* PICL_CNUM_SETATTRVALBYNAME */
281 	picl_nodehdl_t		nodeh;		/* node handle */
282 						/* attr name */
283 	char			propname[PICL_PROPNAMELEN_MAX];
284 } picl_retsetattrvalbyname_t;
285 
286 	/*
287 	 * PICL ping
288 	 */
289 typedef struct {
290 	picl_callnumber_t	cnum;		/* PICL_CNUM_PING */
291 } picl_reqping_t;
292 
293 typedef struct {
294 	picl_callnumber_t	cnum;		/* PICL_CNUM_PING */
295 } picl_retping_t;
296 
297 	/*
298 	 * PICL wait
299 	 */
300 typedef struct {
301 	picl_callnumber_t	cnum;		/* PICL_CNUM_WAIT */
302 	unsigned int		secs;		/* number of seconds */
303 } picl_reqwait_t;
304 
305 typedef struct {
306 	picl_callnumber_t	cnum;		/* PICL_CNUM_WAIT service */
307 	unsigned int		secs;		/* input seconds */
308 	int			retcode;	/* return code */
309 } picl_retwait_t;
310 
311 	/*
312 	 * PICL find node
313 	 */
314 typedef struct {
315 	picl_callnumber_t	cnum;		/* PICL_CNUM_FINDNODE */
316 	picl_nodehdl_t		nodeh;		/* top node handle */
317 						/* property name */
318 	char			propname[PICL_PROPNAMELEN_MAX];
319 	picl_prop_type_t	ptype;		/* property type */
320 	uint32_t		valsize;	/* size of prop value */
321 	char			valbuf[1];	/* prop value */
322 } picl_reqfindnode_t;
323 
324 typedef struct {
325 	picl_callnumber_t	cnum;		/* PICL_CNUM_FINDNODE */
326 	picl_nodehdl_t		rnodeh;		/* matched node */
327 } picl_retfindnode_t;
328 
329 	/*
330 	 * PICL get node by path
331 	 */
332 typedef struct {
333 	picl_callnumber_t	cnum;		/* PICL_CNUM_NODEBYPATH */
334 	uint32_t		psize;		/* size of path */
335 	char			pathbuf[PATH_MAX];	/* picl path */
336 } picl_reqnodebypath_t;
337 
338 typedef struct {
339 	picl_callnumber_t	cnum;		/* PICL_CNUM_NODEBYPATH */
340 	picl_nodehdl_t		nodeh;		/* node handle */
341 } picl_retnodebypath_t;
342 
343 	/*
344 	 * PICL get frutree parent
345 	 */
346 typedef struct {
347 	picl_callnumber_t	cnum;		/* PICL_CNUM_FRUTREEPARENT */
348 	picl_nodehdl_t		devh;		/* dev node handle */
349 } picl_reqfruparent_t;
350 
351 typedef struct {
352 	picl_callnumber_t	cnum;		/* PICL_CNUM_FRUTREEPARENT */
353 	picl_nodehdl_t		fruh;		/* fru parent handle */
354 } picl_retfruparent_t;
355 
356 	/*
357 	 * PICL error return
358 	 */
359 typedef struct {
360 	picl_callnumber_t	cnum;		/* PICL_CNUM_ERROR */
361 	picl_callnumber_t	in_cnum;	/* requested service number */
362 	picl_errno_t		errnum;		/* return error code */
363 } picl_reterror_t;
364 
365 typedef union {
366 	picl_req_t		in;			/* req arguments */
367 	picl_ret_t		out;			/* out results */
368 
369 	picl_reqinit_t		req_init;		/* req initialize */
370 	picl_retinit_t		ret_init;		/* ret initialize */
371 
372 	picl_reqfini_t		req_fini;		/* req fini */
373 	picl_retfini_t		ret_fini;		/* ret fini */
374 
375 	picl_reqroot_t		req_root;		/* req root node */
376 	picl_retroot_t		ret_root;		/* ret root node */
377 
378 	picl_reqattrval_t	req_attrval;		/* req attr value */
379 	picl_retattrval_t	ret_attrval;		/* ret attr value */
380 
381 						/* req attr val by name */
382 	picl_reqattrvalbyname_t	req_attrvalbyname;
383 						/* ret attr val by name */
384 	picl_retattrvalbyname_t	ret_attrvalbyname;
385 
386 	picl_reqattrinfo_t    	req_attrinfo;		/* req attr info */
387 	picl_retattrinfo_t    	ret_attrinfo;		/* ret attr info */
388 
389 	picl_reqfirstattr_t	req_firstattr;		/* req first attr */
390 	picl_retfirstattr_t	ret_firstattr;		/* ret first attr */
391 
392 	picl_reqnextattr_t	req_nextattr;		/* req next attr */
393 	picl_retnextattr_t	ret_nextattr;		/* ret next attr */
394 
395 	picl_reqattrbyname_t	req_attrbyname;		/* req attr by name */
396 	picl_retattrbyname_t	ret_attrbyname;		/* ret attr by name */
397 
398 	picl_reqattrbyrow_t	req_attrbyrow;		/* req attr by row */
399 	picl_retattrbyrow_t	ret_attrbyrow;		/* ret attr by row */
400 
401 	picl_reqattrbycol_t	req_attrbycol;		/* req attr by col */
402 	picl_retattrbycol_t	ret_attrbycol;		/* ret attr by col */
403 
404 						/* set attribute value */
405 	picl_reqsetattrval_t	req_setattrval;
406 						/* ret set attribute value */
407 	picl_retsetattrval_t	ret_setattrval;
408 
409 						/* set attr val by name */
410 	picl_reqsetattrvalbyname_t	req_setattrvalbyname;
411 						/* set attr val by name */
412 	picl_retsetattrvalbyname_t	ret_setattrvalbyname;
413 
414 	picl_reqping_t		req_ping;		/* req ping */
415 	picl_retping_t		ret_ping;		/* ret ping */
416 
417 	picl_reqwait_t		req_wait;		/* req wait */
418 	picl_retwait_t		ret_wait;		/* ret wait */
419 
420 	picl_reqfindnode_t	req_findnode;	/* req find node */
421 	picl_retfindnode_t	ret_findnode;	/* ret find node */
422 
423 	picl_reqnodebypath_t	req_nodebypath;	/* get node by path */
424 	picl_retnodebypath_t	ret_nodebypath;	/* ret node by path */
425 
426 	picl_reqfruparent_t	req_fruparent;	/* get frutree parent */
427 	picl_retfruparent_t	ret_fruparent;	/* ret frutree parent */
428 
429 	picl_reterror_t		ret_error;		/* return error */
430 } picl_service_t;
431 
432 #ifdef	__cplusplus
433 }
434 #endif
435 
436 #endif	/* _PICL2DOOR_H */
437