|
|
1.1 ! root 1: /* @(#)scsi.h 1.1 86/02/03 SMI */ ! 2: ! 3: /* ! 4: * Copyright (c) 1983 by Sun Microsystems, Inc. ! 5: */ ! 6: ! 7: /* ! 8: * Standard SCSI control blocks. ! 9: * These go in or out over the SCSI bus. ! 10: */ ! 11: struct scsi_cdb { /* scsi command description block */ ! 12: u_char cmd; /* command code */ ! 13: u_char lun : 3; /* logical unit number */ ! 14: u_char high_addr : 5; /* high part of address */ ! 15: u_char mid_addr; /* middle part of address */ ! 16: u_char low_addr; /* low part of address */ ! 17: u_char count; /* block count */ ! 18: u_char vu_57 : 1; /* vendor unique (byte 5 bit 7) */ ! 19: u_char vu_56 : 1; /* vendor unique (byte 5 bit 6) */ ! 20: u_char : 4; /* reserved */ ! 21: u_char fr : 1; /* flag request (interrupt at completion) */ ! 22: u_char link : 1; /* link (another command follows) */ ! 23: }; ! 24: ! 25: /* ! 26: * defines for SCSI tape cdb. ! 27: */ ! 28: #define t_code high_addr ! 29: #define high_count mid_addr ! 30: #define mid_count low_addr ! 31: #define low_count count ! 32: ! 33: struct scsi_scb { /* scsi status completion block */ ! 34: /* byte 0 */ ! 35: u_char ext_st1 : 1; /* extended status (next byte valid) */ ! 36: u_char vu_06 : 1; /* vendor unique */ ! 37: u_char vu_05 : 1; /* vendor unique */ ! 38: u_char is : 1; /* intermediate status sent */ ! 39: u_char busy : 1; /* device busy or reserved */ ! 40: u_char cm : 1; /* condition met */ ! 41: u_char chk : 1; /* check condition: sense data available */ ! 42: u_char vu_00 : 1; /* vendor unique */ ! 43: /* byte 1 */ ! 44: u_char ext_st2 : 1; /* extended status (next byte valid) */ ! 45: u_char reserved: 6; /* reserved */ ! 46: u_char ha_er : 1; /* host adapter detected error */ ! 47: /* byte 2 */ ! 48: u_char byte2; /* third byte */ ! 49: }; ! 50: ! 51: struct scsi_sense { /* scsi sense for error classes 0-6 */ ! 52: u_char adr_val : 1; /* sense data is valid */ ! 53: u_char class : 3; /* error class (0-6) */ ! 54: u_char code : 4; /* error code */ ! 55: u_char high_addr; /* high byte of block addr */ ! 56: u_char mid_addr; /* middle byte of block addr */ ! 57: u_char low_addr; /* low byte of block addr */ ! 58: u_char extra[12]; /* pad this struct so it can hold max num */ ! 59: /* of sense bytes we may receive */ ! 60: }; ! 61: ! 62: struct scsi_ext_sense { /* scsi extended sense for error class 7 */ ! 63: /* byte 0 */ ! 64: u_char adr_val : 1; /* sense data is valid */ ! 65: u_char : 7; /* fixed at binary 1110000 */ ! 66: u_char seg_num; /* segment number, applies to copy cmd only */ ! 67: /* byte 2 */ ! 68: u_char fil_mk : 1; /* file mark on device */ ! 69: u_char eom : 1; /* end of media */ ! 70: u_char ili : 1; /* incorrect length indicator */ ! 71: u_char : 1; /* reserved */ ! 72: u_char key : 4; /* sense key, see below */ ! 73: u_char info_1; /* information byte 1 */ ! 74: u_char info_2; /* information byte 2 */ ! 75: u_char info_3; /* information byte 3 */ ! 76: u_char info_4; /* information byte 4 */ ! 77: u_char add_len; /* number of additional bytes */ ! 78: /* additional bytes follow, if any */ ! 79: }; ! 80: ! 81: /* ! 82: * Sense key values for extended sense. ! 83: */ ! 84: #define SC_NO_SENSE 0x0 ! 85: #define SC_RECOVERABLE_ERROR 0x1 ! 86: #define SC_NOT_READY 0x2 ! 87: #define SC_MEDIUM_ERROR 0x3 ! 88: #define SC_HARDWARE_ERROR 0x4 ! 89: #define SC_ILLEGAL_REQUEST 0x5 ! 90: #define SC_UNIT_ATTENTION 0x6 ! 91: #define SC_DATA_PROTECT 0x7 ! 92: #define SC_BLANK_CHECK 0x8 ! 93: #define SC_VENDOR_UNIQUE 0x9 ! 94: #define SC_COPY_ABORTED 0xa ! 95: #define SC_ABORT_COMMAND 0xb ! 96: #define SC_EQUAL 0xc ! 97: #define SC_VOLUME_OVERFLOW 0xd ! 98: #define SC_MISCOMPARE 0xe ! 99: #define SC_RESERVED 0xf ! 100: ! 101: /* ! 102: * SCSI Operation codes. ! 103: */ ! 104: #define SC_TEST_UNIT_READY 0x00 ! 105: #define SC_REZERO_UNIT 0x01 ! 106: #define SC_REQUEST_SENSE 0x03 ! 107: #define SC_READ 0x08 ! 108: #define SC_WRITE 0x0a ! 109: #define SC_SEEK 0x0b ! 110: ! 111: /* ! 112: * Messages that SCSI can send. ! 113: */ ! 114: #define SC_COMMAND_COMPLETE 0x00 ! 115: #define SC_SAVE_DATA_PTR 0x02 ! 116: #define SC_RESTORE_PTRS 0x03 ! 117: #define SC_DISCONNECT 0x04 ! 118: #define SC_IDENTIFY 0x80 ! 119: #define SC_DR_IDENTIFY 0xc0 ! 120: ! 121: #define MORE_STATUS 0x80 /* More status flag */ ! 122: #define STATUS_LEN 3 /* Max status len for SCSI */ ! 123: ! 124: #define cdbaddr(cdb, addr) (cdb)->high_addr = (addr) >> 16;\ ! 125: (cdb)->mid_addr = ((addr) >> 8) & 0xFF;\ ! 126: (cdb)->low_addr = (addr) & 0xFF ! 127: ! 128: ! 129: #define NLPART NDKMAP /* number of logical partitions (8) */ ! 130: ! 131: /* ! 132: * SCSI unit block. ! 133: */ ! 134: struct scsi_unit { ! 135: char un_target; /* scsi bus address of controller */ ! 136: char un_lun; /* logical unit number of device */ ! 137: char un_present; /* unit is present */ ! 138: u_char un_scmd; /* special command */ ! 139: u_short un_unit; /* real unit number of device */ ! 140: struct scsi_unit_subr *un_ss; /* scsi device subroutines */ ! 141: struct scsi_ctlr *un_c; /* scsi ctlr */ ! 142: struct mb_device *un_md; /* mb device */ ! 143: struct mb_ctlr *un_mc; /* mb controller */ ! 144: struct buf un_utab; /* queue of requests */ ! 145: struct buf un_sbuf; /* fake buffer for special commands */ ! 146: struct buf un_rbuf; /* buffer for raw i/o */ ! 147: /* current transfer: */ ! 148: u_short un_flags; /* misc flags relating to cur xfer */ ! 149: int un_baddr; /* virtual buffer address */ ! 150: daddr_t un_blkno; /* current block */ ! 151: short un_sec_left; /* sector count for single sectors */ ! 152: short un_cmd; /* command (for cdb) */ ! 153: short un_count; /* num sectors to xfer (for cdb) */ ! 154: int un_dma_addr; /* dma address */ ! 155: u_short un_dma_count; /* byte count expected */ ! 156: short un_retries; /* retry count */ ! 157: short un_restores; /* restore count */ ! 158: char un_wantint; /* expecting interrupt */ ! 159: /* the following save current dma information in case of disconnect */ ! 160: int un_dma_curaddr; /* current addr to start dma to/from */ ! 161: u_short un_dma_curcnt; /* current dma count */ ! 162: u_short un_dma_curdir; /* direction of dma transfer */ ! 163: }; ! 164: ! 165: /* ! 166: * bits in the scsi unit flags field ! 167: */ ! 168: #define SC_UNF_DVMA 0x0001 /* set if cur xfer requires dvma */ ! 169: ! 170: struct scsi_ctlr { ! 171: struct scsi_ha_reg *c_har; /* sc bus registers in i/o space */ ! 172: struct scsi_si_reg *c_sir; /* si scsi ctlr logic regs */ ! 173: struct scsi_cdb c_cdb; /* command description block */ ! 174: struct scsi_scb c_scb; /* status completion block */ ! 175: struct scsi_sense *c_sense; /* sense info on errors */ ! 176: int c_flags; /* misc state flags */ ! 177: struct scsi_unit *c_un; /* scsi unit using the bus */ ! 178: struct scsi_ctlr_subr *c_ss; /* scsi device subroutines */ ! 179: struct udc_table c_udct; /* scsi dma info for Sun3/50 */ ! 180: struct buf *c_disqh; /* ptr to head of disconnect q */ ! 181: struct buf *c_disqt; /* ptr to tail of disconnect q */ ! 182: struct buf *c_flush; /* ptr to last element to flush */ ! 183: }; ! 184: ! 185: /* misc controller flags */ ! 186: #define SCSI_PRESENT 0x0001 /* scsi bus is alive */ ! 187: #define SCSI_ONBOARD 0x0002 /* scsi logic is onboard */ ! 188: #define SCSI_EN_RECON 0x0004 /* reconnect attempts are enabled */ ! 189: #define SCSI_EN_DISCON 0x0008 /* disconnect attempts are enabled */ ! 190: #define SCSI_FLUSH_DISQ 0x0010 /* flush disconnected tasks */ ! 191: #define SCSI_FLUSHING 0x0020 /* flushing in progress */ ! 192: ! 193: /* ! 194: * Unit specific subroutines called from controllers. ! 195: */ ! 196: struct scsi_unit_subr { ! 197: int (*ss_attach)(); ! 198: int (*ss_start)(); ! 199: int (*ss_mkcdb)(); ! 200: int (*ss_intr)(); ! 201: int (*ss_unit_ptr)(); ! 202: char *ss_devname; ! 203: }; ! 204: ! 205: /* ! 206: * Controller specific subroutines called from units. ! 207: */ ! 208: struct scsi_ctlr_subr { ! 209: int (*scs_ustart)(); ! 210: int (*scs_start)(); ! 211: int (*scs_done)(); ! 212: int (*scs_cmd)(); ! 213: int (*scs_getstat)(); ! 214: int (*scs_cmd_wait)(); ! 215: int (*scs_off)(); ! 216: int (*scs_reset)(); ! 217: int (*scs_dmacount)(); ! 218: int (*scs_go)(); ! 219: }; ! 220: ! 221: /* ! 222: * Defines for getting configuration parameters out of mb_device. ! 223: */ ! 224: #define TYPE(flags) (flags) ! 225: #define TARGET(slave) ((slave >> 3) & 07) ! 226: #define LUN(slave) (slave & 07) ! 227: ! 228: #define SCSI_DISK 0 ! 229: #define SCSI_TAPE 1 ! 230: #define SCSI_FLOPPY 2 ! 231: ! 232: #define NUNIT 8 /* max nubmer of units per controller */ ! 233: ! 234: /* ! 235: * SCSI Error codes passed to device routines. ! 236: * The codes refer to SCSI general errors, not to device ! 237: * specific errors. Device specific errors are discovered ! 238: * by checking the sense data. ! 239: * The distinction between retryable and fatal is somewhat ad hoc. ! 240: */ ! 241: #define SE_NO_ERROR 0 ! 242: #define SE_RETRYABLE 1 ! 243: #define SE_FATAL 2 ! 244: ! 245: struct scsi_disk { ! 246: struct dk_map un_map[NLPART]; /* logical partitions */ ! 247: struct dk_geom un_g; /* disk geometry */ ! 248: }; ! 249: ! 250: struct scsi_tape { ! 251: int un_mspl; /* ptr to mode select param list */ ! 252: int un_bufcnt; /* number of buffers in use */ ! 253: int un_next_block; /* next record on tape */ ! 254: int un_last_block; /* last record of file, if known */ ! 255: short un_status; /* status from last sense */ ! 256: short un_retry_ct; /* retry count */ ! 257: short un_underruns; /* number of underruns */ ! 258: char un_openf; /* tape is open */ ! 259: char un_eof; /* eof seen but not sent to user */ ! 260: char un_read_only; /* tape is read only */ ! 261: char un_lastiow; /* last i/o was write */ ! 262: char un_lastior; /* last i/o was read */ ! 263: char un_reten_rewind; /* retension on next rewind */ ! 264: char un_qic; /* qic format */ ! 265: char un_ctype; /* controller type */ ! 266: char un_reset_occurred; /* reset occured since last command */ ! 267: char un_readmode; /* sysgen left in read mode */ ! 268: char un_err_pending; /* illegal cmd error pending */ ! 269: u_char un_last_cmd; /* last scsi command issued */ ! 270: #ifdef sun2 ! 271: char un_cipher_test; /* test for cipher drive in progres */ ! 272: #endif ! 273: }; ! 274: ! 275: struct scsi_floppy { ! 276: u_char sf_flags; ! 277: u_char sf_mdb; /* media descriptor byte */ ! 278: u_char sf_spt; /* sectors per track */ ! 279: u_char sf_nhead; /* number of heads */ ! 280: int sf_nblk; /* number of blocks on the disk */ ! 281: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.