summaryrefslogtreecommitdiff
path: root/usr/src/uts/sun4u/lw8/sys/sgfru_mbox.h
blob: 5dd60a72f8619414fbf645e10fe9114b9204898f (plain)
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (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 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _SGFRU_MBOX_H
#define	_SGFRU_MBOX_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#ifdef	__cplusplus
extern "C" {
#endif

#include <sys/sgfru_priv.h>
#include <sys/conf.h>
#include <sys/ddi_impldefs.h>

/*
 * Max time sgfru waits for mailbox to respond before
 * it decides to timeout. (measured in seconds)
 */
#define	SGFRU_DEFAULT_MAX_MBOX_WAIT_TIME	86400

/*
 *  FRU Mailbox Definitions
 *
 *	Request (from Solaris to SC):
 *		msg_len = CONTAINER_HDL_SIZE
 *  		msg_buf = pointer to unpadded container_hdl_t
 *  	Response (from SC to Solaris):
 *		msg_len = FRU_CNT_SIZE
 *  		msg_buf = pointer to unpadded fru_cnt_t
 *  		msg_status = return value, see below.
 *  Error Notes:
 */
#define	SGFRU_MBOX_GETNUMSECTIONS		0x7001
/*
 *	Request (from Solaris to SC):
 *		msg_len = FRU_INFO_SIZE
 *  		msg_buf = pointer to unpadded fru_info_t containing:
 *		    parent container_hdl_t and max fru_cnt_t (in #sections)
 *  	Response (from SC to Solaris):
 *		msg_len = FRU_INFO_SIZE + (SECTION_SIZE * max fru_cnt_t)
 *              msg_buf = caddr_t of msg_len, contains:
 *		    unpadded container_hdl_t and actual fru_cnt_t
 *		    unpadded section_t array
 *  		msg_status = return value, see below.
 *  Error Notes:
 *  Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough.
 */
#define	SGFRU_MBOX_GETSECTIONS			0x7002
/*
 *	Request (from Solaris to SC):
 *		msg_len = SECTION_HDL_SIZE
 *  		msg_buf = pointer to unpadded section_hdl_t
 *  	Response (from SC to Solaris):
 *		msg_len = FRU_CNT_SIZE
 *  		msg_buf = pointer to unpadded fru_cnt_t
 *  		msg_status = return value, see below.
 *  Error Notes:
 */
#define	SGFRU_MBOX_GETNUMSEGMENTS		0x7003
/*
 * FRU  Mailbox definitions
 *
 *	Request (from Solaris to SC):
 *		msg_len = FRU_INFO_SIZE
 *  		msg_buf = pointer to unpadded fru_info_t containing:
 *		    parent section_hdl_t and max fru_cnt_t (in #segments)
 *  	Response (from SC to Solaris):
 *		msg_len = FRU_INFO_SIZE + (SEGMENT_SIZE * max fru_cnt_t)
 *              msg_buf = caddr_t of msg_len, contains:
 *		    unpadded parent section_hdl_t and actual fru_cnt_t
 *		    unpadded segment_t array
 *  		msg_status = return value, see below.
 *  Error Notes:
 *  Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough.
 */
#define	SGFRU_MBOX_GETSEGMENTS			0x7004
/*
 *	Request (from Solaris to SC):
 *		msg_len = SECTION_HDL_SIZE + SEGMENT_SIZE
 *  		msg_buf = caddr_t of msg_len, contains:
 *		    unpadded parent section_hdl_t
 *		    unpadded segment_t
 *  	Response (from SC to Solaris):
 *  		msg_len = SEGMENT_HDL_SIZE
 *              msg_buf = pointer to:
 *		    segment_hdl_t of newly created segment
 *		    updated parent section_hdl_t
 *  		msg_status = return value, see below.
 *  Error Notes:
 *  Please return SG_MBOX_STATUS_STALE_OBJECT if the section_hdl_t is stale.
 *  Please return SG_MBOX_STATUS_NO_SEPROM_SPACE if the seprom is out of space
 */
#define	SGFRU_MBOX_ADDSEGMENT			0x7005
/*
 *	Request (from Solaris to SC):
 *		msg_len = SEGMENT_HDL_SIZE
 *  		msg_buf = pointer to segment_hdl_t of segment to be deleted
 *  	Response (from SC to Solaris):
 *		msg_len = SECTION_HDL_SIZE
 *  		msg_buf = pointer to updated section_hdl_t of deleted segment
 *  		msg_status = return value, see below
 *  Error Notes:
 */
#define	SGFRU_MBOX_DELETESEGMENT		0x7006
/*
 *	Request (from Solaris to SC):
 *		msg_len = FRU_INFO_SIZE
 *  		msg_buf = caddr_t of msg_len, contains:
 *		    unpadded fru_info_t: segment_hdl_t and max count in bytes
 *  	Response (from SC to Solaris):
 *		msg_len = FRU_INFO_SIZE
 *              msg_buf = caddr_t of msg_len, contains:
 *		    unpadded fru_info_t: segment_hdl_t and actual count in bytes
 *		    unpadded data of actual fru_cnt_t bytes
 *  		msg_status = return value, see below.
 *  Error Notes:
 *  Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough.
 */
#define	SGFRU_MBOX_READRAWSEGMENT		0x7007
/*
 *	Request (from Solaris to SC):
 *		msg_len = FRU_INFO_SIZE + fru_cnt_t bytes
 *  		msg_buf = caddr_t of msg_len, contains:
 *		    unpadded fru_info_t: segment_hdl_t and count in bytes
 *		    unpadded data of fru_cnt_t bytes
 *  	Response (from SC to Solaris):
 *		msg_len = FRU_INFO_SIZE
 *              msg_buf = caddr_t of msg_len, contains:
 *		    unpadded fru_info_t: segment_hdl_t and count in bytes
 *  		msg_status = return value, see below.
 *  Error Notes:
 *  Please return SG_MBOX_STATUS_ILLEGAL_PARAMETER if it's
 *  	not an opaque segment.
 */
#define	SGFRU_MBOX_WRITERAWSEGMENT		0x7008
/*
 *	Request (from Solaris to SC):
 *		msg_len = SEGMENT_HDL_SIZE
 *  		msg_buf = pointer to unpadded segment_hdl_t
 *  	Response (from SC to Solaris):
 *		msg_len = FRU_CNT_SIZE
 *  		msg_buf = pointer to unpadded fru_cnt_t
 *  		msg_status = return value, see below.
 *  Error Notes:
 */
#define	SGFRU_MBOX_GETNUMPACKETS		0x7009
/*
 *	Request (from Solaris to SC):
 *		msg_len = FRU_INFO_SIZE
 *  		msg_buf = pointer to unpadded fru_info_t, containing:
 *		    unpadded segment_hdl_t plus max fru_cnt_t in bytes
 *  	Response (from SC to Solaris):
 *		msg_len = FRU_INFO_SIZE + (PACKET_SIZE * max fru_cnt_t)
 *              msg_buf = caddr_t of msg_len, contains:
 *		    unpadded parent segment_hdl_t and actual fru_cnt_t
 *		    unpadded packet_t array
 *  		msg_status = return value, see below.
 *  Error Notes:
 *  Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough.
 */
#define	SGFRU_MBOX_GETPACKETS			0x700a
/*
 *	Request (from Solaris to SC):
 *		msg_len = FRU_INFO_SIZE + PACKET_SIZE + fru_cnt_t size
 *  		msg_buf = caddr_t of msg_len, contains:
 *		    unpadded fru_info_t with parent segment_hdl_t and fru_cnt_t
 *		    unpadded packet_t
 *		    unpadded data of size fru_cnt_t (in bytes)
 *  	Response (from SC to Solaris):
 *  		msg_len = SEGMENT_HDL_SIZE + PACKET_HDL_SIZE
 *              msg_buf = pointer to:
 *		    packet_hdl_t of newly created packet
 *		    updated parent segment_hdl_t
 *  		msg_status = return value, see below.
 *  Error Notes:
 *  Please return SG_MBOX_STATUS_NO_SEPROM_SPACE if the seprom is out of space
 */
#define	SGFRU_MBOX_APPENDPACKET			0x700b
/*
 *	Request (from Solaris to SC):
 *		msg_len = PACKET_HDL_SIZE
 *  		msg_buf = pointer to packet_hdl_t of packet to be deleted
 *  	Response (from SC to Solaris):
 *		msg_len = SEGMENT_HDL_SIZE
 *  		msg_buf = pointer to updated segment_hdl_t of deleted packet
 *  		msg_status = return value, see below
 *  Error Notes:
 */
#define	SGFRU_MBOX_DELETEPACKET			0x700c
/*
 *	Request (from Solaris to SC):
 *		msg_len = FRU_INFO_SIZE
 *              msg_buf = caddr_t of msg_len, contains:
 *		    unpadded fru_info_t with packet_hdl_t and max fru_cnt_t
 *  	Response (from SC to Solaris):
 *		msg_len = FRU_INFO_SIZE + max fru_cnt_t
 *              msg_buf = caddr_t of msg_len, contains:
 *		    unpadded fru_info_t with packet_hdl_t and actual fru_cnt_t
 *		    unpadded data of size fru_cnt_t (in bytes)
 *  		msg_status = return value, see below.
 *  Error Notes:
 *  Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough.
 */
#define	SGFRU_MBOX_GETPAYLOAD			0x700d
/*
 *	Request (from Solaris to SC):
 *		msg_len = FRU_INFO_SIZE + fru_cnt_t size
 *              msg_buf = caddr_t of msg_len, contains:
 *		    unpadded fru_info_t with packet_hdl_t and actual count
 *		    unpadded payload data buf of fru_cnt_t size (in bytes)
 *  	Response (from SC to Solaris):
 *		msg_len = FRU_INFO_SIZE
 *  		msg_buf = caddr_t of msg_len, contains:
 *		    unpadded fru_hdl_t with updated handle
 *		    unpadded data of size fru_cnt_t (in bytes)
 *  		msg_status = return value, see below.
 *  Error Notes:
 *  Please return SG_MBOX_STATUS_NO_SEPROM_SPACE if the seprom is out of space
 */
#define	SGFRU_MBOX_UPDATEPAYLOAD		0x700e
/*
 *  FRU Mailbox Definitions
 *
 *      Request (from Solaris to SC):
 *              msg_len = FRU_INFO_SIZE
 *              msg_buf = pointer to unpadded fru_info_t containing:
 *                  parent fru_hdl_t and max fru_cnt_t (in node_t's)
 *      Response (from SC to Solaris):
 *              msg_len = NODE_SIZE * max fru_cnt_t (in node_t's)
 *              msg_buf = caddr_t of msg_len, contains:
 *                  unpadded fru_hdl_t and actual fru_cnt_t
 *                  unpadded node_t array
 *              msg_status = return value, see below.
 *  Error Notes:
 */
#define	SGFRU_MBOX_GETCHILDLIST			0x700f
/*
 *  FRU Mailbox Definitions
 *
 *      Request (from Solaris to SC):
 *              msg_len = FRU_INFO_SIZE
 *              msg_buf = pointer to unpadded fru_info_t containing:
 *                  parent fru_hdl_t and max fru_cnt_t (in fru_hdl_t's)
 *      Response (from SC to Solaris):
 *              msg_len = FRU_HDL_SIZE * max fru_cnt_t (in fru_hdl_t's)
 *              msg_buf = caddr_t of msg_len, contains:
 *                  unpadded fru_hdl_t and actual fru_cnt_t
 *                  unpadded fru_hdl_t array
 *              msg_status = return value, see below.
 *  Error Notes:
 */
#define	SGFRU_MBOX_GETCHILDHANDLES		0x7010
/*
 *      Request (from Solaris to SC):
 *              msg_len = FRU_INFO_SIZE
 *              msg_buf = pointer to unpadded fru_hdl_t
 *      Response (from SC to Solaris):
 *              msg_len = NODE_SIZE
 *              msg_buf = caddr_t of msg_len, contains:
 *                  unpadded node_t
 *              msg_status = return value, see below.
 *  Error Notes:
 */
#define	SGFRU_MBOX_GETNODEINFO			0x7020


/*
 * The defines below are used for translating padded (C) to non-padded (Java),
 * and must directly correspond to the structures defined in fru_data_access.h
 * and sgfru.h.
 */
#define	FRU_HDL_SIZE		sizeof (fru_hdl_t)
#define	CONTAINER_HDL_SIZE	FRU_HDL_SIZE
#define	SECTION_HDL_SIZE	FRU_HDL_SIZE
#define	SEGMENT_HDL_SIZE	FRU_HDL_SIZE
#define	PACKET_HDL_SIZE		FRU_HDL_SIZE
#define	FRU_CNT_SIZE		sizeof (fru_cnt_t)
#define	NAME_SIZE		sizeof (char[SEG_NAME_LEN])
#define	OFFSET_SIZE		sizeof (uint32_t)
#define	LENGTH_SIZE		sizeof (uint32_t)
#define	PROTECTED_SIZE		sizeof (uint32_t)
#define	VERSION_SIZE		sizeof (uint32_t)
#define	DESCRIPTOR_SIZE		sizeof (uint32_t)
#define	TAG_SIZE		sizeof (tag_t)
#define	NODENAME_SIZE		sizeof (char[MAX_NODE_NAME])
#define	HASCHILDREN_SIZE	sizeof (uint16_t)
#define	CLASS_SIZE		sizeof (uint16_t)
#define	CLASS_INFO_SIZE		sizeof (union class_info)
#define	SLOT_SIZE		sizeof (uint16_t)
#define	LABEL_SIZE		sizeof (char[MAX_NODE_NAME])

#define	FRU_INFO_SIZE		(FRU_HDL_SIZE + FRU_CNT_SIZE)
#define	SECTION_SIZE		(SECTION_HDL_SIZE + OFFSET_SIZE +\
				    LENGTH_SIZE + PROTECTED_SIZE + VERSION_SIZE)
#define	SEGMENT_SIZE		(SEGMENT_HDL_SIZE + NAME_SIZE +\
				    DESCRIPTOR_SIZE + OFFSET_SIZE + LENGTH_SIZE)
#define	PACKET_SIZE		(PACKET_HDL_SIZE + TAG_SIZE)
#define	NODE_SIZE		(FRU_HDL_SIZE + NODENAME_SIZE +\
				    HASCHILDREN_SIZE + CLASS_SIZE +\
				    CLASS_INFO_SIZE)

static int sgfru_mbox(const int cmd, char *datap, const size_t size,
    fru_info_t *fru);

static caddr_t sgfru_fru_pad(const caddr_t datap, fru_info_t *fru);
static int sgfru_node_pad(const caddr_t datap, const int max_cnt,
    fru_info_t *fru, node_t *nodep);
static int sgfru_section_pad(const caddr_t datap, const int max_cnt,
    fru_info_t *fru, section_t *sectp);
static int sgfru_segment_pad(const caddr_t datap, const int max_cnt,
    fru_info_t *fru, segment_t *segp);
static int sgfru_packet_pad(const caddr_t datap, const int max_cnt,
    fru_info_t *fru, packet_t *packp);

static caddr_t sgfru_fru_unpad(const fru_info_t *fru, caddr_t datap);
static void sgfru_segment_unpad(const fru_info_t *fru, const segment_t *segp,
    caddr_t datap);
static caddr_t sgfru_packet_unpad(const fru_info_t *fru, const packet_t *packp,
    caddr_t datap);

#ifdef	__cplusplus
}
#endif

#endif	/* _SGFRU_MBOX_H */