1 1.7 gmcgarry /* $NetBSD: icpreg.h,v 1.7 2008/09/08 23:36:54 gmcgarry Exp $ */ 2 1.1 ad 3 1.1 ad /*- 4 1.1 ad * Copyright (c) 2002 The NetBSD Foundation, Inc. 5 1.1 ad * All rights reserved. 6 1.1 ad * 7 1.1 ad * This code is derived from software contributed to The NetBSD Foundation 8 1.1 ad * by Andrew Doran. 9 1.1 ad * 10 1.1 ad * Redistribution and use in source and binary forms, with or without 11 1.1 ad * modification, are permitted provided that the following conditions 12 1.1 ad * are met: 13 1.1 ad * 1. Redistributions of source code must retain the above copyright 14 1.1 ad * notice, this list of conditions and the following disclaimer. 15 1.1 ad * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 ad * notice, this list of conditions and the following disclaimer in the 17 1.1 ad * documentation and/or other materials provided with the distribution. 18 1.1 ad * 19 1.1 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 ad * POSSIBILITY OF SUCH DAMAGE. 30 1.1 ad */ 31 1.1 ad 32 1.1 ad /* 33 1.1 ad * Copyright (c) 1999, 2000 Niklas Hallqvist. All rights reserved. 34 1.1 ad * 35 1.1 ad * Redistribution and use in source and binary forms, with or without 36 1.1 ad * modification, are permitted provided that the following conditions 37 1.1 ad * are met: 38 1.1 ad * 1. Redistributions of source code must retain the above copyright 39 1.1 ad * notice, this list of conditions and the following disclaimer. 40 1.1 ad * 2. Redistributions in binary form must reproduce the above copyright 41 1.1 ad * notice, this list of conditions and the following disclaimer in the 42 1.1 ad * documentation and/or other materials provided with the distribution. 43 1.1 ad * 3. All advertising materials mentioning features or use of this software 44 1.1 ad * must display the following acknowledgement: 45 1.1 ad * This product includes software developed by Niklas Hallqvist. 46 1.1 ad * 4. The name of the author may not be used to endorse or promote products 47 1.1 ad * derived from this software without specific prior written permission. 48 1.1 ad * 49 1.1 ad * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 50 1.1 ad * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 51 1.1 ad * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 52 1.1 ad * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 53 1.1 ad * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 54 1.1 ad * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 55 1.1 ad * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 56 1.1 ad * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 57 1.1 ad * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 58 1.1 ad * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 59 1.1 ad * 60 1.1 ad * from OpenBSD: gdtreg.h,v 1.1 2000/02/07 00:33:03 niklas Exp 61 1.1 ad */ 62 1.1 ad 63 1.1 ad #ifndef _IC_ICPREG_H_ 64 1.1 ad #define _IC_ICPREG_H_ 65 1.1 ad 66 1.1 ad #define ICP_MAXBUS 6 /* XXX Why not 5? */ 67 1.3 thorpej #define ICP_MAX_LDRIVES 255 /* max logical drive count */ 68 1.3 thorpej #define ICP_MAX_HDRIVES 100 /* max host drive count */ 69 1.1 ad #define ICP_MAXID_FC 127 /* Fibre-channel maximum ID */ 70 1.1 ad #define ICP_MAXOFFSETS 128 71 1.1 ad #define ICP_MAXSG 17 /* Max. s/g elements; actually 128 */ 72 1.1 ad #define ICP_PROTOCOL_VERSION 1 73 1.1 ad #define ICP_LINUX_OS 8 /* Used for cache optimization */ 74 1.1 ad #define ICP_SCATTER_GATHER 1 /* s/g feature */ 75 1.1 ad #define ICP_SECS32 0x1f /* round capacity */ 76 1.1 ad #define ICP_LOCALBOARD 0 /* Board node always 0 */ 77 1.1 ad #define ICP_MAX_CMDS 124 78 1.1 ad #define ICP_SECTOR_SIZE 0x200 /* Always 512 bytes for cache devs */ 79 1.2 thorpej #define ICP_MAX_EVENTS 0x100 /* event buffer */ 80 1.1 ad 81 1.1 ad /* DPMEM constants */ 82 1.1 ad #define ICP_MPR_MAGIC 0xc0ffee11 83 1.1 ad #define ICP_IC_HEADER_BYTES 48 84 1.1 ad #define ICP_IC_QUEUE_BYTES 4 85 1.1 ad 86 1.1 ad /* Cache/raw service commands */ 87 1.1 ad #define ICP_INIT 0 /* service initialization */ 88 1.1 ad #define ICP_READ 1 /* read command */ 89 1.1 ad #define ICP_WRITE 2 /* write command */ 90 1.1 ad #define ICP_INFO 3 /* information about devices */ 91 1.1 ad #define ICP_FLUSH 4 /* flush dirty cache buffers */ 92 1.1 ad #define ICP_IOCTL 5 /* ioctl command */ 93 1.1 ad #define ICP_DEVTYPE 9 /* additional information */ 94 1.1 ad #define ICP_MOUNT 10 /* mount cache device */ 95 1.1 ad #define ICP_UNMOUNT 11 /* unmount cache device */ 96 1.1 ad #define ICP_SET_FEAT 12 /* set features (scatter/gather) */ 97 1.1 ad #define ICP_GET_FEAT 13 /* get features */ 98 1.1 ad #define ICP_WRITE_THR 16 /* write through */ 99 1.1 ad #define ICP_READ_THR 17 /* read through */ 100 1.1 ad #define ICP_EXT_INFO 18 /* extended info */ 101 1.1 ad #define ICP_RESET 19 /* controller reset */ 102 1.1 ad #define ICP_FREEZE_IO 25 /* freeze all IOs */ 103 1.1 ad #define ICP_UNFREEZE_IO 26 /* unfreeze all IOs */ 104 1.1 ad 105 1.1 ad /* Additional raw service commands */ 106 1.1 ad #define ICP_RESERVE 14 /* reserve device to raw service */ 107 1.1 ad #define ICP_RELEASE 15 /* release device */ 108 1.1 ad #define ICP_RESERVE_ALL 16 /* reserve all devices */ 109 1.1 ad #define ICP_RELEASE_ALL 17 /* release all devices */ 110 1.1 ad #define ICP_RESET_BUS 18 /* reset bus */ 111 1.1 ad #define ICP_SCAN_START 19 /* start device scan */ 112 1.4 perry #define ICP_SCAN_END 20 /* stop device scan */ 113 1.1 ad 114 1.1 ad /* IOCTL command defines */ 115 1.1 ad #define ICP_SCSI_DR_INFO 0x00 /* SCSI drive info */ 116 1.1 ad #define ICP_SCSI_CHAN_CNT 0x05 /* SCSI channel count */ 117 1.1 ad #define ICP_SCSI_DR_LIST 0x06 /* SCSI drive list */ 118 1.1 ad #define ICP_SCSI_DEF_CNT 0x15 /* grown/primary defects */ 119 1.1 ad #define ICP_DSK_STATISTICS 0x4b /* SCSI disk statistics */ 120 1.1 ad #define ICP_IOCHAN_DESC 0x5d /* description of IO channel */ 121 1.1 ad #define ICP_IOCHAN_RAW_DESC 0x5e /* description of raw IO channel */ 122 1.1 ad 123 1.1 ad #define ICP_L_CTRL_PATTERN 0x20000000 /* SCSI IOCTL mask */ 124 1.1 ad #define ICP_ARRAY_INFO 0x12 /* array drive info */ 125 1.1 ad #define ICP_ARRAY_DRV_LIST 0x0f /* array drive list */ 126 1.1 ad #define ICP_LA_CTRL_PATTERN 0x10000000 /* array IOCTL mask */ 127 1.1 ad #define ICP_CACHE_DRV_CNT 0x01 /* cache drive count */ 128 1.1 ad #define ICP_CACHE_DRV_LIST 0x02 /* cache drive list */ 129 1.1 ad #define ICP_CACHE_INFO 0x04 /* cache info */ 130 1.1 ad #define ICP_CACHE_CONFIG 0x05 /* cache configuration */ 131 1.1 ad #define ICP_CACHE_DRV_INFO 0x07 /* cache drive info */ 132 1.1 ad #define ICP_BOARD_FEATURES 0x15 /* controller features */ 133 1.1 ad #define ICP_BOARD_INFO 0x28 /* controller info */ 134 1.1 ad #define ICP_HOST_GET 0x10001 /* get host drive list */ 135 1.1 ad #define ICP_IO_CHANNEL 0x20000 /* default IO channel */ 136 1.1 ad #define ICP_INVALID_CHANNEL 0xffff /* invalid channel */ 137 1.1 ad 138 1.1 ad /* Service errors */ 139 1.2 thorpej #define ICP_S_MSG_REQUEST 0 /* screen service: async evt message */ 140 1.1 ad #define ICP_S_OK 1 /* no error */ 141 1.1 ad #define ICP_S_BSY 7 /* controller busy */ 142 1.1 ad #define ICP_S_RAW_SCSI 12 /* raw service: target error */ 143 1.1 ad #define ICP_S_RAW_ILL 0xff /* raw service: illegal */ 144 1.1 ad #define ICP_S_NO_STATUS 0x1000 /* got no status (driver-generated) */ 145 1.1 ad 146 1.1 ad /* Controller services */ 147 1.1 ad #define ICP_SCSIRAWSERVICE 3 148 1.1 ad #define ICP_CACHESERVICE 9 149 1.1 ad #define ICP_SCREENSERVICE 11 150 1.1 ad 151 1.1 ad /* Data direction raw service. */ 152 1.1 ad #define ICP_DATA_IN 0x01000000 153 1.1 ad #define ICP_DATA_OUT 0x00000000 154 1.1 ad 155 1.1 ad /* Command queue entries */ 156 1.1 ad #define ICP_OFFSET 0x00 /* u_int16_t, command offset in the DP RAM */ 157 1.1 ad #define ICP_SERV_ID 0x02 /* u_int16_t, service */ 158 1.1 ad #define ICP_COMM_Q_SZ 0x04 159 1.1 ad 160 1.1 ad /* Interface area */ 161 1.1 ad #define ICP_S_CMD_INDX 0x00 /* u_int8_t, special command */ 162 1.1 ad #define ICP_S_STATUS 0x01 /* volatile u_int8_t, status special command */ 163 1.1 ad #define ICP_S_INFO 0x04 /* u_int32_t [4], add. info special command */ 164 1.1 ad #define ICP_SEMA0 0x14 /* volatile u_int8_t, command semaphore */ 165 1.1 ad #define ICP_CMD_INDEX 0x18 /* u_int8_t, command number */ 166 1.1 ad #define ICP_STATUS 0x1c /* volatile u_int16_t, command status */ 167 1.1 ad #define ICP_SERVICE 0x1e /* u_int16_t, service (for asynch. events) */ 168 1.1 ad #define ICP_DPR_INFO 0x20 /* u_int32_t [2], additional info */ 169 1.1 ad #define ICP_COMM_QUEUE 0x28 /* command queue */ 170 1.1 ad #define ICP_DPR_CMD (0x30 + ICP_MAXOFFSETS * ICP_COMM_Q_SZ) 171 1.1 ad /* u_int8_t [], commands */ 172 1.1 ad #define ICP_DPR_IF_SZ ICP_DPR_CMD 173 1.1 ad 174 1.1 ad /* Get cache info */ 175 1.1 ad #define ICP_CINFO_CPAR 0x00 176 1.1 ad #define ICP_CINFO_CSTAT 0x0c 177 1.1 ad 178 1.1 ad /* Other defines */ 179 1.1 ad #define ICP_ASYNCINDEX 0 /* command index asynchronous event */ 180 1.1 ad #define ICP_SPEZINDEX 1 /* command index unknown service */ 181 1.1 ad 182 1.1 ad /* I/O channel header */ 183 1.1 ad struct icp_ioc_version { 184 1.1 ad u_int32_t iv_version; /* version (~0: newest) */ 185 1.1 ad u_int8_t iv_listents; /* list entry count */ 186 1.1 ad u_int8_t iv_firstchan; /* first channel number */ 187 1.1 ad u_int8_t iv_lastchan; /* last channel number */ 188 1.1 ad u_int8_t iv_chancount; /* channel count */ 189 1.1 ad u_int32_t iv_listoffset; /* offset of list[0] */ 190 1.7 gmcgarry } __packed; 191 1.1 ad 192 1.1 ad #define ICP_IOC_NEWEST 0xffffffff 193 1.1 ad 194 1.1 ad /* Get I/O channel description */ 195 1.1 ad struct icp_ioc { 196 1.1 ad u_int32_t io_addr; /* channel address */ 197 1.1 ad u_int8_t io_type; /* type (SCSI/FCAL) */ 198 1.1 ad u_int8_t io_localno; /* local number */ 199 1.1 ad u_int16_t io_features; /* channel features */ 200 1.7 gmcgarry } __packed; 201 1.1 ad 202 1.1 ad /* Get raw I/O channel description */ 203 1.1 ad struct icp_rawioc { 204 1.1 ad u_int8_t ri_procid; /* processor ID */ 205 1.1 ad u_int8_t ri_defect; /* defect? */ 206 1.1 ad u_int16_t ri_padding; 207 1.7 gmcgarry } __packed; 208 1.1 ad 209 1.1 ad /* Get SCSI channel count */ 210 1.1 ad struct icp_getch { 211 1.1 ad u_int32_t gc_channo; /* channel number */ 212 1.1 ad u_int32_t gc_drivecnt; /* drive count */ 213 1.1 ad u_int8_t gc_scsiid; /* SCSI initiator ID */ 214 1.1 ad u_int8_t gc_scsistate; /* SCSI processor state */ 215 1.7 gmcgarry } __packed; 216 1.1 ad 217 1.1 ad /* Cache info/config IOCTL structures */ 218 1.1 ad struct icp_cpar { 219 1.1 ad u_int32_t cp_version; /* firmware version */ 220 1.1 ad u_int16_t cp_state; /* cache state (on/off) */ 221 1.1 ad u_int16_t cp_strategy; /* cache strategy */ 222 1.1 ad u_int16_t cp_write_back; /* write back (on/off) */ 223 1.1 ad u_int16_t cp_block_size; /* cache block size */ 224 1.7 gmcgarry } __packed; 225 1.1 ad 226 1.1 ad struct icp_cstat { 227 1.1 ad u_int32_t cs_size; /* cache size */ 228 1.1 ad u_int32_t cs_readcnt; /* read counter */ 229 1.1 ad u_int32_t cs_writecnt; /* write counter */ 230 1.1 ad u_int32_t cs_trhits; /* track hits */ 231 1.1 ad u_int32_t cs_sechits; /* sector hits */ 232 1.1 ad u_int32_t cs_secmiss; /* sector misses */ 233 1.7 gmcgarry } __packed; 234 1.1 ad 235 1.1 ad /* Board information. */ 236 1.1 ad struct icp_binfo { 237 1.1 ad u_int32_t bi_ser_no; /* serial number */ 238 1.1 ad u_int8_t bi_oem_id[2]; /* OEM ID */ 239 1.1 ad u_int16_t bi_ep_flags; /* eprom flags */ 240 1.1 ad u_int32_t bi_proc_id; /* processor ID */ 241 1.1 ad u_int32_t bi_memsize; /* memory size (bytes) */ 242 1.1 ad u_int8_t bi_mem_banks; /* memory banks */ 243 1.1 ad u_int8_t bi_chan_type; /* channel type */ 244 1.1 ad u_int8_t bi_chan_count; /* channel count */ 245 1.1 ad u_int8_t bi_rdongle_pres; /* dongle present */ 246 1.1 ad u_int32_t bi_epr_fw_ver; /* (eprom) firmware ver */ 247 1.1 ad u_int32_t bi_upd_fw_ver; /* (update) firmware ver */ 248 1.1 ad u_int32_t bi_upd_revision; /* update revision */ 249 1.1 ad char bi_type_string[16]; /* char controller name */ 250 1.1 ad char bi_raid_string[16]; /* char RAID firmware name */ 251 1.1 ad u_int8_t bi_update_pres; /* update present? */ 252 1.1 ad u_int8_t bi_xor_pres; /* XOR engine present */ 253 1.1 ad u_int8_t bi_prom_type; /* ROM type (eprom/flash) */ 254 1.1 ad u_int8_t bi_prom_count; /* number of ROM devices */ 255 1.1 ad u_int32_t bi_dup_pres; /* duplexing module pres? */ 256 1.1 ad u_int32_t bi_chan_pres; /* # of exp. channels */ 257 1.1 ad u_int32_t bi_mem_pres; /* memory expansion inst? */ 258 1.1 ad u_int8_t bi_ft_bus_system; /* fault bus supported? */ 259 1.1 ad u_int8_t bi_subtype_valid; /* board_subtype valid */ 260 1.1 ad u_int8_t bi_board_subtype; /* subtype/hardware level */ 261 1.1 ad u_int8_t bi_rampar_pres; /* RAM parity check hw? */ 262 1.7 gmcgarry } __packed; 263 1.1 ad 264 1.1 ad /* Board features. */ 265 1.1 ad struct icp_bfeat { 266 1.1 ad u_int8_t bf_chaining; /* chaining supported */ 267 1.1 ad u_int8_t bf_striping; /* striping (RAID-0) supported */ 268 1.1 ad u_int8_t bf_mirroring; /* mirroring (RAID-1) supported */ 269 1.1 ad u_int8_t bf_raid; /* RAID-4/5/10 supported */ 270 1.7 gmcgarry } __packed; 271 1.1 ad 272 1.1 ad /* Cache drive information. */ 273 1.1 ad struct icp_cdevinfo { 274 1.1 ad char cd_name[8]; 275 1.1 ad u_int32_t cd_devtype; 276 1.1 ad u_int32_t cd_ldcnt; 277 1.1 ad u_int32_t cd_last_error; 278 1.1 ad u_int8_t cd_initialized; 279 1.1 ad u_int8_t cd_removable; 280 1.1 ad u_int8_t cd_write_protected; 281 1.1 ad u_int8_t cd_flags; 282 1.1 ad u_int32_t ld_blkcnt; 283 1.1 ad u_int32_t ld_blksize; 284 1.1 ad u_int32_t ld_dcnt; 285 1.1 ad u_int32_t ld_slave; 286 1.1 ad u_int32_t ld_dtype; 287 1.1 ad u_int32_t ld_last_error; 288 1.1 ad char ld_name[8]; 289 1.1 ad u_int8_t ld_error; 290 1.7 gmcgarry } __packed; 291 1.1 ad 292 1.1 ad struct icp_sg { 293 1.1 ad u_int32_t sg_addr; 294 1.1 ad u_int32_t sg_len; 295 1.7 gmcgarry } __packed; 296 1.1 ad 297 1.1 ad struct icp_cachecmd { 298 1.1 ad u_int16_t cc_deviceno; 299 1.1 ad u_int32_t cc_blockno; 300 1.1 ad u_int32_t cc_blockcnt; 301 1.1 ad u_int32_t cc_addr; /* ~0 == s/g */ 302 1.1 ad u_int32_t cc_nsgent; 303 1.1 ad struct icp_sg cc_sg[ICP_MAXSG]; 304 1.7 gmcgarry } __packed; 305 1.1 ad 306 1.1 ad struct icp_ioctlcmd { 307 1.1 ad u_int16_t ic_bufsize; 308 1.1 ad u_int32_t ic_subfunc; 309 1.1 ad u_int32_t ic_channel; 310 1.1 ad u_int32_t ic_addr; 311 1.7 gmcgarry } __packed; 312 1.1 ad 313 1.1 ad struct icp_screencmd { 314 1.1 ad u_int32_t sc_msghandle; 315 1.1 ad u_int32_t sc_msgaddr; 316 1.7 gmcgarry } __packed; 317 1.1 ad 318 1.1 ad struct icp_rawcmd { 319 1.1 ad u_int16_t rc_padding0; /* unused */ 320 1.1 ad u_int32_t rc_direction; /* data direction */ 321 1.1 ad u_int32_t rc_mdisc_time; /* disc. time (0: none) */ 322 1.1 ad u_int32_t rc_mcon_time; /* conn. time (0: none) */ 323 1.1 ad u_int32_t rc_sdata; /* dest address */ 324 1.1 ad u_int32_t rc_sdlen; /* data length */ 325 1.1 ad u_int32_t rc_clen; /* CDB length */ 326 1.1 ad u_int8_t rc_cdb[12]; /* SCSI CDB */ 327 1.1 ad u_int8_t rc_target; /* target ID */ 328 1.1 ad u_int8_t rc_lun; /* LUN */ 329 1.1 ad u_int8_t rc_bus; /* channel */ 330 1.1 ad u_int8_t rc_priority; /* priority; 0 only */ 331 1.1 ad u_int32_t rc_sense_len; /* sense length */ 332 1.1 ad u_int32_t rc_sense_addr; /* sense address */ 333 1.1 ad u_int32_t rc_padding1; /* unused */ 334 1.1 ad u_int32_t rc_nsgent; /* s/g element count */ 335 1.1 ad struct icp_sg rc_sg[ICP_MAXSG]; /* s/g list */ 336 1.7 gmcgarry } __packed; 337 1.1 ad 338 1.1 ad struct icp_cmdhdr { 339 1.1 ad u_int32_t cmd_boardnode; /* always 0 */ 340 1.1 ad u_int32_t cmd_cmdindex; /* command identifier */ 341 1.1 ad u_int16_t cmd_opcode; 342 1.7 gmcgarry } __packed; 343 1.1 ad 344 1.1 ad struct icp_cmd { 345 1.1 ad u_int32_t cmd_boardnode; /* always 0 */ 346 1.1 ad u_int32_t cmd_cmdindex; /* command identifier */ 347 1.1 ad u_int16_t cmd_opcode; 348 1.1 ad 349 1.1 ad union { 350 1.1 ad struct icp_rawcmd rc; 351 1.1 ad struct icp_screencmd sc; 352 1.1 ad struct icp_ioctlcmd ic; 353 1.1 ad struct icp_cachecmd cc; 354 1.1 ad } cmd_packet; 355 1.7 gmcgarry } __packed; 356 1.1 ad 357 1.1 ad #endif /* !_IC_ICPREG_H_ */ 358