xref: /freebsd/sys/dev/ida/idareg.h (revision 1e413cf93298b5b97441a21d9a50fdcd0ee9945e)
1 /*-
2  * Copyright (c) 1999,2000 Jonathan Lemon
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 
29 /*
30  * #defines and software structures for the Compaq RAID card
31  */
32 
33 /*
34  * defines for older EISA controllers (IDA, IDA-2, IAES, SMART)
35  */
36 #define	R_EISA_INT_MASK			0x01
37 #define	R_EISA_LOCAL_MASK		0x04
38 #define	R_EISA_LOCAL_DOORBELL		0x05
39 #define	R_EISA_SYSTEM_MASK		0x06
40 #define	R_EISA_SYSTEM_DOORBELL		0x07
41 #define	R_EISA_LIST_ADDR		0x08
42 #define	R_EISA_LIST_LEN			0x0c
43 #define	R_EISA_TAG			0x0f
44 #define	R_EISA_COMPLETE_ADDR		0x10
45 #define	R_EISA_LIST_STATUS		0x16
46 
47 #define	EISA_CHANNEL_BUSY		0x01
48 #define	EISA_CHANNEL_CLEAR		0x02
49 
50 /*
51  * board register offsets for SMART-2 controllers
52  */
53 #define	R_CMD_FIFO	0x04
54 #define	R_DONE_FIFO	0x08
55 #define	R_INT_MASK	0x0C
56 #define	R_STATUS	0x10
57 #define	R_INT_PENDING	0x14
58 
59 /*
60  * interrupt mask values for SMART series
61  */
62 #define	INT_DISABLE	0x00
63 #define	INT_ENABLE	0x01
64 
65 /*
66  * board offsets for the 42xx series
67  */
68 #define	R_42XX_STATUS	0x30
69 #define	R_42XX_INT_MASK	0x34
70 #define	R_42XX_REQUEST	0x40
71 #define	R_42XX_REPLY	0x44
72 
73 /*
74  * interrupt values for 42xx series
75  */
76 #define	INT_ENABLE_42XX			0x00
77 #define	INT_DISABLE_42XX		0x08
78 #define	STATUS_42XX_INT_PENDING		0x08
79 
80 /*
81  * return status codes
82  */
83 #define	SOFT_ERROR	0x02	/* Non-fatal error. */
84 #define	HARD_ERROR	0x04	/* Fatal error. */
85 #define	INVALID_ERROR	0x10	/* Invalid Request Block. */
86 #define	CMD_REJECTED	0x14
87 
88 /*
89  * command types
90  */
91 #define	CMD_GET_LOG_DRV_INFO	0x10	/* Identify controller */
92 #define	CMD_GET_CTRL_INFO	0x11	/* Identify logical driver */
93 #define	CMD_SENSE_DRV_STATUS	0x12	/* Sense logical drive status */
94 #define	CMD_START_RECOVERY	0x13	/* Start recover */
95 #define	CMD_GET_PHYS_DRV_INFO	0x15	/* Identify physical drive */
96 #define	CMD_BLINK_DRV_LEDS	0x16	/* Blink drive tray LEDs */
97 #define	CMD_SENSE_DRV_LEDS	0x17	/* Sense Blinking drive tray LEDs */
98 #define	CMD_GET_LOG_DRV_EXT	0x18	/* Identify logical drive, Extended */
99 #define	CMD_READ		0x20	/* Read */
100 #define	CMD_WRITE		0x30	/* Write */
101 #define	CMD_WRITE_MEDIA		0x31	/* Write media */
102 #define	CMD_RESET_CTRL		0x40	/* Reset controller */
103 #define	CMD_DIAG_PASS_THRU	0x41	/* ??? */
104 #define	CMD_GET_CONFIG		0x50	/* Sense configuration */
105 #define	CMD_SET_CONFIG		0x51	/* Set configuration */
106 
107 #define	CMD_BYPASS_VOL_STATE	0x52	/* ??? */
108 #define	CMD_SS_CREATE_VOL	0x53	/* ??? */
109 #define	CMD_CHANGE_CONFIG	0x54	/* ??? */
110 #define	CMD_SENSE_ORIG_CONF	0x55	/* ??? */
111 #define	CMD_REORDER_LOG_DRV	0x56	/* ??? */
112 
113 #define	CMD_LABEL_LOG_DRV	0x57	/* Label logical drive */
114 #define	CMD_SS_TO_VOL		0x58	/* ??? */
115 #define	CMD_SET_SURFACE_DELAY	0x60	/* Set surface delay */
116 #define	CMD_SET_OVERHEAT_DELAY	0x61	/* ??? */
117 #define	CMD_SENSE_BUS_PARAMS	0x65	/* Sense bus parameters */
118 #define	CMD_SENSE_SUBSYS_INFO	0x66	/* Sense Subsystem Information */
119 #define	CMD_SENSE_SURFACE_ATS	0x70	/* Sense surface analysis task status */
120 #define	CMD_PASSTHROUGH		0x90	/* Pass-through operation */
121 #define	CMD_PASSTHROUGH_A	0x91	/* ??? */
122 #define	CMD_RESET_SCSI_DEV	0x94	/* Reset SCSI device */
123 #define	CMD_PAUSE_BG_ACT	0x98	/* Pause Background Activity */
124 #define	CMD_RESUME_BG_ACT	0x99	/* Resume Background Activity */
125 #define	CMD_START_FIRMWARE	0x99	/* for integrated RAID */
126 #define	CMD_SENSE_DRV_ERR_LOG	0xa6	/* Sense drive error log */
127 #define	CMD_START_CPM		0xa7	/* Start controller performance monitoring */
128 #define	CMD_SENSE_CP		0xa8	/* Sense controller performance */
129 #define	CMD_STOP_CPM		0xa9	/* Stop controller performance monitoring */
130 #define	CMD_FLUSH_CACHE		0xc2	/* Flush/disable write cache */
131 #define	CMD_COLLECT_BUFFER	0xd2	/* ??? */
132 #define	CMD_ACCEPT_MEDIA_EXCH	0xe0	/* Accept Media Exchange */
133 
134 #define	CMD_FLASH_READ		0xf6	/* Read FLASH */
135 #define	CMD_FLASH_WRITE		0xf7	/* Write FLASH */
136 
137 /* logical drive parameter table */
138 struct ida_drive_param {
139 	u_int16_t	ncylinders;
140 	u_int8_t	nheads;
141 	u_int8_t	signature;
142 	u_int8_t	psectors;
143 	u_int16_t	wprecomp;
144 	u_int8_t	max_acc;
145 	u_int8_t	control;
146 	u_int16_t	pcylinders;
147 	u_int8_t	ptracks;
148 	u_int16_t	landing_zone;
149 	u_int8_t	nsectors;
150 	u_int8_t	checksum;
151 } __packed;
152 
153 #define	IDA_RAID0	0	/* No fault tolerance. */
154 #define	IDA_RAID4	1	/* Data Guard */
155 #define	IDA_RAID1	2	/* Mirroring */
156 #define	IDA_RAID5	3	/* Distributed Data Guard */
157 
158 /*
159  * CMD_GET_LOG_DRV_INFO (0x10)
160  * Identify Logical Drive
161  */
162 struct ida_drive_info {
163 	u_int16_t	secsize;	/* block size in bytes */
164 	u_int32_t	secperunit;	/* blocks available */
165 	struct ida_drive_param	dp;	/* logical drive parameter table */
166 	u_int8_t	mirror;		/* fault tolerance */
167 	u_int8_t	reserved;
168 	u_int8_t	bios_disable;
169 } __packed;
170 
171 /*
172  * CMD_GET_LOG_DRV_EXT (0x18)
173  * Identify Logical Drive, Extended
174  */
175 struct ida_drive_info_ext {
176 	u_int16_t	secsize;	/* block size in bytes */
177 	u_int32_t	secperunit;	/* blocks available */
178 	struct ida_drive_param	dp;	/* logical drive parameter table */
179 	u_int8_t	mirror;		/* fault tolerance */
180 	u_int8_t	reserved;
181 	u_int8_t	bios_disable;
182 	u_int32_t	ld_id;		/* Logical drive identifier */
183 	u_int8_t	ld_label[64];	/* Logical drive label */
184 } __packed;
185 
186 /*
187  * CMD_GET_CTRL_INFO (0x11)
188  * Identify Controller
189  */
190 struct ida_controller_info {
191 	u_int8_t	num_drvs;	/* Number of configured logical drives */
192 	u_int32_t	signature;	/* Configuration signature */
193 	u_int8_t	firm_rev[4];	/* ASCII firmware revision */
194 	u_int8_t	rom_rev[4];	/* ROM firmware revision */
195 	u_int8_t	hw_rev;		/* Revision level of the hardware */
196 	u_int32_t	bb_rev;
197 	u_int32_t	dp_map;		/* Drive present bit map */
198 	u_int32_t	ed_map;		/* External drive bit map */
199 	u_int32_t	board_id;
200 	u_int8_t	cfg_error;
201 	u_int32_t	nd_map;		/* Non-disk map */
202 	u_int8_t	bad_ram_addr;
203 	u_int8_t	cpu_rev;
204 	u_int8_t	pdpi_rev;
205 	u_int8_t	epic_rev;
206 	u_int8_t	wcxc_rev;
207 	u_int8_t	mkt_rev;	/* Marketing revision */
208 	u_int8_t	cflag;		/* Controller flags */
209 #define	IDA_CI_CFLAG_7DPB	(1<<3)
210 #define	IDA_CI_CFLAG_BIGMAP	(1<<7)
211 	u_int8_t	hflag;
212 	u_int8_t	expand_dis;
213 	u_int8_t	scsi_cc;	/* SCSI chip count */
214 	u_int32_t	max_req_blocks;
215 	u_int32_t	cclock;		/* Controller Clock */
216 	u_int8_t	dp_scsi;	/* Drives per SCSI bus */
217 	u_int16_t	big_dp_map[8];	/* Big drive present bit map */
218 	u_int16_t	big_ed_map[8];	/* Big external drive bit map */
219 	u_int16_t	big_nd_map[8];	/* Big non-disk map */
220 	u_int16_t	task_flags;
221 	u_int8_t	icl_bus;
222 	u_int8_t	red_modes;
223 	u_int8_t	cur_red_mode;
224 	u_int8_t	red_ctlr_stat;
225 	u_int8_t	red_fail_reason;
226 	u_int8_t	reserved[403];
227 } __packed;
228 
229 /*
230  * CMD_SENSE_DRV_STATUS (0x12)
231  * Sense logical drive status
232  */
233 struct ida_drive_status {
234 	u_int8_t	status;
235 	u_int32_t	failure_map;
236 	u_int16_t	read_err[32];
237 	u_int16_t	write_error[32];
238 	u_int8_t	reserved0[288];
239 	u_int32_t	secrecover;
240 	u_int8_t	rebuilding;
241 	u_int16_t	remap_cnt[32];
242 	u_int32_t	repl_map;
243 	u_int32_t	spare_map;
244 	u_int8_t	spare_status;
245 	u_int8_t	spare_repl_map[32];
246 	u_int32_t	repl_ok_map;
247 	u_int8_t	media_exchange;
248 	u_int8_t	cache_failure;
249 	u_int8_t	expand_failure;
250 	u_int8_t	unit_flags;
251 	u_int16_t	big_failure_map[8];
252 	u_int16_t	big_remap_cnt[128];
253 	u_int16_t	big_repl_map[8];
254 	u_int16_t	big_act_spare_map[8];
255 	u_int8_t	big_spare_repl_map[128];
256 	u_int16_t	big_repl_ok_map[8];
257 	u_int8_t	big_rebuilding;
258 	u_int8_t	reserved1[36];
259 } __packed;
260 
261 /*
262  * CMD_GET_PHYS_DRV_INFO (0x15)
263  * Identify Physical Drive
264  */
265 struct ida_phys_drv_info {
266 	u_int8_t	scsi_bus;	/* SCSI Bus */
267 	u_int8_t	scsi_id;	/* SCSI ID */
268 	u_int16_t	blksize;	/* block size in bytes */
269 	u_int32_t	blkcount;	/* total blocks */
270 	u_int32_t	blkreserved;	/* reserved blocks */
271 	u_int8_t	drv_model[40];	/* drive model */
272 	u_int8_t	drv_serial[40];	/* drive serial number */
273 	u_int8_t	drv_fwrev[8];	/* drive firmware revision */
274 	u_int8_t	scsi_inq;	/* SCSI inquiry bits */
275 	u_int8_t	cpq_drv_stmp;
276 	u_int8_t	last_fail;
277 	u_int8_t	pd_flags;	/* physical drive flags */
278 #define	PDF_DISK_PRESENT	0x01
279 #define	PDF_NONDISK_PRESENT	0x02
280 #define	PDF_WIDE_ENABLED	0x04
281 #define	PDF_SYNC		0x08
282 #define	PDF_NARROW_TRAY		0x10
283 #define	PDF_WIDEFAIL		0x20
284 #define	PDF_ULTRA		0x40
285 #define	PDF_ULTRA2		0x80
286 	u_int8_t	mpd_flags;	/* more physical drive flags */
287 #define	MPDF_SMART_SUPPORT	0x01	/* S.M.A.R.T supported */
288 #define	MPDF_SMART_ERRORS	0x02	/* S.M.A.R.T errors recorded */
289 #define	MPDF_SMART_ENABLED	0x04	/* S.M.A.R.T predictive failure is enabled */
290 #define	MPDF_SMART_ERR_RESET	0x08	/* S.M.A.R.T errors recorded since last reset */
291 #define	MPDF_DRIVE_EXTERNAL	0x10	/* Connected to external connector. */
292 #define	MPDF_DRIVE_CONF_LVOL	0x20	/* Configured as part of a logical volume */
293 #define	MPDF_DRIVE_CONF_SPARE	0x40	/* Configured as a spare */
294 #define	MPDF_DRIVE_WCE		0x80	/* Drive WCE set on spinup */
295 	u_int8_t	scsi_lun;
296 	u_int8_t	ympd_flags;	/* yet more physical drive flags */
297 #define	YMPDF_DRIVE_WCE_SET	0x40	/* WCE currently set */
298 #define	YMPDF_DRIVE_WCE_CHNG	0x80	/* WCE changable */
299 	u_int8_t	reserved;
300 	u_int32_t	spi_speed_rules;
301 	u_int8_t	phys_con[2];	/* Physical Connector */
302 	u_int8_t	phys_box;	/* Physical Box on Bus */
303 	u_int8_t	phys_bay;	/* Physical Bay in Box */
304 } __packed;
305 
306 /*
307  * CMD_BLINK_DRV_LEDS (0x16)
308  * Blink Drive Tray LEDs
309  *
310  * CMD_SENSE_DRV_LEDS (0x17)
311  * Sense Blinking Drive Tray LEDs
312  */
313 struct ida_blink_drv_leds {
314 	u_int32_t	bd;		/* Blink duration (in 10ths sec) */
315 	u_int32_t	bte;		/* Blink time elapsed (sense only) */
316 	u_int8_t	bse[256];	/* Blink/seek enable */
317 	u_int8_t	reserved1[248];
318 } __packed;
319 
320 /*
321  * CMD_LABEL_LOG_DRV (0x57)
322  * Label Logical Drive
323  */
324 struct ida_label_logical {
325 	u_int32_t	ld_id;		/* Logical drive identifier */
326 	u_int8_t	ld_label[64];	/* Logical drive label */
327 } __packed;
328