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