1*0de5da96Sgmcgarry /* $NetBSD: icpreg.h,v 1.7 2008/09/08 23:36:54 gmcgarry Exp $ */ 29a09578eSad 39a09578eSad /*- 49a09578eSad * Copyright (c) 2002 The NetBSD Foundation, Inc. 59a09578eSad * All rights reserved. 69a09578eSad * 79a09578eSad * This code is derived from software contributed to The NetBSD Foundation 89a09578eSad * by Andrew Doran. 99a09578eSad * 109a09578eSad * Redistribution and use in source and binary forms, with or without 119a09578eSad * modification, are permitted provided that the following conditions 129a09578eSad * are met: 139a09578eSad * 1. Redistributions of source code must retain the above copyright 149a09578eSad * notice, this list of conditions and the following disclaimer. 159a09578eSad * 2. Redistributions in binary form must reproduce the above copyright 169a09578eSad * notice, this list of conditions and the following disclaimer in the 179a09578eSad * documentation and/or other materials provided with the distribution. 189a09578eSad * 199a09578eSad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 209a09578eSad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 219a09578eSad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 229a09578eSad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 239a09578eSad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 249a09578eSad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 259a09578eSad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 269a09578eSad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 279a09578eSad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 289a09578eSad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 299a09578eSad * POSSIBILITY OF SUCH DAMAGE. 309a09578eSad */ 319a09578eSad 329a09578eSad /* 339a09578eSad * Copyright (c) 1999, 2000 Niklas Hallqvist. All rights reserved. 349a09578eSad * 359a09578eSad * Redistribution and use in source and binary forms, with or without 369a09578eSad * modification, are permitted provided that the following conditions 379a09578eSad * are met: 389a09578eSad * 1. Redistributions of source code must retain the above copyright 399a09578eSad * notice, this list of conditions and the following disclaimer. 409a09578eSad * 2. Redistributions in binary form must reproduce the above copyright 419a09578eSad * notice, this list of conditions and the following disclaimer in the 429a09578eSad * documentation and/or other materials provided with the distribution. 439a09578eSad * 3. All advertising materials mentioning features or use of this software 449a09578eSad * must display the following acknowledgement: 459a09578eSad * This product includes software developed by Niklas Hallqvist. 469a09578eSad * 4. The name of the author may not be used to endorse or promote products 479a09578eSad * derived from this software without specific prior written permission. 489a09578eSad * 499a09578eSad * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 509a09578eSad * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 519a09578eSad * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 529a09578eSad * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 539a09578eSad * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 549a09578eSad * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 559a09578eSad * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 569a09578eSad * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 579a09578eSad * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 589a09578eSad * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 599a09578eSad * 609a09578eSad * from OpenBSD: gdtreg.h,v 1.1 2000/02/07 00:33:03 niklas Exp 619a09578eSad */ 629a09578eSad 639a09578eSad #ifndef _IC_ICPREG_H_ 649a09578eSad #define _IC_ICPREG_H_ 659a09578eSad 669a09578eSad #define ICP_MAXBUS 6 /* XXX Why not 5? */ 673178a4f4Sthorpej #define ICP_MAX_LDRIVES 255 /* max logical drive count */ 683178a4f4Sthorpej #define ICP_MAX_HDRIVES 100 /* max host drive count */ 699a09578eSad #define ICP_MAXID_FC 127 /* Fibre-channel maximum ID */ 709a09578eSad #define ICP_MAXOFFSETS 128 719a09578eSad #define ICP_MAXSG 17 /* Max. s/g elements; actually 128 */ 729a09578eSad #define ICP_PROTOCOL_VERSION 1 739a09578eSad #define ICP_LINUX_OS 8 /* Used for cache optimization */ 749a09578eSad #define ICP_SCATTER_GATHER 1 /* s/g feature */ 759a09578eSad #define ICP_SECS32 0x1f /* round capacity */ 769a09578eSad #define ICP_LOCALBOARD 0 /* Board node always 0 */ 779a09578eSad #define ICP_MAX_CMDS 124 789a09578eSad #define ICP_SECTOR_SIZE 0x200 /* Always 512 bytes for cache devs */ 79405790a8Sthorpej #define ICP_MAX_EVENTS 0x100 /* event buffer */ 809a09578eSad 819a09578eSad /* DPMEM constants */ 829a09578eSad #define ICP_MPR_MAGIC 0xc0ffee11 839a09578eSad #define ICP_IC_HEADER_BYTES 48 849a09578eSad #define ICP_IC_QUEUE_BYTES 4 859a09578eSad 869a09578eSad /* Cache/raw service commands */ 879a09578eSad #define ICP_INIT 0 /* service initialization */ 889a09578eSad #define ICP_READ 1 /* read command */ 899a09578eSad #define ICP_WRITE 2 /* write command */ 909a09578eSad #define ICP_INFO 3 /* information about devices */ 919a09578eSad #define ICP_FLUSH 4 /* flush dirty cache buffers */ 929a09578eSad #define ICP_IOCTL 5 /* ioctl command */ 939a09578eSad #define ICP_DEVTYPE 9 /* additional information */ 949a09578eSad #define ICP_MOUNT 10 /* mount cache device */ 959a09578eSad #define ICP_UNMOUNT 11 /* unmount cache device */ 969a09578eSad #define ICP_SET_FEAT 12 /* set features (scatter/gather) */ 979a09578eSad #define ICP_GET_FEAT 13 /* get features */ 989a09578eSad #define ICP_WRITE_THR 16 /* write through */ 999a09578eSad #define ICP_READ_THR 17 /* read through */ 1009a09578eSad #define ICP_EXT_INFO 18 /* extended info */ 1019a09578eSad #define ICP_RESET 19 /* controller reset */ 1029a09578eSad #define ICP_FREEZE_IO 25 /* freeze all IOs */ 1039a09578eSad #define ICP_UNFREEZE_IO 26 /* unfreeze all IOs */ 1049a09578eSad 1059a09578eSad /* Additional raw service commands */ 1069a09578eSad #define ICP_RESERVE 14 /* reserve device to raw service */ 1079a09578eSad #define ICP_RELEASE 15 /* release device */ 1089a09578eSad #define ICP_RESERVE_ALL 16 /* reserve all devices */ 1099a09578eSad #define ICP_RELEASE_ALL 17 /* release all devices */ 1109a09578eSad #define ICP_RESET_BUS 18 /* reset bus */ 1119a09578eSad #define ICP_SCAN_START 19 /* start device scan */ 1129a09578eSad #define ICP_SCAN_END 20 /* stop device scan */ 1139a09578eSad 1149a09578eSad /* IOCTL command defines */ 1159a09578eSad #define ICP_SCSI_DR_INFO 0x00 /* SCSI drive info */ 1169a09578eSad #define ICP_SCSI_CHAN_CNT 0x05 /* SCSI channel count */ 1179a09578eSad #define ICP_SCSI_DR_LIST 0x06 /* SCSI drive list */ 1189a09578eSad #define ICP_SCSI_DEF_CNT 0x15 /* grown/primary defects */ 1199a09578eSad #define ICP_DSK_STATISTICS 0x4b /* SCSI disk statistics */ 1209a09578eSad #define ICP_IOCHAN_DESC 0x5d /* description of IO channel */ 1219a09578eSad #define ICP_IOCHAN_RAW_DESC 0x5e /* description of raw IO channel */ 1229a09578eSad 1239a09578eSad #define ICP_L_CTRL_PATTERN 0x20000000 /* SCSI IOCTL mask */ 1249a09578eSad #define ICP_ARRAY_INFO 0x12 /* array drive info */ 1259a09578eSad #define ICP_ARRAY_DRV_LIST 0x0f /* array drive list */ 1269a09578eSad #define ICP_LA_CTRL_PATTERN 0x10000000 /* array IOCTL mask */ 1279a09578eSad #define ICP_CACHE_DRV_CNT 0x01 /* cache drive count */ 1289a09578eSad #define ICP_CACHE_DRV_LIST 0x02 /* cache drive list */ 1299a09578eSad #define ICP_CACHE_INFO 0x04 /* cache info */ 1309a09578eSad #define ICP_CACHE_CONFIG 0x05 /* cache configuration */ 1319a09578eSad #define ICP_CACHE_DRV_INFO 0x07 /* cache drive info */ 1329a09578eSad #define ICP_BOARD_FEATURES 0x15 /* controller features */ 1339a09578eSad #define ICP_BOARD_INFO 0x28 /* controller info */ 1349a09578eSad #define ICP_HOST_GET 0x10001 /* get host drive list */ 1359a09578eSad #define ICP_IO_CHANNEL 0x20000 /* default IO channel */ 1369a09578eSad #define ICP_INVALID_CHANNEL 0xffff /* invalid channel */ 1379a09578eSad 1389a09578eSad /* Service errors */ 139405790a8Sthorpej #define ICP_S_MSG_REQUEST 0 /* screen service: async evt message */ 1409a09578eSad #define ICP_S_OK 1 /* no error */ 1419a09578eSad #define ICP_S_BSY 7 /* controller busy */ 1429a09578eSad #define ICP_S_RAW_SCSI 12 /* raw service: target error */ 1439a09578eSad #define ICP_S_RAW_ILL 0xff /* raw service: illegal */ 1449a09578eSad #define ICP_S_NO_STATUS 0x1000 /* got no status (driver-generated) */ 1459a09578eSad 1469a09578eSad /* Controller services */ 1479a09578eSad #define ICP_SCSIRAWSERVICE 3 1489a09578eSad #define ICP_CACHESERVICE 9 1499a09578eSad #define ICP_SCREENSERVICE 11 1509a09578eSad 1519a09578eSad /* Data direction raw service. */ 1529a09578eSad #define ICP_DATA_IN 0x01000000 1539a09578eSad #define ICP_DATA_OUT 0x00000000 1549a09578eSad 1559a09578eSad /* Command queue entries */ 1569a09578eSad #define ICP_OFFSET 0x00 /* u_int16_t, command offset in the DP RAM */ 1579a09578eSad #define ICP_SERV_ID 0x02 /* u_int16_t, service */ 1589a09578eSad #define ICP_COMM_Q_SZ 0x04 1599a09578eSad 1609a09578eSad /* Interface area */ 1619a09578eSad #define ICP_S_CMD_INDX 0x00 /* u_int8_t, special command */ 1629a09578eSad #define ICP_S_STATUS 0x01 /* volatile u_int8_t, status special command */ 1639a09578eSad #define ICP_S_INFO 0x04 /* u_int32_t [4], add. info special command */ 1649a09578eSad #define ICP_SEMA0 0x14 /* volatile u_int8_t, command semaphore */ 1659a09578eSad #define ICP_CMD_INDEX 0x18 /* u_int8_t, command number */ 1669a09578eSad #define ICP_STATUS 0x1c /* volatile u_int16_t, command status */ 1679a09578eSad #define ICP_SERVICE 0x1e /* u_int16_t, service (for asynch. events) */ 1689a09578eSad #define ICP_DPR_INFO 0x20 /* u_int32_t [2], additional info */ 1699a09578eSad #define ICP_COMM_QUEUE 0x28 /* command queue */ 1709a09578eSad #define ICP_DPR_CMD (0x30 + ICP_MAXOFFSETS * ICP_COMM_Q_SZ) 1719a09578eSad /* u_int8_t [], commands */ 1729a09578eSad #define ICP_DPR_IF_SZ ICP_DPR_CMD 1739a09578eSad 1749a09578eSad /* Get cache info */ 1759a09578eSad #define ICP_CINFO_CPAR 0x00 1769a09578eSad #define ICP_CINFO_CSTAT 0x0c 1779a09578eSad 1789a09578eSad /* Other defines */ 1799a09578eSad #define ICP_ASYNCINDEX 0 /* command index asynchronous event */ 1809a09578eSad #define ICP_SPEZINDEX 1 /* command index unknown service */ 1819a09578eSad 1829a09578eSad /* I/O channel header */ 1839a09578eSad struct icp_ioc_version { 1849a09578eSad u_int32_t iv_version; /* version (~0: newest) */ 1859a09578eSad u_int8_t iv_listents; /* list entry count */ 1869a09578eSad u_int8_t iv_firstchan; /* first channel number */ 1879a09578eSad u_int8_t iv_lastchan; /* last channel number */ 1889a09578eSad u_int8_t iv_chancount; /* channel count */ 1899a09578eSad u_int32_t iv_listoffset; /* offset of list[0] */ 190*0de5da96Sgmcgarry } __packed; 1919a09578eSad 1929a09578eSad #define ICP_IOC_NEWEST 0xffffffff 1939a09578eSad 1949a09578eSad /* Get I/O channel description */ 1959a09578eSad struct icp_ioc { 1969a09578eSad u_int32_t io_addr; /* channel address */ 1979a09578eSad u_int8_t io_type; /* type (SCSI/FCAL) */ 1989a09578eSad u_int8_t io_localno; /* local number */ 1999a09578eSad u_int16_t io_features; /* channel features */ 200*0de5da96Sgmcgarry } __packed; 2019a09578eSad 2029a09578eSad /* Get raw I/O channel description */ 2039a09578eSad struct icp_rawioc { 2049a09578eSad u_int8_t ri_procid; /* processor ID */ 2059a09578eSad u_int8_t ri_defect; /* defect? */ 2069a09578eSad u_int16_t ri_padding; 207*0de5da96Sgmcgarry } __packed; 2089a09578eSad 2099a09578eSad /* Get SCSI channel count */ 2109a09578eSad struct icp_getch { 2119a09578eSad u_int32_t gc_channo; /* channel number */ 2129a09578eSad u_int32_t gc_drivecnt; /* drive count */ 2139a09578eSad u_int8_t gc_scsiid; /* SCSI initiator ID */ 2149a09578eSad u_int8_t gc_scsistate; /* SCSI processor state */ 215*0de5da96Sgmcgarry } __packed; 2169a09578eSad 2179a09578eSad /* Cache info/config IOCTL structures */ 2189a09578eSad struct icp_cpar { 2199a09578eSad u_int32_t cp_version; /* firmware version */ 2209a09578eSad u_int16_t cp_state; /* cache state (on/off) */ 2219a09578eSad u_int16_t cp_strategy; /* cache strategy */ 2229a09578eSad u_int16_t cp_write_back; /* write back (on/off) */ 2239a09578eSad u_int16_t cp_block_size; /* cache block size */ 224*0de5da96Sgmcgarry } __packed; 2259a09578eSad 2269a09578eSad struct icp_cstat { 2279a09578eSad u_int32_t cs_size; /* cache size */ 2289a09578eSad u_int32_t cs_readcnt; /* read counter */ 2299a09578eSad u_int32_t cs_writecnt; /* write counter */ 2309a09578eSad u_int32_t cs_trhits; /* track hits */ 2319a09578eSad u_int32_t cs_sechits; /* sector hits */ 2329a09578eSad u_int32_t cs_secmiss; /* sector misses */ 233*0de5da96Sgmcgarry } __packed; 2349a09578eSad 2359a09578eSad /* Board information. */ 2369a09578eSad struct icp_binfo { 2379a09578eSad u_int32_t bi_ser_no; /* serial number */ 2389a09578eSad u_int8_t bi_oem_id[2]; /* OEM ID */ 2399a09578eSad u_int16_t bi_ep_flags; /* eprom flags */ 2409a09578eSad u_int32_t bi_proc_id; /* processor ID */ 2419a09578eSad u_int32_t bi_memsize; /* memory size (bytes) */ 2429a09578eSad u_int8_t bi_mem_banks; /* memory banks */ 2439a09578eSad u_int8_t bi_chan_type; /* channel type */ 2449a09578eSad u_int8_t bi_chan_count; /* channel count */ 2459a09578eSad u_int8_t bi_rdongle_pres; /* dongle present */ 2469a09578eSad u_int32_t bi_epr_fw_ver; /* (eprom) firmware ver */ 2479a09578eSad u_int32_t bi_upd_fw_ver; /* (update) firmware ver */ 2489a09578eSad u_int32_t bi_upd_revision; /* update revision */ 2499a09578eSad char bi_type_string[16]; /* char controller name */ 2509a09578eSad char bi_raid_string[16]; /* char RAID firmware name */ 2519a09578eSad u_int8_t bi_update_pres; /* update present? */ 2529a09578eSad u_int8_t bi_xor_pres; /* XOR engine present */ 2539a09578eSad u_int8_t bi_prom_type; /* ROM type (eprom/flash) */ 2549a09578eSad u_int8_t bi_prom_count; /* number of ROM devices */ 2559a09578eSad u_int32_t bi_dup_pres; /* duplexing module pres? */ 2569a09578eSad u_int32_t bi_chan_pres; /* # of exp. channels */ 2579a09578eSad u_int32_t bi_mem_pres; /* memory expansion inst? */ 2589a09578eSad u_int8_t bi_ft_bus_system; /* fault bus supported? */ 2599a09578eSad u_int8_t bi_subtype_valid; /* board_subtype valid */ 2609a09578eSad u_int8_t bi_board_subtype; /* subtype/hardware level */ 2619a09578eSad u_int8_t bi_rampar_pres; /* RAM parity check hw? */ 262*0de5da96Sgmcgarry } __packed; 2639a09578eSad 2649a09578eSad /* Board features. */ 2659a09578eSad struct icp_bfeat { 2669a09578eSad u_int8_t bf_chaining; /* chaining supported */ 2679a09578eSad u_int8_t bf_striping; /* striping (RAID-0) supported */ 2689a09578eSad u_int8_t bf_mirroring; /* mirroring (RAID-1) supported */ 2699a09578eSad u_int8_t bf_raid; /* RAID-4/5/10 supported */ 270*0de5da96Sgmcgarry } __packed; 2719a09578eSad 2729a09578eSad /* Cache drive information. */ 2739a09578eSad struct icp_cdevinfo { 2749a09578eSad char cd_name[8]; 2759a09578eSad u_int32_t cd_devtype; 2769a09578eSad u_int32_t cd_ldcnt; 2779a09578eSad u_int32_t cd_last_error; 2789a09578eSad u_int8_t cd_initialized; 2799a09578eSad u_int8_t cd_removable; 2809a09578eSad u_int8_t cd_write_protected; 2819a09578eSad u_int8_t cd_flags; 2829a09578eSad u_int32_t ld_blkcnt; 2839a09578eSad u_int32_t ld_blksize; 2849a09578eSad u_int32_t ld_dcnt; 2859a09578eSad u_int32_t ld_slave; 2869a09578eSad u_int32_t ld_dtype; 2879a09578eSad u_int32_t ld_last_error; 2889a09578eSad char ld_name[8]; 2899a09578eSad u_int8_t ld_error; 290*0de5da96Sgmcgarry } __packed; 2919a09578eSad 2929a09578eSad struct icp_sg { 2939a09578eSad u_int32_t sg_addr; 2949a09578eSad u_int32_t sg_len; 295*0de5da96Sgmcgarry } __packed; 2969a09578eSad 2979a09578eSad struct icp_cachecmd { 2989a09578eSad u_int16_t cc_deviceno; 2999a09578eSad u_int32_t cc_blockno; 3009a09578eSad u_int32_t cc_blockcnt; 3019a09578eSad u_int32_t cc_addr; /* ~0 == s/g */ 3029a09578eSad u_int32_t cc_nsgent; 3039a09578eSad struct icp_sg cc_sg[ICP_MAXSG]; 304*0de5da96Sgmcgarry } __packed; 3059a09578eSad 3069a09578eSad struct icp_ioctlcmd { 3079a09578eSad u_int16_t ic_bufsize; 3089a09578eSad u_int32_t ic_subfunc; 3099a09578eSad u_int32_t ic_channel; 3109a09578eSad u_int32_t ic_addr; 311*0de5da96Sgmcgarry } __packed; 3129a09578eSad 3139a09578eSad struct icp_screencmd { 3149a09578eSad u_int32_t sc_msghandle; 3159a09578eSad u_int32_t sc_msgaddr; 316*0de5da96Sgmcgarry } __packed; 3179a09578eSad 3189a09578eSad struct icp_rawcmd { 3199a09578eSad u_int16_t rc_padding0; /* unused */ 3209a09578eSad u_int32_t rc_direction; /* data direction */ 3219a09578eSad u_int32_t rc_mdisc_time; /* disc. time (0: none) */ 3229a09578eSad u_int32_t rc_mcon_time; /* conn. time (0: none) */ 3239a09578eSad u_int32_t rc_sdata; /* dest address */ 3249a09578eSad u_int32_t rc_sdlen; /* data length */ 3259a09578eSad u_int32_t rc_clen; /* CDB length */ 3269a09578eSad u_int8_t rc_cdb[12]; /* SCSI CDB */ 3279a09578eSad u_int8_t rc_target; /* target ID */ 3289a09578eSad u_int8_t rc_lun; /* LUN */ 3299a09578eSad u_int8_t rc_bus; /* channel */ 3309a09578eSad u_int8_t rc_priority; /* priority; 0 only */ 3319a09578eSad u_int32_t rc_sense_len; /* sense length */ 3329a09578eSad u_int32_t rc_sense_addr; /* sense address */ 3339a09578eSad u_int32_t rc_padding1; /* unused */ 3349a09578eSad u_int32_t rc_nsgent; /* s/g element count */ 3359a09578eSad struct icp_sg rc_sg[ICP_MAXSG]; /* s/g list */ 336*0de5da96Sgmcgarry } __packed; 3379a09578eSad 3389a09578eSad struct icp_cmdhdr { 3399a09578eSad u_int32_t cmd_boardnode; /* always 0 */ 3409a09578eSad u_int32_t cmd_cmdindex; /* command identifier */ 3419a09578eSad u_int16_t cmd_opcode; 342*0de5da96Sgmcgarry } __packed; 3439a09578eSad 3449a09578eSad struct icp_cmd { 3459a09578eSad u_int32_t cmd_boardnode; /* always 0 */ 3469a09578eSad u_int32_t cmd_cmdindex; /* command identifier */ 3479a09578eSad u_int16_t cmd_opcode; 3489a09578eSad 3499a09578eSad union { 3509a09578eSad struct icp_rawcmd rc; 3519a09578eSad struct icp_screencmd sc; 3529a09578eSad struct icp_ioctlcmd ic; 3539a09578eSad struct icp_cachecmd cc; 3549a09578eSad } cmd_packet; 355*0de5da96Sgmcgarry } __packed; 3569a09578eSad 3579a09578eSad #endif /* !_IC_ICPREG_H_ */ 358