1 1.1 mycroft typedef u_int8_t physaddr[4]; 2 1.1 mycroft typedef u_int8_t physlen[4]; 3 1.1 mycroft #define ltophys _lto4l 4 1.1 mycroft #define phystol _4ltol 5 1.1 mycroft 6 1.1 mycroft /* 7 1.1 mycroft * I/O port offsets 8 1.1 mycroft */ 9 1.1 mycroft #define BHA_CTRL_PORT 0 /* control (wo) */ 10 1.1 mycroft #define BHA_STAT_PORT 0 /* status (ro) */ 11 1.1 mycroft #define BHA_CMD_PORT 1 /* command (wo) */ 12 1.1 mycroft #define BHA_DATA_PORT 1 /* data (ro) */ 13 1.1 mycroft #define BHA_INTR_PORT 2 /* interrupt status (ro) */ 14 1.1 mycroft 15 1.1 mycroft /* 16 1.1 mycroft * BHA_CTRL bits 17 1.1 mycroft */ 18 1.1 mycroft #define BHA_CTRL_HRST 0x80 /* Hardware reset */ 19 1.1 mycroft #define BHA_CTRL_SRST 0x40 /* Software reset */ 20 1.1 mycroft #define BHA_CTRL_IRST 0x20 /* Interrupt reset */ 21 1.1 mycroft #define BHA_CTRL_SCRST 0x10 /* SCSI bus reset */ 22 1.1 mycroft 23 1.1 mycroft /* 24 1.1 mycroft * BHA_STAT bits 25 1.1 mycroft */ 26 1.1 mycroft #define BHA_STAT_STST 0x80 /* Self test in Progress */ 27 1.1 mycroft #define BHA_STAT_DIAGF 0x40 /* Diagnostic Failure */ 28 1.1 mycroft #define BHA_STAT_INIT 0x20 /* Mbx Init required */ 29 1.1 mycroft #define BHA_STAT_IDLE 0x10 /* Host Adapter Idle */ 30 1.1 mycroft #define BHA_STAT_CDF 0x08 /* cmd/data out port full */ 31 1.1 mycroft #define BHA_STAT_DF 0x04 /* Data in port full */ 32 1.1 mycroft #define BHA_STAT_INVDCMD 0x01 /* Invalid command */ 33 1.1 mycroft 34 1.1 mycroft /* 35 1.1 mycroft * BHA_CMD opcodes 36 1.1 mycroft */ 37 1.1 mycroft #define BHA_NOP 0x00 /* No operation */ 38 1.1 mycroft #define BHA_MBX_INIT 0x01 /* Mbx initialization */ 39 1.1 mycroft #define BHA_START_SCSI 0x02 /* start scsi command */ 40 1.1 mycroft #define BHA_INQUIRE_REVISION 0x04 /* Adapter Inquiry */ 41 1.1 mycroft #define BHA_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */ 42 1.1 mycroft #if 0 43 1.1 mycroft #define BHA_SEL_TIMEOUT_SET 0x06 /* set selection time-out */ 44 1.1 mycroft #define BHA_BUS_ON_TIME_SET 0x07 /* set bus-on time */ 45 1.1 mycroft #define BHA_BUS_OFF_TIME_SET 0x08 /* set bus-off time */ 46 1.1 mycroft #define BHA_SPEED_SET 0x09 /* set transfer speed */ 47 1.1 mycroft #endif 48 1.1 mycroft #define BHA_INQUIRE_DEVICES 0x0a /* return installed devices 0-7 */ 49 1.1 mycroft #define BHA_INQUIRE_CONFIG 0x0b /* return configuration data */ 50 1.1 mycroft #define BHA_TARGET_EN 0x0c /* enable target mode */ 51 1.1 mycroft #define BHA_INQUIRE_SETUP 0x0d /* return setup data */ 52 1.1 mycroft #define BHA_ECHO 0x1e /* Echo command data */ 53 1.1 mycroft #define BHA_INQUIRE_DEVICES_2 0x23 /* return installed devices 8-15 */ 54 1.1 mycroft #define BHA_MBX_INIT_EXTENDED 0x81 /* Mbx initialization */ 55 1.1 mycroft #define BHA_INQUIRE_REVISION_3 0x84 /* Get 3rd firmware version byte */ 56 1.1 mycroft #define BHA_INQUIRE_REVISION_4 0x85 /* Get 4th firmware version byte */ 57 1.1 mycroft #define BHA_INQUIRE_MODEL 0x8b /* Get hardware ID and revision */ 58 1.1 mycroft #define BHA_INQUIRE_PERIOD 0x8c /* Get synchronous period */ 59 1.1 mycroft #define BHA_INQUIRE_EXTENDED 0x8d /* Adapter Setup Inquiry */ 60 1.1 mycroft #define BHA_ROUND_ROBIN 0x8f /* Enable/Disable(default) round robin */ 61 1.1 mycroft 62 1.1 mycroft /* 63 1.1 mycroft * BHA_INTR bits 64 1.1 mycroft */ 65 1.1 mycroft #define BHA_INTR_ANYINTR 0x80 /* Any interrupt */ 66 1.1 mycroft #define BHA_INTR_SCRD 0x08 /* SCSI reset detected */ 67 1.1 mycroft #define BHA_INTR_HACC 0x04 /* Command complete */ 68 1.1 mycroft #define BHA_INTR_MBOA 0x02 /* MBX out empty */ 69 1.1 mycroft #define BHA_INTR_MBIF 0x01 /* MBX in full */ 70 1.1 mycroft 71 1.1 mycroft struct bha_mbx_out { 72 1.1 mycroft physaddr ccb_addr; 73 1.1 mycroft u_char dummy[3]; 74 1.1 mycroft u_char cmd; 75 1.1 mycroft }; 76 1.1 mycroft 77 1.1 mycroft struct bha_mbx_in { 78 1.1 mycroft physaddr ccb_addr; 79 1.1 mycroft u_char dummy[3]; 80 1.1 mycroft u_char stat; 81 1.1 mycroft }; 82 1.1 mycroft 83 1.1 mycroft /* 84 1.1 mycroft * mbo.cmd values 85 1.1 mycroft */ 86 1.1 mycroft #define BHA_MBO_FREE 0x0 /* MBO entry is free */ 87 1.1 mycroft #define BHA_MBO_START 0x1 /* MBO activate entry */ 88 1.1 mycroft #define BHA_MBO_ABORT 0x2 /* MBO abort entry */ 89 1.1 mycroft 90 1.1 mycroft /* 91 1.1 mycroft * mbi.stat values 92 1.1 mycroft */ 93 1.1 mycroft #define BHA_MBI_FREE 0x0 /* MBI entry is free */ 94 1.1 mycroft #define BHA_MBI_OK 0x1 /* completed without error */ 95 1.1 mycroft #define BHA_MBI_ABORT 0x2 /* aborted ccb */ 96 1.1 mycroft #define BHA_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */ 97 1.1 mycroft #define BHA_MBI_ERROR 0x4 /* Completed with error */ 98 1.1 mycroft 99 1.1 mycroft #if defined(BIG_DMA) 100 1.1 mycroft WARNING...THIS WON'T WORK(won't fit on 1 page) 101 1.1 mycroft #if 0 102 1.1 mycroft #define BHA_NSEG 2048 /* Number of scatter gather segments - to much vm */ 103 1.1 mycroft #endif 104 1.1 mycroft #define BHA_NSEG 128 105 1.1 mycroft #else 106 1.1 mycroft #define BHA_NSEG 33 107 1.1 mycroft #endif /* BIG_DMA */ 108 1.1 mycroft 109 1.1 mycroft struct bha_scat_gath { 110 1.1 mycroft physlen seg_len; 111 1.1 mycroft physaddr seg_addr; 112 1.1 mycroft }; 113 1.1 mycroft 114 1.1 mycroft struct bha_ccb { 115 1.1 mycroft u_char opcode; 116 1.1 mycroft u_char:3, data_in:1, data_out:1,:3; 117 1.1 mycroft u_char scsi_cmd_length; 118 1.1 mycroft u_char req_sense_length; 119 1.1 mycroft /*------------------------------------longword boundary */ 120 1.1 mycroft physlen data_length; 121 1.1 mycroft /*------------------------------------longword boundary */ 122 1.1 mycroft physaddr data_addr; 123 1.1 mycroft /*------------------------------------longword boundary */ 124 1.1 mycroft u_char dummy1[2]; 125 1.1 mycroft u_char host_stat; 126 1.1 mycroft u_char target_stat; 127 1.1 mycroft /*------------------------------------longword boundary */ 128 1.1 mycroft u_char target; 129 1.1 mycroft u_char lun; 130 1.1 mycroft struct scsi_generic scsi_cmd; 131 1.1 mycroft u_char dummy2[1]; 132 1.1 mycroft u_char link_id; 133 1.1 mycroft /*------------------------------------longword boundary */ 134 1.1 mycroft physaddr link_addr; 135 1.1 mycroft /*------------------------------------longword boundary */ 136 1.1 mycroft physaddr sense_ptr; 137 1.1 mycroft /*-----end of HW fields-----------------------longword boundary */ 138 1.1 mycroft struct scsi_sense_data scsi_sense; 139 1.1 mycroft /*------------------------------------longword boundary */ 140 1.1 mycroft struct bha_scat_gath scat_gath[BHA_NSEG]; 141 1.1 mycroft /*------------------------------------longword boundary */ 142 1.1 mycroft TAILQ_ENTRY(bha_ccb) chain; 143 1.1 mycroft struct bha_ccb *nexthash; 144 1.1 mycroft long hashkey; 145 1.1 mycroft struct scsi_xfer *xs; /* the scsi_xfer for this cmd */ 146 1.1 mycroft int flags; 147 1.1 mycroft #define CCB_ALLOC 0x01 148 1.1 mycroft #define CCB_ABORT 0x02 149 1.1 mycroft #ifdef BHADIAG 150 1.1 mycroft #define CCB_SENDING 0x04 151 1.1 mycroft #endif 152 1.1 mycroft int timeout; 153 1.1 mycroft }; 154 1.1 mycroft 155 1.1 mycroft /* 156 1.1 mycroft * opcode fields 157 1.1 mycroft */ 158 1.1 mycroft #define BHA_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */ 159 1.1 mycroft #define BHA_TARGET_CCB 0x01 /* SCSI Target CCB */ 160 1.1 mycroft #define BHA_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scattter gather */ 161 1.1 mycroft #define BHA_RESET_CCB 0x81 /* SCSI Bus reset */ 162 1.1 mycroft 163 1.1 mycroft /* 164 1.1 mycroft * bha_ccb.host_stat values 165 1.1 mycroft */ 166 1.1 mycroft #define BHA_OK 0x00 /* cmd ok */ 167 1.1 mycroft #define BHA_LINK_OK 0x0a /* Link cmd ok */ 168 1.1 mycroft #define BHA_LINK_IT 0x0b /* Link cmd ok + int */ 169 1.1 mycroft #define BHA_SEL_TIMEOUT 0x11 /* Selection time out */ 170 1.1 mycroft #define BHA_OVER_UNDER 0x12 /* Data over/under run */ 171 1.1 mycroft #define BHA_BUS_FREE 0x13 /* Bus dropped at unexpected time */ 172 1.1 mycroft #define BHA_INV_BUS 0x14 /* Invalid bus phase/sequence */ 173 1.1 mycroft #define BHA_BAD_MBO 0x15 /* Incorrect MBO cmd */ 174 1.1 mycroft #define BHA_BAD_CCB 0x16 /* Incorrect ccb opcode */ 175 1.1 mycroft #define BHA_BAD_LINK 0x17 /* Not same values of LUN for links */ 176 1.1 mycroft #define BHA_INV_TARGET 0x18 /* Invalid target direction */ 177 1.1 mycroft #define BHA_CCB_DUP 0x19 /* Duplicate CCB received */ 178 1.1 mycroft #define BHA_INV_CCB 0x1a /* Invalid CCB or segment list */ 179 1.1 mycroft 180 1.1 mycroft struct bha_extended_inquire { 181 1.1 mycroft struct { 182 1.1 mycroft u_char opcode; 183 1.1 mycroft u_char len; 184 1.1 mycroft } cmd; 185 1.1 mycroft struct { 186 1.1 mycroft u_char bus_type; /* Type of bus connected to */ 187 1.1 mycroft #define BHA_BUS_TYPE_24BIT 'A' /* ISA bus */ 188 1.1 mycroft #define BHA_BUS_TYPE_32BIT 'E' /* EISA/VLB/PCI bus */ 189 1.1 mycroft #define BHA_BUS_TYPE_MCA 'M' /* MicroChannel bus */ 190 1.1 mycroft u_char bios_address; /* Address of adapter BIOS */ 191 1.1 mycroft u_short max_segment; /* ? */ 192 1.1 mycroft } reply; 193 1.1 mycroft }; 194 1.1 mycroft 195 1.1 mycroft struct bha_config { 196 1.1 mycroft struct { 197 1.1 mycroft u_char opcode; 198 1.1 mycroft } cmd; 199 1.1 mycroft struct { 200 1.1 mycroft u_char chan; 201 1.1 mycroft u_char intr; 202 1.1 mycroft u_char scsi_dev:3; 203 1.1 mycroft u_char :5; 204 1.1 mycroft } reply; 205 1.1 mycroft }; 206 1.1 mycroft 207 1.1 mycroft struct bha_toggle { 208 1.1 mycroft struct { 209 1.1 mycroft u_char opcode; 210 1.1 mycroft u_char enable; 211 1.1 mycroft } cmd; 212 1.1 mycroft }; 213 1.1 mycroft 214 1.1 mycroft struct bha_mailbox { 215 1.1 mycroft struct { 216 1.1 mycroft u_char opcode; 217 1.1 mycroft u_char nmbx; 218 1.1 mycroft physaddr addr; 219 1.1 mycroft } cmd; 220 1.1 mycroft }; 221 1.1 mycroft 222 1.1 mycroft struct bha_model { 223 1.1 mycroft struct { 224 1.1 mycroft u_char opcode; 225 1.1 mycroft u_char len; 226 1.1 mycroft } cmd; 227 1.1 mycroft struct { 228 1.1 mycroft u_char id[4]; /* i.e bt742a -> '7','4','2','A' */ 229 1.1 mycroft u_char version[2]; /* i.e Board Revision 'H' -> 'H', 0x00 */ 230 1.1 mycroft } reply; 231 1.1 mycroft }; 232 1.1 mycroft 233 1.1 mycroft struct bha_revision { 234 1.1 mycroft struct { 235 1.1 mycroft u_char opcode; 236 1.1 mycroft } cmd; 237 1.1 mycroft struct { 238 1.1 mycroft u_char board_type; 239 1.1 mycroft u_char custom_feature; 240 1.1 mycroft char firm_revision; 241 1.1 mycroft u_char firm_version; 242 1.1 mycroft } reply; 243 1.1 mycroft }; 244 1.1 mycroft 245 1.1 mycroft struct bha_digit { 246 1.1 mycroft struct { 247 1.1 mycroft u_char opcode; 248 1.1 mycroft } cmd; 249 1.1 mycroft struct { 250 1.1 mycroft u_char digit; 251 1.1 mycroft } reply; 252 1.1 mycroft }; 253 1.1 mycroft 254 1.1 mycroft struct bha_devices { 255 1.1 mycroft struct { 256 1.1 mycroft u_char opcode; 257 1.1 mycroft } cmd; 258 1.1 mycroft struct { 259 1.1 mycroft u_char junk[8]; 260 1.1 mycroft } reply; 261 1.1 mycroft }; 262 1.1 mycroft 263 1.1 mycroft struct bha_setup { 264 1.1 mycroft struct { 265 1.1 mycroft u_char opcode; 266 1.1 mycroft u_char len; 267 1.1 mycroft } cmd; 268 1.1 mycroft struct { 269 1.1 mycroft u_char sync_neg:1; 270 1.1 mycroft u_char parity:1; 271 1.1 mycroft u_char :6; 272 1.1 mycroft u_char speed; 273 1.1 mycroft u_char bus_on; 274 1.1 mycroft u_char bus_off; 275 1.1 mycroft u_char num_mbx; 276 1.1 mycroft u_char mbx[3]; /*XXX */ 277 1.1 mycroft /* doesn't make sense with 32bit addresses */ 278 1.1 mycroft struct { 279 1.1 mycroft u_char offset:4; 280 1.1 mycroft u_char period:3; 281 1.1 mycroft u_char valid:1; 282 1.1 mycroft } sync[8]; 283 1.1 mycroft u_char disc_sts; 284 1.1 mycroft } reply; 285 1.1 mycroft }; 286 1.1 mycroft 287 1.1 mycroft struct bha_period { 288 1.1 mycroft struct { 289 1.1 mycroft u_char opcode; 290 1.1 mycroft u_char len; 291 1.1 mycroft } cmd; 292 1.1 mycroft struct { 293 1.1 mycroft u_char period[8]; 294 1.1 mycroft } reply; 295 1.1 mycroft }; 296 1.1 mycroft 297 1.1 mycroft #define INT9 0x01 298 1.1 mycroft #define INT10 0x02 299 1.1 mycroft #define INT11 0x04 300 1.1 mycroft #define INT12 0x08 301 1.1 mycroft #define INT14 0x20 302 1.1 mycroft #define INT15 0x40 303 1.1 mycroft 304 1.1 mycroft #define EISADMA 0x00 305 1.1 mycroft #define CHAN0 0x01 306 1.1 mycroft #define CHAN5 0x20 307 1.1 mycroft #define CHAN6 0x40 308 1.1 mycroft #define CHAN7 0x80 309