summaryrefslogtreecommitdiff
path: root/usr/src/uts/sun4u/lw8/sys/sgfru.h
blob: d9d3a2368e236223ef0b43a1d853d91eb3d1653e (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
/*
 * 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 2001 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _SGFRU_H
#define	_SGFRU_H

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

#ifdef	__cplusplus
extern "C" {
#endif

#include <sys/types.h>

/*
 * sgfru driver ioctl definitions
 */

#define	FRU_PSEUDO_DEV		"/devices/pseudo/sgfru@0:sgfru"
/* see SCAPP source file FruRegistry.java */
#define	SEG_PROTIGNCKS		(1 << 30)
#define	SEG_PROTOPAQUE		(1 << 29)
#define	SEG_PROTFIXED		(1 << 28)

#ifdef _KERNEL
#define	_SGFRU_KERNEL_OR_FRU
#endif

#ifdef _SGFRU
#define	_SGFRU_KERNEL_OR_FRU
#endif

#ifdef _SGFRU_KERNEL_OR_FRU
#define	SEG_NAME_LEN 2
#endif

/*
 * Generic typedefs and defines.
 *
 * All sgfru ioctls accept either a fru_info_t (a handle and a count),
 * a frup_info_t (which is a fru_info_t plus a pointer to a preallocated
 * data buffer), or an append_info_t (which is a packet_t plus a frup_info_t).
 *
 * The count is always the space allocated for a specific number of items,
 * aka the calloc model.
 */
typedef	int32_t		fru_cnt_t;	/* count for number of objects */
#ifdef _SGFRU_KERNEL_OR_FRU
typedef uint64_t	fru_hdl_t;	/* SC_handle, opaque handle for SCAPP */

typedef fru_hdl_t	container_hdl_t; /* container handle */
typedef fru_hdl_t	section_hdl_t;	/* section handle */
typedef fru_hdl_t	segment_hdl_t;	/* segment handle */
typedef fru_hdl_t	packet_hdl_t;	/* packet handle */

typedef struct {
	section_hdl_t	handle;		/* for use in operations on section */
	uint32_t	offset;		/* bytes from container beginning */
	uint32_t	length;		/*  length of section in bytes */
	uint32_t	protected;	/* non-zero if write-protected */
	int32_t		version;	/* version of section header, or -1 */
} section_t;

typedef struct {
	segment_hdl_t	handle;		/* for use in operations on segment */
	char		name[SEG_NAME_LEN]; /* from container section header */
	uint32_t	descriptor;	/* ditto */
	uint32_t	offset;		/* ditto */
	uint32_t	length;		/* ditto */
} segment_t;

typedef uint64_t  tag_t;

typedef struct {
	packet_hdl_t	handle;		/* for use in operations on packet */
	tag_t		tag;		/* packet tag */
} packet_t;
#endif

typedef struct {
	fru_hdl_t	hdl;		/* generic fru handle */
	fru_cnt_t	cnt;		/* generic fru count */
} fru_info_t;

typedef	fru_info_t	section_info_t;	/* section handle and count */
typedef	fru_info_t	segment_info_t;	/* segment handle and count */
typedef	fru_info_t	packet_info_t;	/* packet handle and count */

typedef struct {
	fru_info_t	fru_info;	/* handle and count */
	void		*frus;		/* pointer to opaque buffer */
} frup_info_t;

#define	fru_hdl		fru_info.hdl
#define	fru_cnt		fru_info.cnt

typedef	frup_info_t	sections_t;	/* section handle, count, pointer */
typedef	frup_info_t	segments_t;	/* segment handle, count, pointer */
typedef	frup_info_t	packets_t;	/* packet handle, count, pointer */
typedef	frup_info_t	payload_t;	/* payload handle, count, pointer */

typedef struct {
	packet_t	packet;		/* packet info */
	payload_t	payload;	/* handle, count, pointer to buffer */
} append_info_t;

#define	payload_hdl	payload.fru_hdl
#define	payload_cnt	payload.fru_cnt
#define	payload_data	payload.frus

#if defined(_SYSCALL32)

typedef struct {
	fru_info_t	fru_info;	/* handle and count */
	caddr32_t	frus;		/* 32 bit pointer to opaque buffer */
} frup32_info_t;

typedef struct {
	packet_t	packet;		/* packet info */
	frup32_info_t	payload;	/* handle, count, 32 bit pointer */
} append32_info_t;

#endif	/* _SYSCALL32 */

/*
 * Request: section_info_t, with container handle
 * Receive: section_info_t, with current section count
 */
#define	SGFRU_GETNUMSECTIONS		0x0001

/*
 * Request: sections_t, with container handle, max count, preallocated buffer
 * Receive: sections_t, with section_t array and actual count
 */
#define	SGFRU_GETSECTIONS		0x0002

/*
 * Request: segment_info_t, with section handle
 * Receive: segment_info_t, with current segment count
 */
#define	SGFRU_GETNUMSEGMENTS		0x0003

/*
 * Request: segments_t, with section handle, max count, preallocated buffer
 * Receive: segments_t, with segment_t array and actual count
 */
#define	SGFRU_GETSEGMENTS		0x0004

/*
 * Request: segments_t, with section handle and segment_t
 * Receive: updated segments_t with section handle and new segment handle
 */
#define	SGFRU_ADDSEGMENT		0x0005

/*
 * Request: segment_info_t, with segment handle
 * Receive: segment_info_t, with updated section handle
 */
#define	SGFRU_DELETESEGMENT		0x0006

/*
 * Request: segments_t, with segment handle, max count, preallocated buffer
 * Receive: segments_t, with segment raw data and actual count
 */
#define	SGFRU_READRAWSEGMENT		0x0007

/*
 * Request: segments_t, with segment handle, max count, data buffer
 * Receive: segments_t, with segment data and actual count
 */
#define	SGFRU_WRITERAWSEGMENT		0x0008

/*
 * Request: packet_info_t, with segment handle
 * Receive: packet_info_t, with current packet count
 */
#define	SGFRU_GETNUMPACKETS		0x0009

/*
 * Request: packet_info_t, with segment handle, max count, preallocated buffer
 * Receive: packet_info_t, with packet array and actual count
 */
#define	SGFRU_GETPACKETS		0x000a

/*
 * Request: append_info_t, with packet_t, segment handle, count and data
 * Receive: updated append_info_t with segment handle and new packet handle
 */
#define	SGFRU_APPENDPACKET		0x000b

/*
 * Request: packet_info_t, with packet handle
 * Receive: packet_info_t, with updated segment handle
 */
#define	SGFRU_DELETEPACKET		0x000c

/*
 * Request: payload_t, with packet handle, max count, and payload data buffer
 * Receive: payload_t, with payload data and actual count
 */
#define	SGFRU_GETPAYLOAD		0x000d

/*
 * Request: payload_t, with packet handle, max count, and payload data buffer
 * Receive: payload_t, with new packet handle and actual count
 */
#define	SGFRU_UPDATEPAYLOAD		0x000e

#ifdef	__cplusplus
}
#endif

#endif	/* _SGFRU_H */