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