1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _PICL_H 28*0Sstevel@tonic-gate #define _PICL_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef __cplusplus 33*0Sstevel@tonic-gate extern "C" { 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate /* 37*0Sstevel@tonic-gate * PICL Interface 38*0Sstevel@tonic-gate */ 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate #include <sys/types.h> 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate #define PICL_VERSION_1 0x1 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate /* 45*0Sstevel@tonic-gate * A PICL handle 46*0Sstevel@tonic-gate */ 47*0Sstevel@tonic-gate typedef uint64_t picl_nodehdl_t; 48*0Sstevel@tonic-gate typedef uint64_t picl_prophdl_t; 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate /* 51*0Sstevel@tonic-gate * Maximum length of a property name 52*0Sstevel@tonic-gate */ 53*0Sstevel@tonic-gate #define PICL_PROPNAMELEN_MAX 256 54*0Sstevel@tonic-gate #define PICL_CLASSNAMELEN_MAX (PICL_PROPNAMELEN_MAX - sizeof ("__")) 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate /* 57*0Sstevel@tonic-gate * Maximum size of a property value 58*0Sstevel@tonic-gate */ 59*0Sstevel@tonic-gate #define PICL_PROPSIZE_MAX (512 * 1024) 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate /* 62*0Sstevel@tonic-gate * PICL property access modes 63*0Sstevel@tonic-gate */ 64*0Sstevel@tonic-gate #define PICL_READ 0x1 65*0Sstevel@tonic-gate #define PICL_WRITE 0x2 66*0Sstevel@tonic-gate /* Not seen by clients */ 67*0Sstevel@tonic-gate #define PICL_VOLATILE 0x4 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate /* 70*0Sstevel@tonic-gate * PICL error numbers 71*0Sstevel@tonic-gate */ 72*0Sstevel@tonic-gate typedef enum { 73*0Sstevel@tonic-gate PICL_SUCCESS = 0x0, 74*0Sstevel@tonic-gate PICL_FAILURE, /* general failure */ 75*0Sstevel@tonic-gate PICL_NORESPONSE, /* No response */ 76*0Sstevel@tonic-gate PICL_UNKNOWNSERVICE, /* unknown PICL service */ 77*0Sstevel@tonic-gate PICL_NOTINITIALIZED, /* interface not initialized */ 78*0Sstevel@tonic-gate PICL_INVALIDARG, /* invalid arguments passed */ 79*0Sstevel@tonic-gate PICL_VALUETOOBIG, /* value too big for buffer */ 80*0Sstevel@tonic-gate PICL_PROPNOTFOUND, /* property not found */ 81*0Sstevel@tonic-gate PICL_NOTTABLE, /* not a table */ 82*0Sstevel@tonic-gate PICL_NOTNODE, /* not a node */ 83*0Sstevel@tonic-gate PICL_NOTPROP, /* not a prop */ 84*0Sstevel@tonic-gate PICL_ENDOFLIST, /* end of list */ 85*0Sstevel@tonic-gate PICL_PROPEXISTS, /* prop already exists */ 86*0Sstevel@tonic-gate PICL_NOTWRITABLE, /* not writable */ 87*0Sstevel@tonic-gate PICL_PERMDENIED, /* permission denied */ 88*0Sstevel@tonic-gate PICL_INVALIDHANDLE, /* invalid handle */ 89*0Sstevel@tonic-gate PICL_STALEHANDLE, /* stale handle */ 90*0Sstevel@tonic-gate PICL_NOTSUPPORTED, /* version not supported */ 91*0Sstevel@tonic-gate PICL_TIMEDOUT, /* timed out */ 92*0Sstevel@tonic-gate PICL_CANTDESTROY, /* cannot destroy */ 93*0Sstevel@tonic-gate PICL_TREEBUSY, /* too busy to lock tree */ 94*0Sstevel@tonic-gate PICL_CANTPARENT, /* already has a parent */ 95*0Sstevel@tonic-gate PICL_RESERVEDNAME, /* property name is reserved */ 96*0Sstevel@tonic-gate PICL_INVREFERENCE, /* Invalid reference value */ 97*0Sstevel@tonic-gate PICL_WALK_CONTINUE, /* continue walking tree */ 98*0Sstevel@tonic-gate PICL_WALK_TERMINATE, /* stop walking tree */ 99*0Sstevel@tonic-gate PICL_NODENOTFOUND, /* node not found */ 100*0Sstevel@tonic-gate PICL_NOSPACE, /* not enough space available */ 101*0Sstevel@tonic-gate PICL_NOTREADABLE, /* property not readable */ 102*0Sstevel@tonic-gate PICL_PROPVALUNAVAILABLE /* property value unavailable */ 103*0Sstevel@tonic-gate } picl_errno_t; 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate /* 106*0Sstevel@tonic-gate * PICL property types 107*0Sstevel@tonic-gate */ 108*0Sstevel@tonic-gate typedef enum { 109*0Sstevel@tonic-gate PICL_PTYPE_UNKNOWN = 0x0, 110*0Sstevel@tonic-gate PICL_PTYPE_VOID, /* exists or not */ 111*0Sstevel@tonic-gate PICL_PTYPE_INT, /* scalar */ 112*0Sstevel@tonic-gate PICL_PTYPE_UNSIGNED_INT, /* scalar */ 113*0Sstevel@tonic-gate PICL_PTYPE_FLOAT, /* scalar */ 114*0Sstevel@tonic-gate PICL_PTYPE_REFERENCE, /* reference handle */ 115*0Sstevel@tonic-gate PICL_PTYPE_TABLE, /* table handle */ 116*0Sstevel@tonic-gate PICL_PTYPE_TIMESTAMP, /* time stamp */ 117*0Sstevel@tonic-gate PICL_PTYPE_BYTEARRAY, /* array of bytes */ 118*0Sstevel@tonic-gate PICL_PTYPE_CHARSTRING /* nul terminated array of chars */ 119*0Sstevel@tonic-gate } picl_prop_type_t; 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate typedef struct { 122*0Sstevel@tonic-gate picl_prop_type_t type; 123*0Sstevel@tonic-gate unsigned int accessmode; /* always == PICL_READ */ 124*0Sstevel@tonic-gate size_t size; /* item size or string size */ 125*0Sstevel@tonic-gate char name[PICL_PROPNAMELEN_MAX]; 126*0Sstevel@tonic-gate } picl_propinfo_t; 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate /* 129*0Sstevel@tonic-gate * ------------------------------------- 130*0Sstevel@tonic-gate * Function prototypes of PICL Interface 131*0Sstevel@tonic-gate * ------------------------------------- 132*0Sstevel@tonic-gate */ 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate extern int picl_initialize(void); 135*0Sstevel@tonic-gate extern int picl_shutdown(void); 136*0Sstevel@tonic-gate extern int picl_get_root(picl_nodehdl_t *nodehandle); 137*0Sstevel@tonic-gate extern int picl_get_propval(picl_prophdl_t proph, void *valbuf, 138*0Sstevel@tonic-gate size_t sz); 139*0Sstevel@tonic-gate extern int picl_get_propval_by_name(picl_nodehdl_t nodeh, 140*0Sstevel@tonic-gate const char *propname, void *valbuf, size_t sz); 141*0Sstevel@tonic-gate extern int picl_set_propval(picl_prophdl_t proph, void *valbuf, 142*0Sstevel@tonic-gate size_t sz); 143*0Sstevel@tonic-gate extern int picl_set_propval_by_name(picl_nodehdl_t nodeh, 144*0Sstevel@tonic-gate const char *propname, void *valbuf, size_t sz); 145*0Sstevel@tonic-gate extern int picl_get_propinfo(picl_prophdl_t proph, picl_propinfo_t *pi); 146*0Sstevel@tonic-gate extern int picl_get_first_prop(picl_nodehdl_t nodeh, picl_prophdl_t *proph); 147*0Sstevel@tonic-gate extern int picl_get_next_prop(picl_prophdl_t proph, picl_prophdl_t *nexth); 148*0Sstevel@tonic-gate extern int picl_get_prop_by_name(picl_nodehdl_t nodeh, const char *nm, 149*0Sstevel@tonic-gate picl_prophdl_t *ph); 150*0Sstevel@tonic-gate extern int picl_get_next_by_row(picl_prophdl_t thish, picl_prophdl_t *proph); 151*0Sstevel@tonic-gate extern int picl_get_next_by_col(picl_prophdl_t thish, picl_prophdl_t *proph); 152*0Sstevel@tonic-gate extern int picl_wait(unsigned int secs); 153*0Sstevel@tonic-gate extern char *picl_strerror(int err); 154*0Sstevel@tonic-gate extern int picl_walk_tree_by_class(picl_nodehdl_t rooth, 155*0Sstevel@tonic-gate const char *classname, void *c_args, 156*0Sstevel@tonic-gate int (*callback_fn)(picl_nodehdl_t hdl, void *args)); 157*0Sstevel@tonic-gate extern int picl_get_propinfo_by_name(picl_nodehdl_t nodeh, const char *pname, 158*0Sstevel@tonic-gate picl_propinfo_t *pinfo, picl_prophdl_t *proph); 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate extern int picl_find_node(picl_nodehdl_t rooth, char *pname, 161*0Sstevel@tonic-gate picl_prop_type_t ptype, void *pval, size_t valsize, 162*0Sstevel@tonic-gate picl_nodehdl_t *retnodeh); 163*0Sstevel@tonic-gate 164*0Sstevel@tonic-gate extern int picl_get_node_by_path(const char *piclpath, picl_nodehdl_t *nodeh); 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate extern int picl_get_frutree_parent(picl_nodehdl_t devh, picl_nodehdl_t *fruh); 167*0Sstevel@tonic-gate 168*0Sstevel@tonic-gate /* 169*0Sstevel@tonic-gate * Standard PICL names: properties and nodes 170*0Sstevel@tonic-gate */ 171*0Sstevel@tonic-gate #define PICL_NODE_ROOT "/" 172*0Sstevel@tonic-gate #define PICL_NODE_PLATFORM "platform" 173*0Sstevel@tonic-gate #define PICL_NODE_OBP "obp" 174*0Sstevel@tonic-gate #define PICL_NODE_FRUTREE "frutree" 175*0Sstevel@tonic-gate 176*0Sstevel@tonic-gate #define PICL_PROP_NAME "name" 177*0Sstevel@tonic-gate #define PICL_PROP_CLASSNAME "_class" 178*0Sstevel@tonic-gate #define PICL_PROP_PARENT "_parent" 179*0Sstevel@tonic-gate #define PICL_PROP_CHILD "_child" 180*0Sstevel@tonic-gate #define PICL_PROP_PEER "_peer" 181*0Sstevel@tonic-gate 182*0Sstevel@tonic-gate #define PICL_CLASS_PICL "picl" 183*0Sstevel@tonic-gate 184*0Sstevel@tonic-gate #ifdef __cplusplus 185*0Sstevel@tonic-gate } 186*0Sstevel@tonic-gate #endif 187*0Sstevel@tonic-gate 188*0Sstevel@tonic-gate #endif /* _PICL_H */ 189