xref: /titanic_51/usr/src/uts/sun4u/lw8/sys/sgfru_mbox.h (revision ccbf80fa3b6bf6b986dca9037e5ad9d6c9f9fa65)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SGFRU_MBOX_H
28 #define	_SGFRU_MBOX_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/sgfru_priv.h>
37 #include <sys/conf.h>
38 #include <sys/ddi_impldefs.h>
39 
40 /*
41  * Max time sgfru waits for mailbox to respond before
42  * it decides to timeout. (measured in seconds)
43  */
44 #define	SGFRU_DEFAULT_MAX_MBOX_WAIT_TIME	86400
45 
46 /*
47  *  FRU Mailbox Definitions
48  *
49  *	Request (from Solaris to SC):
50  *		msg_len = CONTAINER_HDL_SIZE
51  *  		msg_buf = pointer to unpadded container_hdl_t
52  *  	Response (from SC to Solaris):
53  *		msg_len = FRU_CNT_SIZE
54  *  		msg_buf = pointer to unpadded fru_cnt_t
55  *  		msg_status = return value, see below.
56  *  Error Notes:
57  */
58 #define	SGFRU_MBOX_GETNUMSECTIONS		0x7001
59 /*
60  *	Request (from Solaris to SC):
61  *		msg_len = FRU_INFO_SIZE
62  *  		msg_buf = pointer to unpadded fru_info_t containing:
63  *		    parent container_hdl_t and max fru_cnt_t (in #sections)
64  *  	Response (from SC to Solaris):
65  *		msg_len = FRU_INFO_SIZE + (SECTION_SIZE * max fru_cnt_t)
66  *              msg_buf = caddr_t of msg_len, contains:
67  *		    unpadded container_hdl_t and actual fru_cnt_t
68  *		    unpadded section_t array
69  *  		msg_status = return value, see below.
70  *  Error Notes:
71  *  Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough.
72  */
73 #define	SGFRU_MBOX_GETSECTIONS			0x7002
74 /*
75  *	Request (from Solaris to SC):
76  *		msg_len = SECTION_HDL_SIZE
77  *  		msg_buf = pointer to unpadded section_hdl_t
78  *  	Response (from SC to Solaris):
79  *		msg_len = FRU_CNT_SIZE
80  *  		msg_buf = pointer to unpadded fru_cnt_t
81  *  		msg_status = return value, see below.
82  *  Error Notes:
83  */
84 #define	SGFRU_MBOX_GETNUMSEGMENTS		0x7003
85 /*
86  * FRU  Mailbox definitions
87  *
88  *	Request (from Solaris to SC):
89  *		msg_len = FRU_INFO_SIZE
90  *  		msg_buf = pointer to unpadded fru_info_t containing:
91  *		    parent section_hdl_t and max fru_cnt_t (in #segments)
92  *  	Response (from SC to Solaris):
93  *		msg_len = FRU_INFO_SIZE + (SEGMENT_SIZE * max fru_cnt_t)
94  *              msg_buf = caddr_t of msg_len, contains:
95  *		    unpadded parent section_hdl_t and actual fru_cnt_t
96  *		    unpadded segment_t array
97  *  		msg_status = return value, see below.
98  *  Error Notes:
99  *  Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough.
100  */
101 #define	SGFRU_MBOX_GETSEGMENTS			0x7004
102 /*
103  *	Request (from Solaris to SC):
104  *		msg_len = SECTION_HDL_SIZE + SEGMENT_SIZE
105  *  		msg_buf = caddr_t of msg_len, contains:
106  *		    unpadded parent section_hdl_t
107  *		    unpadded segment_t
108  *  	Response (from SC to Solaris):
109  *  		msg_len = SEGMENT_HDL_SIZE
110  *              msg_buf = pointer to:
111  *		    segment_hdl_t of newly created segment
112  *		    updated parent section_hdl_t
113  *  		msg_status = return value, see below.
114  *  Error Notes:
115  *  Please return SG_MBOX_STATUS_STALE_OBJECT if the section_hdl_t is stale.
116  *  Please return SG_MBOX_STATUS_NO_SEPROM_SPACE if the seprom is out of space
117  */
118 #define	SGFRU_MBOX_ADDSEGMENT			0x7005
119 /*
120  *	Request (from Solaris to SC):
121  *		msg_len = SEGMENT_HDL_SIZE
122  *  		msg_buf = pointer to segment_hdl_t of segment to be deleted
123  *  	Response (from SC to Solaris):
124  *		msg_len = SECTION_HDL_SIZE
125  *  		msg_buf = pointer to updated section_hdl_t of deleted segment
126  *  		msg_status = return value, see below
127  *  Error Notes:
128  */
129 #define	SGFRU_MBOX_DELETESEGMENT		0x7006
130 /*
131  *	Request (from Solaris to SC):
132  *		msg_len = FRU_INFO_SIZE
133  *  		msg_buf = caddr_t of msg_len, contains:
134  *		    unpadded fru_info_t: segment_hdl_t and max count in bytes
135  *  	Response (from SC to Solaris):
136  *		msg_len = FRU_INFO_SIZE
137  *              msg_buf = caddr_t of msg_len, contains:
138  *		    unpadded fru_info_t: segment_hdl_t and actual count in bytes
139  *		    unpadded data of actual fru_cnt_t bytes
140  *  		msg_status = return value, see below.
141  *  Error Notes:
142  *  Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough.
143  */
144 #define	SGFRU_MBOX_READRAWSEGMENT		0x7007
145 /*
146  *	Request (from Solaris to SC):
147  *		msg_len = FRU_INFO_SIZE + fru_cnt_t bytes
148  *  		msg_buf = caddr_t of msg_len, contains:
149  *		    unpadded fru_info_t: segment_hdl_t and count in bytes
150  *		    unpadded data of fru_cnt_t bytes
151  *  	Response (from SC to Solaris):
152  *		msg_len = FRU_INFO_SIZE
153  *              msg_buf = caddr_t of msg_len, contains:
154  *		    unpadded fru_info_t: segment_hdl_t and count in bytes
155  *  		msg_status = return value, see below.
156  *  Error Notes:
157  *  Please return SG_MBOX_STATUS_ILLEGAL_PARAMETER if it's
158  *  	not an opaque segment.
159  */
160 #define	SGFRU_MBOX_WRITERAWSEGMENT		0x7008
161 /*
162  *	Request (from Solaris to SC):
163  *		msg_len = SEGMENT_HDL_SIZE
164  *  		msg_buf = pointer to unpadded segment_hdl_t
165  *  	Response (from SC to Solaris):
166  *		msg_len = FRU_CNT_SIZE
167  *  		msg_buf = pointer to unpadded fru_cnt_t
168  *  		msg_status = return value, see below.
169  *  Error Notes:
170  */
171 #define	SGFRU_MBOX_GETNUMPACKETS		0x7009
172 /*
173  *	Request (from Solaris to SC):
174  *		msg_len = FRU_INFO_SIZE
175  *  		msg_buf = pointer to unpadded fru_info_t, containing:
176  *		    unpadded segment_hdl_t plus max fru_cnt_t in bytes
177  *  	Response (from SC to Solaris):
178  *		msg_len = FRU_INFO_SIZE + (PACKET_SIZE * max fru_cnt_t)
179  *              msg_buf = caddr_t of msg_len, contains:
180  *		    unpadded parent segment_hdl_t and actual fru_cnt_t
181  *		    unpadded packet_t array
182  *  		msg_status = return value, see below.
183  *  Error Notes:
184  *  Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough.
185  */
186 #define	SGFRU_MBOX_GETPACKETS			0x700a
187 /*
188  *	Request (from Solaris to SC):
189  *		msg_len = FRU_INFO_SIZE + PACKET_SIZE + fru_cnt_t size
190  *  		msg_buf = caddr_t of msg_len, contains:
191  *		    unpadded fru_info_t with parent segment_hdl_t and fru_cnt_t
192  *		    unpadded packet_t
193  *		    unpadded data of size fru_cnt_t (in bytes)
194  *  	Response (from SC to Solaris):
195  *  		msg_len = SEGMENT_HDL_SIZE + PACKET_HDL_SIZE
196  *              msg_buf = pointer to:
197  *		    packet_hdl_t of newly created packet
198  *		    updated parent segment_hdl_t
199  *  		msg_status = return value, see below.
200  *  Error Notes:
201  *  Please return SG_MBOX_STATUS_NO_SEPROM_SPACE if the seprom is out of space
202  */
203 #define	SGFRU_MBOX_APPENDPACKET			0x700b
204 /*
205  *	Request (from Solaris to SC):
206  *		msg_len = PACKET_HDL_SIZE
207  *  		msg_buf = pointer to packet_hdl_t of packet to be deleted
208  *  	Response (from SC to Solaris):
209  *		msg_len = SEGMENT_HDL_SIZE
210  *  		msg_buf = pointer to updated segment_hdl_t of deleted packet
211  *  		msg_status = return value, see below
212  *  Error Notes:
213  */
214 #define	SGFRU_MBOX_DELETEPACKET			0x700c
215 /*
216  *	Request (from Solaris to SC):
217  *		msg_len = FRU_INFO_SIZE
218  *              msg_buf = caddr_t of msg_len, contains:
219  *		    unpadded fru_info_t with packet_hdl_t and max fru_cnt_t
220  *  	Response (from SC to Solaris):
221  *		msg_len = FRU_INFO_SIZE + max fru_cnt_t
222  *              msg_buf = caddr_t of msg_len, contains:
223  *		    unpadded fru_info_t with packet_hdl_t and actual fru_cnt_t
224  *		    unpadded data of size fru_cnt_t (in bytes)
225  *  		msg_status = return value, see below.
226  *  Error Notes:
227  *  Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough.
228  */
229 #define	SGFRU_MBOX_GETPAYLOAD			0x700d
230 /*
231  *	Request (from Solaris to SC):
232  *		msg_len = FRU_INFO_SIZE + fru_cnt_t size
233  *              msg_buf = caddr_t of msg_len, contains:
234  *		    unpadded fru_info_t with packet_hdl_t and actual count
235  *		    unpadded payload data buf of fru_cnt_t size (in bytes)
236  *  	Response (from SC to Solaris):
237  *		msg_len = FRU_INFO_SIZE
238  *  		msg_buf = caddr_t of msg_len, contains:
239  *		    unpadded fru_hdl_t with updated handle
240  *		    unpadded data of size fru_cnt_t (in bytes)
241  *  		msg_status = return value, see below.
242  *  Error Notes:
243  *  Please return SG_MBOX_STATUS_NO_SEPROM_SPACE if the seprom is out of space
244  */
245 #define	SGFRU_MBOX_UPDATEPAYLOAD		0x700e
246 /*
247  *  FRU Mailbox Definitions
248  *
249  *      Request (from Solaris to SC):
250  *              msg_len = FRU_INFO_SIZE
251  *              msg_buf = pointer to unpadded fru_info_t containing:
252  *                  parent fru_hdl_t and max fru_cnt_t (in node_t's)
253  *      Response (from SC to Solaris):
254  *              msg_len = NODE_SIZE * max fru_cnt_t (in node_t's)
255  *              msg_buf = caddr_t of msg_len, contains:
256  *                  unpadded fru_hdl_t and actual fru_cnt_t
257  *                  unpadded node_t array
258  *              msg_status = return value, see below.
259  *  Error Notes:
260  */
261 #define	SGFRU_MBOX_GETCHILDLIST			0x700f
262 /*
263  *  FRU Mailbox Definitions
264  *
265  *      Request (from Solaris to SC):
266  *              msg_len = FRU_INFO_SIZE
267  *              msg_buf = pointer to unpadded fru_info_t containing:
268  *                  parent fru_hdl_t and max fru_cnt_t (in fru_hdl_t's)
269  *      Response (from SC to Solaris):
270  *              msg_len = FRU_HDL_SIZE * max fru_cnt_t (in fru_hdl_t's)
271  *              msg_buf = caddr_t of msg_len, contains:
272  *                  unpadded fru_hdl_t and actual fru_cnt_t
273  *                  unpadded fru_hdl_t array
274  *              msg_status = return value, see below.
275  *  Error Notes:
276  */
277 #define	SGFRU_MBOX_GETCHILDHANDLES		0x7010
278 /*
279  *      Request (from Solaris to SC):
280  *              msg_len = FRU_INFO_SIZE
281  *              msg_buf = pointer to unpadded fru_hdl_t
282  *      Response (from SC to Solaris):
283  *              msg_len = NODE_SIZE
284  *              msg_buf = caddr_t of msg_len, contains:
285  *                  unpadded node_t
286  *              msg_status = return value, see below.
287  *  Error Notes:
288  */
289 #define	SGFRU_MBOX_GETNODEINFO			0x7020
290 
291 
292 /*
293  * The defines below are used for translating padded (C) to non-padded (Java),
294  * and must directly correspond to the structures defined in fru_data_access.h
295  * and sgfru.h.
296  */
297 #define	FRU_HDL_SIZE		sizeof (fru_hdl_t)
298 #define	CONTAINER_HDL_SIZE	FRU_HDL_SIZE
299 #define	SECTION_HDL_SIZE	FRU_HDL_SIZE
300 #define	SEGMENT_HDL_SIZE	FRU_HDL_SIZE
301 #define	PACKET_HDL_SIZE		FRU_HDL_SIZE
302 #define	FRU_CNT_SIZE		sizeof (fru_cnt_t)
303 #define	NAME_SIZE		sizeof (char[SEG_NAME_LEN])
304 #define	OFFSET_SIZE		sizeof (uint32_t)
305 #define	LENGTH_SIZE		sizeof (uint32_t)
306 #define	PROTECTED_SIZE		sizeof (uint32_t)
307 #define	VERSION_SIZE		sizeof (uint32_t)
308 #define	DESCRIPTOR_SIZE		sizeof (uint32_t)
309 #define	TAG_SIZE		sizeof (tag_t)
310 #define	NODENAME_SIZE		sizeof (char[MAX_NODE_NAME])
311 #define	HASCHILDREN_SIZE	sizeof (uint16_t)
312 #define	CLASS_SIZE		sizeof (uint16_t)
313 #define	CLASS_INFO_SIZE		sizeof (union class_info)
314 #define	SLOT_SIZE		sizeof (uint16_t)
315 #define	LABEL_SIZE		sizeof (char[MAX_NODE_NAME])
316 
317 #define	FRU_INFO_SIZE		(FRU_HDL_SIZE + FRU_CNT_SIZE)
318 #define	SECTION_SIZE		(SECTION_HDL_SIZE + OFFSET_SIZE +\
319 				    LENGTH_SIZE + PROTECTED_SIZE + VERSION_SIZE)
320 #define	SEGMENT_SIZE		(SEGMENT_HDL_SIZE + NAME_SIZE +\
321 				    DESCRIPTOR_SIZE + OFFSET_SIZE + LENGTH_SIZE)
322 #define	PACKET_SIZE		(PACKET_HDL_SIZE + TAG_SIZE)
323 #define	NODE_SIZE		(FRU_HDL_SIZE + NODENAME_SIZE +\
324 				    HASCHILDREN_SIZE + CLASS_SIZE +\
325 				    CLASS_INFO_SIZE)
326 
327 static int sgfru_mbox(const int cmd, char *datap, const size_t size,
328     fru_info_t *fru);
329 
330 static caddr_t sgfru_fru_pad(const caddr_t datap, fru_info_t *fru);
331 static int sgfru_node_pad(const caddr_t datap, const int max_cnt,
332     fru_info_t *fru, node_t *nodep);
333 static int sgfru_section_pad(const caddr_t datap, const int max_cnt,
334     fru_info_t *fru, section_t *sectp);
335 static int sgfru_segment_pad(const caddr_t datap, const int max_cnt,
336     fru_info_t *fru, segment_t *segp);
337 static int sgfru_packet_pad(const caddr_t datap, const int max_cnt,
338     fru_info_t *fru, packet_t *packp);
339 
340 static caddr_t sgfru_fru_unpad(const fru_info_t *fru, caddr_t datap);
341 static void sgfru_segment_unpad(const fru_info_t *fru, const segment_t *segp,
342     caddr_t datap);
343 static caddr_t sgfru_packet_unpad(const fru_info_t *fru, const packet_t *packp,
344     caddr_t datap);
345 
346 #ifdef	__cplusplus
347 }
348 #endif
349 
350 #endif	/* _SGFRU_MBOX_H */
351