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