xref: /titanic_51/usr/src/uts/common/sys/bofi.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_BOFI_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_BOFI_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * header file for bus_ops fault injector
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
37*7c478bd9Sstevel@tonic-gate extern "C" {
38*7c478bd9Sstevel@tonic-gate #endif
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate /*
43*7c478bd9Sstevel@tonic-gate  * ioctl command values
44*7c478bd9Sstevel@tonic-gate  */
45*7c478bd9Sstevel@tonic-gate #define	BOFI_ADD_DEF 0
46*7c478bd9Sstevel@tonic-gate #define	BOFI_DEL_DEF 1
47*7c478bd9Sstevel@tonic-gate #define	BOFI_START 2
48*7c478bd9Sstevel@tonic-gate #define	BOFI_STOP 3
49*7c478bd9Sstevel@tonic-gate #define	BOFI_CHK_STATE 8
50*7c478bd9Sstevel@tonic-gate #define	BOFI_CHK_STATE_W 9
51*7c478bd9Sstevel@tonic-gate #define	BOFI_BROADCAST 10
52*7c478bd9Sstevel@tonic-gate #define	BOFI_CLEAR_ACC_CHK 11
53*7c478bd9Sstevel@tonic-gate #define	BOFI_CLEAR_ERRORS 12
54*7c478bd9Sstevel@tonic-gate #define	BOFI_CLEAR_ERRDEFS 13
55*7c478bd9Sstevel@tonic-gate #define	BOFI_GET_HANDLES 16
56*7c478bd9Sstevel@tonic-gate #define	BOFI_GET_HANDLE_INFO 17
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate #define	NAMESIZE 256
59*7c478bd9Sstevel@tonic-gate #define	ERRMSGSIZE 256
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate struct  acc_log_elem {
62*7c478bd9Sstevel@tonic-gate     hrtime_t	access_time;	/* timestamp */
63*7c478bd9Sstevel@tonic-gate     uint_t	access_type;	/* the type of access */
64*7c478bd9Sstevel@tonic-gate     uint_t	_pad;		/* pad struct to multiple of 8 bytes for x86 */
65*7c478bd9Sstevel@tonic-gate     offset_t 	offset;		/* the offset into handle */
66*7c478bd9Sstevel@tonic-gate     uint64_t	value;		/* the value being read or written */
67*7c478bd9Sstevel@tonic-gate     uint32_t 	size;		/* the size (in bytes) of the transaction */
68*7c478bd9Sstevel@tonic-gate     uint32_t  	repcount;	/* repcount parameter of a ddi_repX routine */
69*7c478bd9Sstevel@tonic-gate };
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate /* Access logging flags */
72*7c478bd9Sstevel@tonic-gate #define	BOFI_LOG_REPIO	0x1	/* log ddi_repX as multiple accesses */
73*7c478bd9Sstevel@tonic-gate #define	BOFI_LOG_WRAP	0x2	/* do continuous logging of accesses */
74*7c478bd9Sstevel@tonic-gate #define	BOFI_LOG_FULL	0x4	/* lets callers know if the log has wrapped */
75*7c478bd9Sstevel@tonic-gate #define	BOFI_LOG_TIMESTAMP	0x8 /* timestamp each log entry */
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate struct  acc_log {
78*7c478bd9Sstevel@tonic-gate     uint32_t	logsize;	/* length of the logbase array */
79*7c478bd9Sstevel@tonic-gate     uint32_t	entries;	/* number of valid log elements */
80*7c478bd9Sstevel@tonic-gate     uint_t	flags;		/* access logging flags */
81*7c478bd9Sstevel@tonic-gate     uint_t	wrapcnt;	/* wrap cnt */
82*7c478bd9Sstevel@tonic-gate     hrtime_t	start_time;	/* activation time */
83*7c478bd9Sstevel@tonic-gate     hrtime_t	stop_time;	/* deactivation time (or time when full) */
84*7c478bd9Sstevel@tonic-gate     caddr_t	logbase;	/* pointer to acc_log_elem struct */
85*7c478bd9Sstevel@tonic-gate };
86*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
89*7c478bd9Sstevel@tonic-gate #pragma pack(4)
90*7c478bd9Sstevel@tonic-gate #endif
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate struct  acc_log32 {
93*7c478bd9Sstevel@tonic-gate     uint32_t	logsize;	/* length of the logbase array */
94*7c478bd9Sstevel@tonic-gate     uint32_t	entries;	/* number of valid log elements */
95*7c478bd9Sstevel@tonic-gate     uint_t	flags;		/* access logging flags */
96*7c478bd9Sstevel@tonic-gate     uint_t	wrapcnt;	/* wrap cnt */
97*7c478bd9Sstevel@tonic-gate     hrtime_t	start_time;	/* activation time */
98*7c478bd9Sstevel@tonic-gate     hrtime_t	stop_time;	/* deactivation time (or time when full) */
99*7c478bd9Sstevel@tonic-gate     caddr32_t	logbase;	/* pointer to acc_log_elem struct */
100*7c478bd9Sstevel@tonic-gate };
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
103*7c478bd9Sstevel@tonic-gate #pragma pack()
104*7c478bd9Sstevel@tonic-gate #endif
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate struct bofi_errdef {
109*7c478bd9Sstevel@tonic-gate     uint_t 	namesize;
110*7c478bd9Sstevel@tonic-gate     char 	name[NAMESIZE];		/* as returned by ddi_get_name() */
111*7c478bd9Sstevel@tonic-gate 				/* pointer to char */
112*7c478bd9Sstevel@tonic-gate     int 	instance;	/* as returned by ddi_get_instance() */
113*7c478bd9Sstevel@tonic-gate     int		rnumber;	/* as used by ddi_regs_map_setup() */
114*7c478bd9Sstevel@tonic-gate     offset_t 	offset;		/* as used by ddi_regs_map_setup() */
115*7c478bd9Sstevel@tonic-gate     offset_t 	len;		/* as used by ddi_regs_map_setup() */
116*7c478bd9Sstevel@tonic-gate     uint_t	access_type;
117*7c478bd9Sstevel@tonic-gate     uint_t	access_count;
118*7c478bd9Sstevel@tonic-gate     uint_t	fail_count;
119*7c478bd9Sstevel@tonic-gate     uint_t	acc_chk;
120*7c478bd9Sstevel@tonic-gate     uint_t	optype;
121*7c478bd9Sstevel@tonic-gate     uint64_t	operand;
122*7c478bd9Sstevel@tonic-gate     struct acc_log log;
123*7c478bd9Sstevel@tonic-gate     uint64_t 	errdef_handle;	/* pointer to void */
124*7c478bd9Sstevel@tonic-gate };
125*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
128*7c478bd9Sstevel@tonic-gate #pragma pack(4)
129*7c478bd9Sstevel@tonic-gate #endif
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate struct bofi_errdef32 {
132*7c478bd9Sstevel@tonic-gate     uint_t 	namesize;
133*7c478bd9Sstevel@tonic-gate     char 	name[NAMESIZE];		/* as returned by ddi_get_name() */
134*7c478bd9Sstevel@tonic-gate 				/* pointer to char */
135*7c478bd9Sstevel@tonic-gate     int 	instance;	/* as returned by ddi_get_instance() */
136*7c478bd9Sstevel@tonic-gate     int		rnumber;	/* as used by ddi_regs_map_setup() */
137*7c478bd9Sstevel@tonic-gate     offset_t 	offset;		/* as used by ddi_regs_map_setup() */
138*7c478bd9Sstevel@tonic-gate     offset_t 	len;		/* as used by ddi_regs_map_setup() */
139*7c478bd9Sstevel@tonic-gate     uint_t	access_type;
140*7c478bd9Sstevel@tonic-gate     uint_t	access_count;
141*7c478bd9Sstevel@tonic-gate     uint_t	fail_count;
142*7c478bd9Sstevel@tonic-gate     uint_t	acc_chk;
143*7c478bd9Sstevel@tonic-gate     uint_t	optype;
144*7c478bd9Sstevel@tonic-gate     uint64_t	operand;
145*7c478bd9Sstevel@tonic-gate     struct acc_log32 log;
146*7c478bd9Sstevel@tonic-gate     uint64_t 	errdef_handle;	/* pointer to void */
147*7c478bd9Sstevel@tonic-gate };
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
150*7c478bd9Sstevel@tonic-gate #pragma pack()
151*7c478bd9Sstevel@tonic-gate #endif
152*7c478bd9Sstevel@tonic-gate 
153*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate struct bofi_errctl {
156*7c478bd9Sstevel@tonic-gate     uint_t 	namesize;
157*7c478bd9Sstevel@tonic-gate     char 	name[NAMESIZE];		/* as returned by ddi_get_name() */
158*7c478bd9Sstevel@tonic-gate     int 	instance;	/* as returned by ddi_get_instance() */
159*7c478bd9Sstevel@tonic-gate };
160*7c478bd9Sstevel@tonic-gate 
161*7c478bd9Sstevel@tonic-gate struct bofi_get_handles {
162*7c478bd9Sstevel@tonic-gate     uint_t 	namesize;
163*7c478bd9Sstevel@tonic-gate     char 	name[NAMESIZE];		/* as returned by ddi_get_name() */
164*7c478bd9Sstevel@tonic-gate     int 	instance;	/* as returned by ddi_get_instance() */
165*7c478bd9Sstevel@tonic-gate     int 	count;
166*7c478bd9Sstevel@tonic-gate     caddr_t 	buffer;
167*7c478bd9Sstevel@tonic-gate };
168*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
169*7c478bd9Sstevel@tonic-gate struct bofi_get_handles32 {
170*7c478bd9Sstevel@tonic-gate     uint_t 	namesize;
171*7c478bd9Sstevel@tonic-gate     char 	name[NAMESIZE];		/* as returned by ddi_get_name() */
172*7c478bd9Sstevel@tonic-gate     int 	instance;	/* as returned by ddi_get_instance() */
173*7c478bd9Sstevel@tonic-gate     int 	count;
174*7c478bd9Sstevel@tonic-gate     caddr32_t 	buffer;
175*7c478bd9Sstevel@tonic-gate };
176*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
177*7c478bd9Sstevel@tonic-gate 
178*7c478bd9Sstevel@tonic-gate struct handle_info {
179*7c478bd9Sstevel@tonic-gate     int 	instance;
180*7c478bd9Sstevel@tonic-gate     uint_t 	access_type;
181*7c478bd9Sstevel@tonic-gate     int 	rnumber;
182*7c478bd9Sstevel@tonic-gate     int		_pad;		/* pad to 8 bytes for x86 */
183*7c478bd9Sstevel@tonic-gate     offset_t 	len;
184*7c478bd9Sstevel@tonic-gate     offset_t 	offset;
185*7c478bd9Sstevel@tonic-gate     uint64_t 	addr_cookie;
186*7c478bd9Sstevel@tonic-gate };
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate struct bofi_get_hdl_info {
189*7c478bd9Sstevel@tonic-gate     uint_t 	namesize;
190*7c478bd9Sstevel@tonic-gate     char 	name[NAMESIZE];		/* as returned by ddi_get_name() */
191*7c478bd9Sstevel@tonic-gate     int 	count;		/* number of handle_info structures */
192*7c478bd9Sstevel@tonic-gate     caddr_t 	hdli;		/* pointer to struct handle_info */
193*7c478bd9Sstevel@tonic-gate };
194*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
195*7c478bd9Sstevel@tonic-gate struct bofi_get_hdl_info32 {
196*7c478bd9Sstevel@tonic-gate     uint_t 	namesize;
197*7c478bd9Sstevel@tonic-gate     char 	name[NAMESIZE];		/* as returned by ddi_get_name() */
198*7c478bd9Sstevel@tonic-gate     int 	count;		/* number of handle_info structures */
199*7c478bd9Sstevel@tonic-gate     caddr32_t 	hdli;		/* pointer to struct handle_info */
200*7c478bd9Sstevel@tonic-gate };
201*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
202*7c478bd9Sstevel@tonic-gate 
203*7c478bd9Sstevel@tonic-gate /*
204*7c478bd9Sstevel@tonic-gate  * values for optype
205*7c478bd9Sstevel@tonic-gate  */
206*7c478bd9Sstevel@tonic-gate #define	BOFI_EQUAL 0
207*7c478bd9Sstevel@tonic-gate #define	BOFI_AND 1
208*7c478bd9Sstevel@tonic-gate #define	BOFI_OR 2
209*7c478bd9Sstevel@tonic-gate #define	BOFI_XOR 3
210*7c478bd9Sstevel@tonic-gate #define	BOFI_NO_TRANSFER 4
211*7c478bd9Sstevel@tonic-gate #define	BOFI_DELAY_INTR 5
212*7c478bd9Sstevel@tonic-gate #define	BOFI_LOSE_INTR 6
213*7c478bd9Sstevel@tonic-gate #define	BOFI_EXTRA_INTR 7
214*7c478bd9Sstevel@tonic-gate #define	BOFI_NOP 16
215*7c478bd9Sstevel@tonic-gate /*
216*7c478bd9Sstevel@tonic-gate  * values for access_type
217*7c478bd9Sstevel@tonic-gate  */
218*7c478bd9Sstevel@tonic-gate #define	BOFI_PIO_R 1
219*7c478bd9Sstevel@tonic-gate #define	BOFI_PIO_W 2
220*7c478bd9Sstevel@tonic-gate #define	BOFI_PIO_RW (BOFI_PIO_R|BOFI_PIO_W)
221*7c478bd9Sstevel@tonic-gate #define	BOFI_DMA_R 4
222*7c478bd9Sstevel@tonic-gate #define	BOFI_DMA_W 8
223*7c478bd9Sstevel@tonic-gate #define	BOFI_DMA_RW (BOFI_DMA_R|BOFI_DMA_W)
224*7c478bd9Sstevel@tonic-gate #define	BOFI_INTR 64
225*7c478bd9Sstevel@tonic-gate #define	BOFI_LOG 128
226*7c478bd9Sstevel@tonic-gate 
227*7c478bd9Sstevel@tonic-gate struct bofi_errstate {
228*7c478bd9Sstevel@tonic-gate     hrtime_t	fail_time;	/* time that count went to zero */
229*7c478bd9Sstevel@tonic-gate     hrtime_t	msg_time;	/* time that ddi_report_error was called */
230*7c478bd9Sstevel@tonic-gate     uint_t	access_count;
231*7c478bd9Sstevel@tonic-gate     uint_t	fail_count;
232*7c478bd9Sstevel@tonic-gate     uint_t	acc_chk;
233*7c478bd9Sstevel@tonic-gate     uint_t 	errmsg_count;
234*7c478bd9Sstevel@tonic-gate     char 	buffer[ERRMSGSIZE];
235*7c478bd9Sstevel@tonic-gate     ddi_fault_impact_t severity;
236*7c478bd9Sstevel@tonic-gate     struct acc_log log;
237*7c478bd9Sstevel@tonic-gate     uint64_t 	errdef_handle;
238*7c478bd9Sstevel@tonic-gate };
239*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
240*7c478bd9Sstevel@tonic-gate 
241*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
242*7c478bd9Sstevel@tonic-gate #pragma pack(4)
243*7c478bd9Sstevel@tonic-gate #endif
244*7c478bd9Sstevel@tonic-gate 
245*7c478bd9Sstevel@tonic-gate struct bofi_errstate32 {
246*7c478bd9Sstevel@tonic-gate     hrtime_t	fail_time;	/* time that count went to zero */
247*7c478bd9Sstevel@tonic-gate     hrtime_t	msg_time;	/* time that ddi_report_error was called */
248*7c478bd9Sstevel@tonic-gate     uint_t	access_count;
249*7c478bd9Sstevel@tonic-gate     uint_t	fail_count;
250*7c478bd9Sstevel@tonic-gate     uint_t	acc_chk;
251*7c478bd9Sstevel@tonic-gate     uint_t 	errmsg_count;
252*7c478bd9Sstevel@tonic-gate     char 	buffer[ERRMSGSIZE];
253*7c478bd9Sstevel@tonic-gate     ddi_fault_impact_t severity;
254*7c478bd9Sstevel@tonic-gate     struct acc_log32 log;
255*7c478bd9Sstevel@tonic-gate     uint64_t 	errdef_handle;
256*7c478bd9Sstevel@tonic-gate };
257*7c478bd9Sstevel@tonic-gate 
258*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
259*7c478bd9Sstevel@tonic-gate #pragma pack()
260*7c478bd9Sstevel@tonic-gate #endif
261*7c478bd9Sstevel@tonic-gate 
262*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
265*7c478bd9Sstevel@tonic-gate }
266*7c478bd9Sstevel@tonic-gate #endif
267*7c478bd9Sstevel@tonic-gate 
268*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_BOFI_H */
269