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 _CFGA_SBD_H 28*7c478bd9Sstevel@tonic-gate #define _CFGA_SBD_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 #define DEVDIR "/devices" 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #ifdef SBD_DEBUG 39*7c478bd9Sstevel@tonic-gate #define DBG dbg 40*7c478bd9Sstevel@tonic-gate void dbg(char *, ...); 41*7c478bd9Sstevel@tonic-gate #else 42*7c478bd9Sstevel@tonic-gate #define DBG 43*7c478bd9Sstevel@tonic-gate #endif 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate typedef struct { 46*7c478bd9Sstevel@tonic-gate int flags; 47*7c478bd9Sstevel@tonic-gate int code; 48*7c478bd9Sstevel@tonic-gate char *mid; 49*7c478bd9Sstevel@tonic-gate char *platform; 50*7c478bd9Sstevel@tonic-gate int skip; 51*7c478bd9Sstevel@tonic-gate int err; 52*7c478bd9Sstevel@tonic-gate } ap_opts_t; 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate /* 55*7c478bd9Sstevel@tonic-gate * Command options. 56*7c478bd9Sstevel@tonic-gate * 57*7c478bd9Sstevel@tonic-gate * Some of the options are provided for testing purpose and 58*7c478bd9Sstevel@tonic-gate * will not published (e.g. err,code,mid). 59*7c478bd9Sstevel@tonic-gate */ 60*7c478bd9Sstevel@tonic-gate #define OPT_UNASSIGN 0 61*7c478bd9Sstevel@tonic-gate #define OPT_SKIP 1 62*7c478bd9Sstevel@tonic-gate #define OPT_PARSABLE 2 63*7c478bd9Sstevel@tonic-gate #define OPT_NOPOWEROFF 3 64*7c478bd9Sstevel@tonic-gate #define OPT_CODE 4 65*7c478bd9Sstevel@tonic-gate #define OPT_MID 5 66*7c478bd9Sstevel@tonic-gate #define OPT_ERR 6 67*7c478bd9Sstevel@tonic-gate #define OPT_PLATFORM 7 68*7c478bd9Sstevel@tonic-gate #define OPT_SIM 8 69*7c478bd9Sstevel@tonic-gate #define OPT_SUSPEND_OK 9 70*7c478bd9Sstevel@tonic-gate #define OPT_LIST_ALL 29 71*7c478bd9Sstevel@tonic-gate #define OPT_FORCE 30 72*7c478bd9Sstevel@tonic-gate #define OPT_VERBOSE 31 73*7c478bd9Sstevel@tonic-gate 74*7c478bd9Sstevel@tonic-gate #define ap_getopt(a, o) ((a)->opts.flags & ((uint_t)1 << (o))) 75*7c478bd9Sstevel@tonic-gate #define ap_setopt(a, o) ((a)->opts.flags |= ((uint_t)1 << (o))) 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate typedef enum { 78*7c478bd9Sstevel@tonic-gate AP_NONE = 0, 79*7c478bd9Sstevel@tonic-gate AP_BOARD, 80*7c478bd9Sstevel@tonic-gate AP_CPU, 81*7c478bd9Sstevel@tonic-gate AP_MEM, 82*7c478bd9Sstevel@tonic-gate AP_IO, 83*7c478bd9Sstevel@tonic-gate AP_CMP 84*7c478bd9Sstevel@tonic-gate } ap_target_t; 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate #define AP_NCLASS 6 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate /* 89*7c478bd9Sstevel@tonic-gate * Attachment point descriptor. 90*7c478bd9Sstevel@tonic-gate * 91*7c478bd9Sstevel@tonic-gate * All commands are processed as follows: 92*7c478bd9Sstevel@tonic-gate * 93*7c478bd9Sstevel@tonic-gate * . allocate a command descriptor 94*7c478bd9Sstevel@tonic-gate * . parse the physical ap_id 95*7c478bd9Sstevel@tonic-gate * . parse the command and its options. 96*7c478bd9Sstevel@tonic-gate * . sequence if necessary (state change commands) 97*7c478bd9Sstevel@tonic-gate * . execute 98*7c478bd9Sstevel@tonic-gate * 99*7c478bd9Sstevel@tonic-gate */ 100*7c478bd9Sstevel@tonic-gate typedef struct { 101*7c478bd9Sstevel@tonic-gate int fd; 102*7c478bd9Sstevel@tonic-gate int bnum; 103*7c478bd9Sstevel@tonic-gate int cnum; 104*7c478bd9Sstevel@tonic-gate int ncm; 105*7c478bd9Sstevel@tonic-gate int inst; 106*7c478bd9Sstevel@tonic-gate int norcm; 107*7c478bd9Sstevel@tonic-gate int statonly; 108*7c478bd9Sstevel@tonic-gate const char *class; 109*7c478bd9Sstevel@tonic-gate const char *apid; 110*7c478bd9Sstevel@tonic-gate char *drv; 111*7c478bd9Sstevel@tonic-gate char *path; 112*7c478bd9Sstevel@tonic-gate char *target; 113*7c478bd9Sstevel@tonic-gate char *minor; 114*7c478bd9Sstevel@tonic-gate char *cid; 115*7c478bd9Sstevel@tonic-gate char *cname; 116*7c478bd9Sstevel@tonic-gate char *options; 117*7c478bd9Sstevel@tonic-gate char **errstring; 118*7c478bd9Sstevel@tonic-gate ap_opts_t opts; 119*7c478bd9Sstevel@tonic-gate ap_target_t tgt; 120*7c478bd9Sstevel@tonic-gate struct cfga_msg *msgp; 121*7c478bd9Sstevel@tonic-gate struct cfga_confirm *confp; 122*7c478bd9Sstevel@tonic-gate void *ctl; 123*7c478bd9Sstevel@tonic-gate void *stat; 124*7c478bd9Sstevel@tonic-gate void *cmstat; 125*7c478bd9Sstevel@tonic-gate void *rcm; 126*7c478bd9Sstevel@tonic-gate } apd_t; 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate /* 129*7c478bd9Sstevel@tonic-gate * Command definitions. 130*7c478bd9Sstevel@tonic-gate * 131*7c478bd9Sstevel@tonic-gate * The command order is significant. The sequenced (-c) commands 132*7c478bd9Sstevel@tonic-gate * are sorted in execution order. The configure command starts from 133*7c478bd9Sstevel@tonic-gate * assign and ends with online. The disconnect command starts 134*7c478bd9Sstevel@tonic-gate * from offline and goes to unassign. Steps in the sequencing may 135*7c478bd9Sstevel@tonic-gate * be optionally skipped. 136*7c478bd9Sstevel@tonic-gate */ 137*7c478bd9Sstevel@tonic-gate #define CMD_ASSIGN 0 138*7c478bd9Sstevel@tonic-gate #define CMD_POWERON 1 139*7c478bd9Sstevel@tonic-gate #define CMD_TEST 2 140*7c478bd9Sstevel@tonic-gate #define CMD_CONNECT 3 141*7c478bd9Sstevel@tonic-gate #define CMD_CONFIGURE 4 142*7c478bd9Sstevel@tonic-gate #define CMD_RCM_ONLINE 5 143*7c478bd9Sstevel@tonic-gate #define CMD_RCM_CAP_ADD 6 144*7c478bd9Sstevel@tonic-gate #define CMD_SUSPEND_CHECK 7 145*7c478bd9Sstevel@tonic-gate #define CMD_RCM_SUSPEND 8 146*7c478bd9Sstevel@tonic-gate #define CMD_RCM_CAP_DEL 9 147*7c478bd9Sstevel@tonic-gate #define CMD_RCM_OFFLINE 10 148*7c478bd9Sstevel@tonic-gate #define CMD_UNCONFIGURE 11 149*7c478bd9Sstevel@tonic-gate #define CMD_RCM_REMOVE 12 150*7c478bd9Sstevel@tonic-gate #define CMD_RCM_CAP_NOTIFY 13 151*7c478bd9Sstevel@tonic-gate #define CMD_DISCONNECT 14 152*7c478bd9Sstevel@tonic-gate #define CMD_POWEROFF 15 153*7c478bd9Sstevel@tonic-gate #define CMD_UNASSIGN 16 154*7c478bd9Sstevel@tonic-gate #define CMD_RCM_RESUME 17 155*7c478bd9Sstevel@tonic-gate #define CMD_STATUS 18 156*7c478bd9Sstevel@tonic-gate #define CMD_GETNCM 19 157*7c478bd9Sstevel@tonic-gate #define CMD_PASSTHRU 20 158*7c478bd9Sstevel@tonic-gate #define CMD_HELP 21 159*7c478bd9Sstevel@tonic-gate #define CMD_ERRTEST 22 160*7c478bd9Sstevel@tonic-gate #define CMD_NONE 23 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate /* 163*7c478bd9Sstevel@tonic-gate * Error messages. 164*7c478bd9Sstevel@tonic-gate */ 165*7c478bd9Sstevel@tonic-gate #define ERR_CMD_INVAL 0 166*7c478bd9Sstevel@tonic-gate #define ERR_CMD_FAIL 1 167*7c478bd9Sstevel@tonic-gate #define ERR_CMD_NACK 2 168*7c478bd9Sstevel@tonic-gate #define ERR_CMD_NOTSUPP 3 169*7c478bd9Sstevel@tonic-gate #define ERR_CMD_ABORT 4 170*7c478bd9Sstevel@tonic-gate #define ERR_OPT_INVAL 5 171*7c478bd9Sstevel@tonic-gate #define ERR_OPT_NOVAL 6 172*7c478bd9Sstevel@tonic-gate #define ERR_OPT_VAL 7 173*7c478bd9Sstevel@tonic-gate #define ERR_OPT_BADVAL 8 174*7c478bd9Sstevel@tonic-gate #define ERR_AP_INVAL 9 175*7c478bd9Sstevel@tonic-gate #define ERR_CM_INVAL 10 176*7c478bd9Sstevel@tonic-gate #define ERR_TRANS_INVAL 11 177*7c478bd9Sstevel@tonic-gate #define ERR_SIG_CHANGE 12 178*7c478bd9Sstevel@tonic-gate #define ERR_RCM_HANDLE 13 179*7c478bd9Sstevel@tonic-gate #define ERR_RCM_CMD 14 180*7c478bd9Sstevel@tonic-gate #define ERR_RCM_INFO 15 181*7c478bd9Sstevel@tonic-gate #define ERR_LIB_OPEN 16 182*7c478bd9Sstevel@tonic-gate #define ERR_LIB_SYM 17 183*7c478bd9Sstevel@tonic-gate #define ERR_STAT 18 184*7c478bd9Sstevel@tonic-gate #define ERR_NOMEM 19 185*7c478bd9Sstevel@tonic-gate #define ERR_PLUGIN 20 186*7c478bd9Sstevel@tonic-gate #define ERR_NONE 21 187*7c478bd9Sstevel@tonic-gate 188*7c478bd9Sstevel@tonic-gate #define MSG_ISSUE 0 189*7c478bd9Sstevel@tonic-gate #define MSG_SKIP 1 190*7c478bd9Sstevel@tonic-gate #define MSG_SUSPEND 2 191*7c478bd9Sstevel@tonic-gate #define MSG_ABORT 3 192*7c478bd9Sstevel@tonic-gate #define MSG_DONE 4 193*7c478bd9Sstevel@tonic-gate #define MSG_FAIL 5 194*7c478bd9Sstevel@tonic-gate #define MSG_NORCM 6 195*7c478bd9Sstevel@tonic-gate #define MSG_NONE 7 196*7c478bd9Sstevel@tonic-gate 197*7c478bd9Sstevel@tonic-gate #define s_free(x) (((x) != NULL) ? (free(x), (x) = NULL) : (void *)0) 198*7c478bd9Sstevel@tonic-gate #define str_valid(p) ((p) != NULL && *(p) != '\0') 199*7c478bd9Sstevel@tonic-gate #define mask(x) ((uint_t)1 << (x)) 200*7c478bd9Sstevel@tonic-gate 201*7c478bd9Sstevel@tonic-gate #define CM_DFLT -1 /* default (current) component */ 202*7c478bd9Sstevel@tonic-gate 203*7c478bd9Sstevel@tonic-gate int ap_cnt(apd_t *); 204*7c478bd9Sstevel@tonic-gate int ap_parse(apd_t *, const char *); 205*7c478bd9Sstevel@tonic-gate int ap_confirm(apd_t *); 206*7c478bd9Sstevel@tonic-gate int ap_state_cmd(cfga_cmd_t, int *); 207*7c478bd9Sstevel@tonic-gate int ap_symid(apd_t *, char *, char *, size_t); 208*7c478bd9Sstevel@tonic-gate char *ap_sys_err(apd_t *, char **); 209*7c478bd9Sstevel@tonic-gate char *ap_cmd_name(int); 210*7c478bd9Sstevel@tonic-gate char *ap_opt_name(int); 211*7c478bd9Sstevel@tonic-gate char *ap_logid(apd_t *, char *); 212*7c478bd9Sstevel@tonic-gate void ap_err(apd_t *, ...); 213*7c478bd9Sstevel@tonic-gate void ap_msg(apd_t *, ...); 214*7c478bd9Sstevel@tonic-gate void ap_info(apd_t *, cfga_info_t, ap_target_t); 215*7c478bd9Sstevel@tonic-gate void ap_init(apd_t *, cfga_list_data_t *); 216*7c478bd9Sstevel@tonic-gate void ap_state(apd_t *, cfga_stat_t *, cfga_stat_t *); 217*7c478bd9Sstevel@tonic-gate cfga_err_t ap_stat(apd_t *a, int); 218*7c478bd9Sstevel@tonic-gate cfga_err_t ap_ioctl(apd_t *, int); 219*7c478bd9Sstevel@tonic-gate cfga_err_t ap_help(struct cfga_msg *, const char *, cfga_flags_t); 220*7c478bd9Sstevel@tonic-gate cfga_err_t ap_cmd_exec(apd_t *, int); 221*7c478bd9Sstevel@tonic-gate cfga_err_t ap_cmd_seq(apd_t *, int); 222*7c478bd9Sstevel@tonic-gate cfga_err_t ap_suspend_query(apd_t *, int, int *); 223*7c478bd9Sstevel@tonic-gate cfga_err_t ap_platopts_check(apd_t *, int, int); 224*7c478bd9Sstevel@tonic-gate cfga_err_t ap_cmd_parse(apd_t *, const char *, const char *, int *); 225*7c478bd9Sstevel@tonic-gate cfga_err_t ap_test_err(apd_t *, const char *); 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate int ap_cm_capacity(apd_t *, int, void *, int *, cfga_stat_t *); 228*7c478bd9Sstevel@tonic-gate int ap_cm_ncap(apd_t *, int); 229*7c478bd9Sstevel@tonic-gate void ap_cm_id(apd_t *, int, char *, size_t); 230*7c478bd9Sstevel@tonic-gate void ap_cm_init(apd_t *, cfga_list_data_t *, int); 231*7c478bd9Sstevel@tonic-gate char *ap_cm_devpath(apd_t *, int); 232*7c478bd9Sstevel@tonic-gate ap_target_t ap_cm_type(apd_t *, int); 233*7c478bd9Sstevel@tonic-gate 234*7c478bd9Sstevel@tonic-gate cfga_err_t ap_rcm_init(apd_t *); 235*7c478bd9Sstevel@tonic-gate void ap_rcm_fini(apd_t *); 236*7c478bd9Sstevel@tonic-gate cfga_err_t ap_rcm_ctl(apd_t *, int); 237*7c478bd9Sstevel@tonic-gate int ap_rcm_info(apd_t *, char **); 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate apd_t *apd_alloc(const char *, cfga_flags_t, char **, 240*7c478bd9Sstevel@tonic-gate struct cfga_msg *, struct cfga_confirm *); 241*7c478bd9Sstevel@tonic-gate void apd_free(apd_t *a); 242*7c478bd9Sstevel@tonic-gate cfga_err_t apd_init(apd_t *, int); 243*7c478bd9Sstevel@tonic-gate 244*7c478bd9Sstevel@tonic-gate int debugging(); 245*7c478bd9Sstevel@tonic-gate 246*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 247*7c478bd9Sstevel@tonic-gate } 248*7c478bd9Sstevel@tonic-gate #endif 249*7c478bd9Sstevel@tonic-gate 250*7c478bd9Sstevel@tonic-gate #endif /* _CFGA_SBD_H */ 251