xref: /titanic_50/usr/src/uts/sun4u/lw8/sys/sgfru.h (revision 67e3a03ed4a2813074d36330f062ed6e593a4937)
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 2001 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SGFRU_H
28 #define	_SGFRU_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/types.h>
37 
38 /*
39  * sgfru driver ioctl definitions
40  */
41 
42 #define	FRU_PSEUDO_DEV		"/devices/pseudo/sgfru@0:sgfru"
43 /* see SCAPP source file FruRegistry.java */
44 #define	SEG_PROTIGNCKS		(1 << 30)
45 #define	SEG_PROTOPAQUE		(1 << 29)
46 #define	SEG_PROTFIXED		(1 << 28)
47 
48 #ifdef _KERNEL
49 #define	_SGFRU_KERNEL_OR_FRU
50 #endif
51 
52 #ifdef _SGFRU
53 #define	_SGFRU_KERNEL_OR_FRU
54 #endif
55 
56 #ifdef _SGFRU_KERNEL_OR_FRU
57 #define	SEG_NAME_LEN 2
58 #endif
59 
60 /*
61  * Generic typedefs and defines.
62  *
63  * All sgfru ioctls accept either a fru_info_t (a handle and a count),
64  * a frup_info_t (which is a fru_info_t plus a pointer to a preallocated
65  * data buffer), or an append_info_t (which is a packet_t plus a frup_info_t).
66  *
67  * The count is always the space allocated for a specific number of items,
68  * aka the calloc model.
69  */
70 typedef	int32_t		fru_cnt_t;	/* count for number of objects */
71 #ifdef _SGFRU_KERNEL_OR_FRU
72 typedef uint64_t	fru_hdl_t;	/* SC_handle, opaque handle for SCAPP */
73 
74 typedef fru_hdl_t	container_hdl_t; /* container handle */
75 typedef fru_hdl_t	section_hdl_t;	/* section handle */
76 typedef fru_hdl_t	segment_hdl_t;	/* segment handle */
77 typedef fru_hdl_t	packet_hdl_t;	/* packet handle */
78 
79 typedef struct {
80 	section_hdl_t	handle;		/* for use in operations on section */
81 	uint32_t	offset;		/* bytes from container beginning */
82 	uint32_t	length;		/*  length of section in bytes */
83 	uint32_t	protected;	/* non-zero if write-protected */
84 	int32_t		version;	/* version of section header, or -1 */
85 } section_t;
86 
87 typedef struct {
88 	segment_hdl_t	handle;		/* for use in operations on segment */
89 	char		name[SEG_NAME_LEN]; /* from container section header */
90 	uint32_t	descriptor;	/* ditto */
91 	uint32_t	offset;		/* ditto */
92 	uint32_t	length;		/* ditto */
93 } segment_t;
94 
95 typedef uint64_t  tag_t;
96 
97 typedef struct {
98 	packet_hdl_t	handle;		/* for use in operations on packet */
99 	tag_t		tag;		/* packet tag */
100 } packet_t;
101 #endif
102 
103 typedef struct {
104 	fru_hdl_t	hdl;		/* generic fru handle */
105 	fru_cnt_t	cnt;		/* generic fru count */
106 } fru_info_t;
107 
108 typedef	fru_info_t	section_info_t;	/* section handle and count */
109 typedef	fru_info_t	segment_info_t;	/* segment handle and count */
110 typedef	fru_info_t	packet_info_t;	/* packet handle and count */
111 
112 typedef struct {
113 	fru_info_t	fru_info;	/* handle and count */
114 	void		*frus;		/* pointer to opaque buffer */
115 } frup_info_t;
116 
117 #define	fru_hdl		fru_info.hdl
118 #define	fru_cnt		fru_info.cnt
119 
120 typedef	frup_info_t	sections_t;	/* section handle, count, pointer */
121 typedef	frup_info_t	segments_t;	/* segment handle, count, pointer */
122 typedef	frup_info_t	packets_t;	/* packet handle, count, pointer */
123 typedef	frup_info_t	payload_t;	/* payload handle, count, pointer */
124 
125 typedef struct {
126 	packet_t	packet;		/* packet info */
127 	payload_t	payload;	/* handle, count, pointer to buffer */
128 } append_info_t;
129 
130 #define	payload_hdl	payload.fru_hdl
131 #define	payload_cnt	payload.fru_cnt
132 #define	payload_data	payload.frus
133 
134 #if defined(_SYSCALL32)
135 
136 typedef struct {
137 	fru_info_t	fru_info;	/* handle and count */
138 	caddr32_t	frus;		/* 32 bit pointer to opaque buffer */
139 } frup32_info_t;
140 
141 typedef struct {
142 	packet_t	packet;		/* packet info */
143 	frup32_info_t	payload;	/* handle, count, 32 bit pointer */
144 } append32_info_t;
145 
146 #endif	/* _SYSCALL32 */
147 
148 /*
149  * Request: section_info_t, with container handle
150  * Receive: section_info_t, with current section count
151  */
152 #define	SGFRU_GETNUMSECTIONS		0x0001
153 
154 /*
155  * Request: sections_t, with container handle, max count, preallocated buffer
156  * Receive: sections_t, with section_t array and actual count
157  */
158 #define	SGFRU_GETSECTIONS		0x0002
159 
160 /*
161  * Request: segment_info_t, with section handle
162  * Receive: segment_info_t, with current segment count
163  */
164 #define	SGFRU_GETNUMSEGMENTS		0x0003
165 
166 /*
167  * Request: segments_t, with section handle, max count, preallocated buffer
168  * Receive: segments_t, with segment_t array and actual count
169  */
170 #define	SGFRU_GETSEGMENTS		0x0004
171 
172 /*
173  * Request: segments_t, with section handle and segment_t
174  * Receive: updated segments_t with section handle and new segment handle
175  */
176 #define	SGFRU_ADDSEGMENT		0x0005
177 
178 /*
179  * Request: segment_info_t, with segment handle
180  * Receive: segment_info_t, with updated section handle
181  */
182 #define	SGFRU_DELETESEGMENT		0x0006
183 
184 /*
185  * Request: segments_t, with segment handle, max count, preallocated buffer
186  * Receive: segments_t, with segment raw data and actual count
187  */
188 #define	SGFRU_READRAWSEGMENT		0x0007
189 
190 /*
191  * Request: segments_t, with segment handle, max count, data buffer
192  * Receive: segments_t, with segment data and actual count
193  */
194 #define	SGFRU_WRITERAWSEGMENT		0x0008
195 
196 /*
197  * Request: packet_info_t, with segment handle
198  * Receive: packet_info_t, with current packet count
199  */
200 #define	SGFRU_GETNUMPACKETS		0x0009
201 
202 /*
203  * Request: packet_info_t, with segment handle, max count, preallocated buffer
204  * Receive: packet_info_t, with packet array and actual count
205  */
206 #define	SGFRU_GETPACKETS		0x000a
207 
208 /*
209  * Request: append_info_t, with packet_t, segment handle, count and data
210  * Receive: updated append_info_t with segment handle and new packet handle
211  */
212 #define	SGFRU_APPENDPACKET		0x000b
213 
214 /*
215  * Request: packet_info_t, with packet handle
216  * Receive: packet_info_t, with updated segment handle
217  */
218 #define	SGFRU_DELETEPACKET		0x000c
219 
220 /*
221  * Request: payload_t, with packet handle, max count, and payload data buffer
222  * Receive: payload_t, with payload data and actual count
223  */
224 #define	SGFRU_GETPAYLOAD		0x000d
225 
226 /*
227  * Request: payload_t, with packet handle, max count, and payload data buffer
228  * Receive: payload_t, with new packet handle and actual count
229  */
230 #define	SGFRU_UPDATEPAYLOAD		0x000e
231 
232 #ifdef	__cplusplus
233 }
234 #endif
235 
236 #endif	/* _SGFRU_H */
237