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