1 /* 2 * Copyright (c) 1992 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc. 7 * 8 * %sccs.include.redist.c% 9 * 10 * from: $Hdr: scsireg.h,v 4.300 91/06/09 06:38:12 root Rel41 $ SONY 11 * 12 * @(#)scsireg.h 7.1 (Berkeley) 06/04/92 13 */ 14 15 /* 16 * scsireg.h 17 */ 18 19 #ifndef __SCSIREG__ 20 #define __SCSIREG__ 1 21 22 #ifdef KERNEL 23 #include "../include/fix_machine_type.h" 24 #else 25 #include "machine/fix_machine_type.h" 26 #endif 27 28 29 /* 30 * initiator status byte bit image 31 */ 32 #define INST_EP 0x80 /* End of Process */ 33 #define INST_WR 0x40 /* Waiting Reselection */ 34 #define INST_IP 0x20 /* In Process */ 35 #define INST_WAIT 0x10 /* Waiting Bus free */ 36 #define INST_LB 0x8 /* Loss of BUSY */ 37 #define INST_TO 0x4 /* Time Out */ 38 #define INST_PRE 0x2 /* PaRameter Error */ 39 #define INST_HE 0x1 /* Hard Error */ 40 41 #define INSTERMASK 0x7 42 43 44 /* 45 * target status byte bit image 46 */ 47 #define VENDOR 0x61 48 #define TGSTMASK 0x1e 49 #define TGST_RSVCFLCT 0x18 50 #define TGST_INTERMED 0x10 51 #define TGST_BUSY 0x8 52 #define TGST_CC 0x2 53 #define TGST_GOOD 0x0 54 55 #define TS_MAPPED_PIO 0x01 /* program I/O with map */ 56 #define TS_CONTR_ON 0x02 /* contiguous transfer on */ 57 #define TS_CONTR_OFF 0x04 /* contiguous transfer off */ 58 #define TS_BYTE_DMA 0x08 /* DMA transfer(byte access) */ 59 #define TS_LONG_DMA 0x10 /* DMA transfer(long access) */ 60 61 62 /* 63 * message byte 64 */ 65 #define MSG_IDENT 0x80 66 #define MSG_RESELEN 0x40 67 #define MSG_CCOMP 0 68 #define MSG_EXTND 1 69 #define MSG_SDP 2 70 #define MSG_RDP 3 71 #define MSG_DCNT 4 72 #define MSG_IDE 5 73 #define MSG_ABORT 6 74 #define MSG_MREJ 7 75 #define MSG_NOP 8 76 #define MSG_PERROR 9 77 78 79 /* 80 * message identify byte bit image 81 */ 82 #define IDT_DISCON 0x40 83 #define IDT_DRMASK 0x7 84 85 86 /* 87 * scsi command opcodes 88 */ 89 #define SCOP_TST 0x00 90 #define SCOP_REZERO 0x01 91 #define SCOP_REWIND 0x01 92 #define SCOP_RSENSE 0x03 93 #define SCOP_FMT 0x04 94 #define SCOP_RBLIM 0x05 95 #define SCOP_SPARAM 0x06 96 #define SCOP_RASBLK 0x07 97 #define SCOP_READ 0x08 98 #define SCOP_MOERASE 0x09 99 #define SCOP_WRITE 0x0a 100 #define SCOP_SEEK 0x0b 101 #define SCOP_MERASE 0x0e 102 #define SCOP_WFMARK 0x10 103 #define SCOP_SPACE 0x11 104 #define SCOP_INQUIRY 0x12 105 #define SCOP_SVERIFY 0x13 106 #define SCOP_RBDATA 0x14 107 #define SCOP_MSELECT 0x15 108 #define SCOP_ERASE 0x19 109 #define SCOP_MSENSE 0x1a 110 #define SCOP_STST 0x1b 111 #define SCOP_LOAD 0x1b 112 #define SCOP_RECDIAG 0x1c 113 #define SCOP_SNDDIAG 0x1d 114 #define SCOP_MEDRMV 0x1e 115 #define SCOP_RCAP 0x25 116 #define SCOP_EREAD 0x28 117 #define SCOP_EWRITE 0x2a 118 #define SCOP_BSSRCH 0x2c 119 #define SCOP_WSSRCH 0x2d 120 #define SCOP_WRTVRFY 0x2e 121 #define SCOP_VERIFY 0x2f 122 #define SCOP_RDL 0x37 123 #define SCOP_WBUF 0x3b 124 #define SCOP_RBUF 0x3c 125 #define SCOP_EJECT 0xc0 126 #define SCOP_EESENSE 0xc1 127 #define SCOP_READTOC 0xc1 128 #define SCOP_READID 0xc2 129 #define SCOP_ADP 0xc2 130 #define SCOP_READQ 0xc2 131 #define SCOP_BLANKS 0xc3 132 #define SCOP_READHEAD 0xc3 133 #define SCOP_PBSTS 0xc4 134 #define SCOP_RCVDISK 0xc4 135 #define SCOP_PAUSE 0xc5 136 #define SCOP_PLAYTRACK 0xc6 137 #define SCOP_PLAYMSF 0xc7 138 #define SCOP_PLAYAUDIO 0xc8 139 #define SCOP_ERASED 0xe7 140 #define SCOP_RESET 0xff 141 142 143 /* 144 * other definition 145 */ 146 #define ON 1 147 #define OFF 0 148 149 150 /* 151 * scsi internal parameter block 152 */ 153 struct scsi { 154 /*00*/ u_char sc_istatus; 155 /*01*/ u_char sc_tstatus; 156 /*02*/ u_char sc_identify; 157 /*03*/ u_char sc_message; 158 /*04*/ u_int sc_mpages; 159 /*08*/ u_int sc_bytesec; 160 /*0c*/ u_char *sc_cpoint; 161 /*10*/ u_int sc_ctrnscnt; 162 /*14*/ struct sc_map *sc_map; 163 union { 164 struct un_type0 { 165 /*18*/ u_int t0_opcode : 8; 166 /*19*/ u_int t0_lun : 3; 167 /*19*/ u_int t0_lad : 21; 168 /*1c*/ u_char t0_count; 169 /*1d*/ u_char t0_ctrl; 170 /*1e*/ 171 } un_type0; 172 struct un_tuio { 173 /*18*/ u_char tu_opcode; 174 /*19*/ u_char tu_lun : 3; 175 /*19*/ u_char tu_resved : 3; 176 /*19*/ u_char tu_code : 2; 177 /*1a*/ u_char tu_count1; 178 /*1b*/ u_char tu_count2; 179 /*1c*/ u_char tu_count3; 180 /*1d*/ u_char tu_ctrl; 181 /*1e*/ 182 } un_tuio; 183 struct un_mtio { 184 /*18*/ u_char mt_opcode; 185 /*19*/ u_char mt_lun : 3; 186 /*19*/ u_char mt_resvd : 2; 187 /*19*/ u_char mt_st : 1; 188 /*19*/ u_char mt_code : 2; 189 /*1a*/ u_char mt_len1; 190 /*1b*/ u_char mt_len2; 191 /*1c*/ u_char mt_len3; 192 /*1d*/ u_char mt_ctrl; 193 /*1e*/ 194 } un_mtio; 195 struct un_type1 { 196 /*18*/ u_char t1_opcode; 197 /*19*/ u_char t1_lun : 3; 198 /*19*/ u_char t1_rsvd : 4; 199 /*19*/ u_char t1_relat : 1; 200 /*1a*/ u_short t1_ladhi; 201 /*1c*/ u_short t1_ladlo; 202 /*1e*/ u_char t1_p1; 203 /*1f*/ u_char t1_p2; 204 /*20*/ u_char t1_p3; 205 /*21*/ u_char t1_ctrl; 206 /*22*/ 207 } un_type1; 208 /*18*/ u_char un_reserved[12]; 209 /*24*/ 210 } sc_cdb; 211 /*24*/ u_char sc_param[20]; 212 /*38*/ int sc_hbinfo; /* Copy of the hb_ctlr->hm_hbinfo */ 213 /*3c*/ u_int sc_ctag; 214 /*40*/ u_int sc_coffset; 215 /*44*/ 216 }; 217 218 219 #define sc_opcode sc_cdb.un_type0.t0_opcode 220 #define sc_lun sc_cdb.un_type0.t0_lun 221 #define sc_lad sc_cdb.un_type0.t0_lad 222 #define sc_count sc_cdb.un_type0.t0_count 223 #define sc_nsect sc_cdb.un_type0.t0_count 224 #define sc_switch sc_cdb.un_type0.t0_count 225 #define sc_ctrl sc_cdb.un_type0.t0_ctrl 226 227 #define sc_tucode sc_cdb.un_tuio.tu_code 228 #define sc_tucount1 sc_cdb.un_tuio.tu_count1 229 #define sc_tucount2 sc_cdb.un_tuio.tu_count2 230 #define sc_tucount3 sc_cdb.un_tuio.tu_count3 231 #define sc_tunsect1 sc_cdb.un_tuio.tu_count1 232 #define sc_tunsect2 sc_cdb.un_tuio.tu_count2 233 #define sc_tunsect3 sc_cdb.un_tuio.tu_count3 234 235 #define sc_mtst sc_cdb.un_mtio.mt_st 236 #define sc_mtcode sc_cdb.un_mtio.mt_code 237 #define sc_mtlen1 sc_cdb.un_mtio.mt_len1 238 #define sc_mtlen2 sc_cdb.un_mtio.mt_len2 239 #define sc_mtlen3 sc_cdb.un_mtio.mt_len3 240 #define sc_mtcount1 sc_cdb.un_mtio.mt_len1 241 #define sc_mtcount2 sc_cdb.un_mtio.mt_len2 242 #define sc_mtcount3 sc_cdb.un_mtio.mt_len3 243 #define sc_mtnsect1 sc_cdb.un_mtio.mt_len1 244 #define sc_mtnsect2 sc_cdb.un_mtio.mt_len2 245 #define sc_mtnsect3 sc_cdb.un_mtio.mt_len3 246 #define sc_mtctrl sc_cdb.un_mtio.mt_ctrl 247 #define sc_mtfxd sc_mtcode 248 #define sc_mtimm sc_mtcode 249 #define sc_mtlng sc_mtcode 250 251 #define sc_ladhi sc_cdb.un_type1.t1_ladhi 252 #define sc_ladlo sc_cdb.un_type1.t1_ladlo 253 #define sc_pmi sc_cdb.un_type1.t1_p3 254 255 #define scop_load(a,b,c,d,e) scop_stst(a,b,c,d,e) 256 257 258 /* 259 * tape unit space operation code definitions 260 */ 261 #define SCSC_DATA 0 262 #define SCSC_FM 1 263 #define SCSC_SQFM 2 264 #define SCSC_EOD 3 265 266 267 /* 268 * scsi map table format 269 */ 270 #if defined(news800) || defined(news1800) 271 #define NSCMAP 510 272 #endif /* defined(news800) || defined(news1800) */ 273 274 #if defined(news1200) || defined(news1700) 275 #define NSCMAP 129 276 #endif /* news1200 || news1700 */ 277 278 #ifdef news3400 279 #define NSCMAP 120 280 #endif /* news3400 */ 281 282 #ifdef news3800 283 #define NSCMAP 129 284 #endif /* news3800 */ 285 286 struct sc_map { 287 /*000*/ unsigned mp_offset; 288 /*004*/ unsigned mp_pages; 289 /*008*/ unsigned mp_addr[NSCMAP]; 290 #if defined(news800) || defined(news1800) 291 /*800*/ 292 #endif /* defined(news800) || defined(news1800) */ 293 #if defined(news1200) || defined(news1700) 294 /*20c*/ 295 #endif /* news1200 || news1700 */ 296 }; 297 298 299 /* 300 * scsi nonextended sense data 301 */ 302 struct sc_nextnd { 303 /*00*/ u_int scn_advalid : 1; 304 /*00*/ u_int scn_ecode : 7; 305 /*01*/ u_int scn_resvd : 3; 306 /*01*/ u_int scn_secno : 21; 307 /*04*/ 308 }; 309 310 311 /* 312 * scsi extended sense data 313 */ 314 struct sc_extnd { 315 /*00*/ u_char sce_advalid : 1; 316 /*00*/ u_char sce_extend : 7; 317 /*01*/ u_char sce_segno; 318 /*02*/ u_char sce_fm : 1; 319 /*02*/ u_char sce_eom : 1; 320 /*02*/ u_char sce_ili : 1; 321 /*02*/ u_char sce_resvd : 1; 322 /*02*/ u_char sce_skey : 4; 323 /*03*/ u_char sce_infob1; 324 /*04*/ u_char sce_infob2; 325 /*05*/ u_char sce_infob3; 326 /*06*/ u_char sce_infob4; 327 /*07*/ u_char sce_addlen; 328 union { 329 struct un_ehd { 330 /*08*/ u_short ehd_resvd1; 331 /*0a*/ u_short ehd_resvd2; 332 /*0c*/ u_char ehd_ecode; 333 /*0d*/ u_char ehd_resvd3; 334 /*0e*/ u_char ehd_fru; 335 /*0f*/ u_char ehd_fpv : 1; 336 /*0f*/ u_char ehd_cd : 1; 337 /*0f*/ u_char ehd_resvd4 : 2; 338 /*0f*/ u_char ehd_bpv : 1; 339 /*0f*/ u_char ehd_bitpnt : 3; 340 /*10*/ u_short ehd_fldpnt; 341 /*12*/ 342 } un_ehd; 343 struct un_etu { 344 /*08*/ u_char etu_ecode; 345 /*09*/ u_char etu_nerrhi; 346 /*0a*/ u_char etu_nerrlo; 347 /*0b*/ 348 } un_etu; 349 struct un_emt { 350 /*08*/ u_short emt_estat; 351 /*0a*/ u_char emt_resvd1; 352 /*0b*/ u_char emt_totlrtry; 353 /*0c*/ u_short emt_resvd2; 354 /*0e*/ u_short emt_resvd3; 355 /*10*/ u_char emt_resvd4; 356 /*11*/ u_char emt_ecode; 357 /*12*/ 358 } un_emt; 359 struct un_ewo { 360 /*08*/ u_char ewo_resvd1; 361 /*09*/ u_char ewo_resvd2; 362 /*0a*/ u_char ewo_resvd3; 363 /*0b*/ u_char ewo_sadvalid : 1; 364 /*0b*/ u_char ewo_secode : 7; 365 /*0c*/ u_char ewo_saddr1; 366 /*0d*/ u_char ewo_saddr2; 367 /*0e*/ u_char ewo_saddr3; 368 /*0f*/ u_char ewo_saddr4; 369 /*10*/ u_char ewo_resvd4; 370 /*11*/ u_char ewo_dadvalid : 1; 371 /*11*/ u_char ewo_decode : 7; 372 /*12*/ u_char ewo_daddr1; 373 /*13*/ u_char ewo_daddr2; 374 /*14*/ u_char ewo_daddr3; 375 /*15*/ u_char ewo_daddr4; 376 /*16*/ 377 } un_ewo; 378 struct un_eod { 379 /*08*/ u_char eod_resvd1; 380 /*09*/ u_char eod_resvd2; 381 /*0a*/ u_char eod_resvd3; 382 /*0b*/ u_char eod_resvd4; 383 /*0c*/ u_char eod_ecode; 384 /*0d*/ u_char eod_resvd5; 385 /*0e*/ u_char eod_resvd6; 386 /*0f*/ u_char eod_resvd7; 387 /*10*/ u_char eod_resvd8; 388 /*11*/ u_char eod_resvd9; 389 /*12*/ 390 } un_eod; 391 /*08*/ u_char un_data[24]; 392 /*20*/ 393 } sce_add; 394 /*20*/ 395 }; 396 397 #define sce_hdecode sce_add.un_ehd.ehd_ecode 398 399 #define sce_tuecode sce_add.un_etu.etu_ecode 400 #define sce_tunerrhi sce_add.un_etu.etu_nerrhi 401 #define sce_tunerrlo sce_add.un_etu.etu_nerrlo 402 403 #define sce_mtestat sce_add.un_emt.emt_estat 404 #define sce_mtecode sce_add.un_emt.emt_ecode 405 406 #define sce_odecode sce_add.un_eod.eod_ecode 407 408 #define sce_ascq sce_add.un_ehd.ehd_resvd3 409 #define sce_sksv sce_add.un_ehd.ehd_fpv 410 #define sce_actretry sce_add.un_ehd.ehd_fldpnt 411 412 /* 413 * scsi inquiry response data 414 */ 415 struct sc_inq { 416 /*00*/ u_char sci_devtype; 417 /*01*/ u_char sci_qual; 418 /*02*/ u_char sci_version; 419 /*03*/ u_char sci_resvd1; 420 /*04*/ u_char sci_ninfo; 421 /*05*/ u_char sci_drinfo; 422 /*06*/ u_char sci_firmrev; 423 /*07*/ u_char sci_ready; 424 /*08*/ u_char sci_vendid[8]; 425 /*10*/ u_char sci_prodid[16]; 426 /*20*/ u_char sci_revision[4]; 427 /*24*/ 428 }; 429 430 431 /* 432 * scsi read capacity data 433 */ 434 struct sc_rcap { 435 /*00*/ u_int scr_nblock; 436 /*04*/ u_int scr_blocklen; 437 /*08*/ 438 }; 439 440 441 /* 442 * scsi mode sense/select data 443 */ 444 struct sc_mdata { 445 /*00*/ u_char scm_len; 446 /*01*/ u_char scm_type; 447 /*02*/ u_char scm_flags1; 448 /*03*/ u_char scm_dlen; 449 /*04*/ u_int scm_dens : 8; 450 /*05*/ u_int scm_nblock : 24; 451 /*08*/ u_int scm_resvd1 : 8; 452 /*09*/ u_int scm_bsize : 24; 453 /*0c*/ u_char scm_flags2; 454 /*0d*/ u_char scm_resvd2; 455 /*0e*/ u_char scm_resvd3; 456 /*0f*/ u_char scm_maxrtry; 457 /*10*/ 458 }; 459 460 #define scm_tdens scm_flags2 461 462 463 /* 464 * bits of scm_flags1 465 */ 466 #define SCM1_WRP 0x80 467 #define SCM1_BUFM 0x10 468 #define SCM1_SPD90 0x02 469 470 471 /* 472 * scm_type 473 */ 474 #define SCMT_DEFAULT 0x0 475 #define SCMT_150_600 0x80 476 #define SCMT_300_450 0x81 477 478 479 /* 480 * scm_dens 481 */ 482 #define SCMD_QIC_24_9 0x0 /* This may be 0x5 */ 483 #define SCMD_QIC_11_4 0x4 484 #define SCMD_QIC_11_9 0x84 485 #define SCMD_QIC_120_15 0xf 486 #define SCMD_QIC_150_18 0x10 487 488 #define SCMD_DEFAULT 0x00 489 #define SCMD_800_BPI 0x01 490 #define SCMD_1600_BPI 0x02 491 #define SCMD_6250_BPI 0x03 492 #define SCMD_3200_BPI 0x06 493 #define SCMD_NEWTAPE 0x80 494 #define SCMD_NOTAPE 0xff 495 496 497 /* 498 * bits of scm_flags2 499 */ 500 #define SCM2_DEA 0x04 501 #define SCM2_AUI 0x02 502 #define SCM2_SEC 0x01 503 504 505 /* 506 * scsi reassign block perameter list 507 */ 508 struct sc_rab { 509 /*00*/ u_short sca_resved; 510 /*02*/ u_short sca_dllen; 511 /*04*/ u_int sca_dlad[4]; 512 /*14*/ 513 }; 514 515 516 #ifdef CPU_DOUBLE 517 518 # ifdef mips 519 # define ipc_phys(x) (caddr_t)K0_TT0(x) 520 # else 521 # define ipc_phys(x) (caddr_t)((int)(x) & ~0x80000000) 522 # endif 523 524 # ifdef news800 525 # define splsc spl3 526 # define splscon spl2 527 # endif 528 529 # ifdef news1800 530 # define splsc spl5 531 # define splscon spl4 532 # endif 533 534 # ifdef news3800 535 # define splsc spl4 536 # define splscon spl3 537 # endif 538 539 #endif /* CPU_DOUBLE */ 540 541 #ifdef CPU_SINGLE 542 # define ipc_phys(x) (caddr_t)(x) 543 # ifdef news3400 544 # define splsc spl3 545 # define splscon spl2 546 # else 547 # define splsc spl4 548 # define splscon spl3 549 # endif 550 #endif /* CPU_SINGLE */ 551 552 #define SCSI_INTEN 1 553 #define SCSI_INTDIS 0 554 555 556 struct scintsw { 557 /*00*/ int (*sci_inthandler)(); /* pointer to interrupt handler */ 558 /*04*/ int sci_ctlr; /* controller number */ 559 /*08*/ 560 }; 561 562 563 struct sc_data { 564 /*00*/ caddr_t scd_scaddr; /* pointer to struct scsi */ 565 /*04*/ caddr_t scd_vaddr; /* pointer to buffer address */ 566 /*08*/ int scd_count; /* buffer size */ 567 /*0c*/ int scd_rw; /* R/W flag see buf.h */ 568 /*10*/ struct proc *scd_procp; /* user prrocess */ 569 /*14*/ 570 }; 571 572 #endif /* !__SCSIREG__ */ 573