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