8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libpicl / picl.h
blob02ca5bbb101b3e4333096e274f3085d873a2f678
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 _PICL_H
28 #define _PICL_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
37 * PICL Interface
40 #include <sys/types.h>
42 #define PICL_VERSION_1 0x1
45 * A PICL handle
47 typedef uint64_t picl_nodehdl_t;
48 typedef uint64_t picl_prophdl_t;
51 * Maximum length of a property name
53 #define PICL_PROPNAMELEN_MAX 256
54 #define PICL_CLASSNAMELEN_MAX (PICL_PROPNAMELEN_MAX - sizeof ("__"))
57 * Maximum size of a property value
59 #define PICL_PROPSIZE_MAX (512 * 1024)
62 * PICL property access modes
64 #define PICL_READ 0x1
65 #define PICL_WRITE 0x2
66 /* Not seen by clients */
67 #define PICL_VOLATILE 0x4
70 * PICL error numbers
72 typedef enum {
73 PICL_SUCCESS = 0x0,
74 PICL_FAILURE, /* general failure */
75 PICL_NORESPONSE, /* No response */
76 PICL_UNKNOWNSERVICE, /* unknown PICL service */
77 PICL_NOTINITIALIZED, /* interface not initialized */
78 PICL_INVALIDARG, /* invalid arguments passed */
79 PICL_VALUETOOBIG, /* value too big for buffer */
80 PICL_PROPNOTFOUND, /* property not found */
81 PICL_NOTTABLE, /* not a table */
82 PICL_NOTNODE, /* not a node */
83 PICL_NOTPROP, /* not a prop */
84 PICL_ENDOFLIST, /* end of list */
85 PICL_PROPEXISTS, /* prop already exists */
86 PICL_NOTWRITABLE, /* not writable */
87 PICL_PERMDENIED, /* permission denied */
88 PICL_INVALIDHANDLE, /* invalid handle */
89 PICL_STALEHANDLE, /* stale handle */
90 PICL_NOTSUPPORTED, /* version not supported */
91 PICL_TIMEDOUT, /* timed out */
92 PICL_CANTDESTROY, /* cannot destroy */
93 PICL_TREEBUSY, /* too busy to lock tree */
94 PICL_CANTPARENT, /* already has a parent */
95 PICL_RESERVEDNAME, /* property name is reserved */
96 PICL_INVREFERENCE, /* Invalid reference value */
97 PICL_WALK_CONTINUE, /* continue walking tree */
98 PICL_WALK_TERMINATE, /* stop walking tree */
99 PICL_NODENOTFOUND, /* node not found */
100 PICL_NOSPACE, /* not enough space available */
101 PICL_NOTREADABLE, /* property not readable */
102 PICL_PROPVALUNAVAILABLE /* property value unavailable */
103 } picl_errno_t;
106 * PICL property types
108 typedef enum {
109 PICL_PTYPE_UNKNOWN = 0x0,
110 PICL_PTYPE_VOID, /* exists or not */
111 PICL_PTYPE_INT, /* scalar */
112 PICL_PTYPE_UNSIGNED_INT, /* scalar */
113 PICL_PTYPE_FLOAT, /* scalar */
114 PICL_PTYPE_REFERENCE, /* reference handle */
115 PICL_PTYPE_TABLE, /* table handle */
116 PICL_PTYPE_TIMESTAMP, /* time stamp */
117 PICL_PTYPE_BYTEARRAY, /* array of bytes */
118 PICL_PTYPE_CHARSTRING /* nul terminated array of chars */
119 } picl_prop_type_t;
121 typedef struct {
122 picl_prop_type_t type;
123 unsigned int accessmode; /* always == PICL_READ */
124 size_t size; /* item size or string size */
125 char name[PICL_PROPNAMELEN_MAX];
126 } picl_propinfo_t;
129 * -------------------------------------
130 * Function prototypes of PICL Interface
131 * -------------------------------------
134 extern int picl_initialize(void);
135 extern int picl_shutdown(void);
136 extern int picl_get_root(picl_nodehdl_t *nodehandle);
137 extern int picl_get_propval(picl_prophdl_t proph, void *valbuf,
138 size_t sz);
139 extern int picl_get_propval_by_name(picl_nodehdl_t nodeh,
140 const char *propname, void *valbuf, size_t sz);
141 extern int picl_set_propval(picl_prophdl_t proph, void *valbuf,
142 size_t sz);
143 extern int picl_set_propval_by_name(picl_nodehdl_t nodeh,
144 const char *propname, void *valbuf, size_t sz);
145 extern int picl_get_propinfo(picl_prophdl_t proph, picl_propinfo_t *pi);
146 extern int picl_get_first_prop(picl_nodehdl_t nodeh, picl_prophdl_t *proph);
147 extern int picl_get_next_prop(picl_prophdl_t proph, picl_prophdl_t *nexth);
148 extern int picl_get_prop_by_name(picl_nodehdl_t nodeh, const char *nm,
149 picl_prophdl_t *ph);
150 extern int picl_get_next_by_row(picl_prophdl_t thish, picl_prophdl_t *proph);
151 extern int picl_get_next_by_col(picl_prophdl_t thish, picl_prophdl_t *proph);
152 extern int picl_wait(unsigned int secs);
153 extern char *picl_strerror(int err);
154 extern int picl_walk_tree_by_class(picl_nodehdl_t rooth,
155 const char *classname, void *c_args,
156 int (*callback_fn)(picl_nodehdl_t hdl, void *args));
157 extern int picl_get_propinfo_by_name(picl_nodehdl_t nodeh, const char *pname,
158 picl_propinfo_t *pinfo, picl_prophdl_t *proph);
160 extern int picl_find_node(picl_nodehdl_t rooth, char *pname,
161 picl_prop_type_t ptype, void *pval, size_t valsize,
162 picl_nodehdl_t *retnodeh);
164 extern int picl_get_node_by_path(const char *piclpath, picl_nodehdl_t *nodeh);
166 extern int picl_get_frutree_parent(picl_nodehdl_t devh, picl_nodehdl_t *fruh);
169 * Standard PICL names: properties and nodes
171 #define PICL_NODE_ROOT "/"
172 #define PICL_NODE_PLATFORM "platform"
173 #define PICL_NODE_OBP "obp"
174 #define PICL_NODE_FRUTREE "frutree"
176 #define PICL_PROP_NAME "name"
177 #define PICL_PROP_CLASSNAME "_class"
178 #define PICL_PROP_PARENT "_parent"
179 #define PICL_PROP_CHILD "_child"
180 #define PICL_PROP_PEER "_peer"
182 #define PICL_CLASS_PICL "picl"
184 #ifdef __cplusplus
186 #endif
188 #endif /* _PICL_H */