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