|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1988 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * This code is derived from software contributed to Berkeley by ! 6: * Chris Torek. ! 7: * ! 8: * Redistribution is only permitted until one year after the first shipment ! 9: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and ! 10: * binary forms are permitted provided that: (1) source distributions retain ! 11: * this entire copyright notice and comment, and (2) distributions including ! 12: * binaries display the following acknowledgement: This product includes ! 13: * software developed by the University of California, Berkeley and its ! 14: * contributors'' in the documentation or other materials provided with the ! 15: * distribution and in all advertising materials mentioning features or use ! 16: * of this software. Neither the name of the University nor the names of ! 17: * its contributors may be used to endorse or promote products derived from ! 18: * this software without specific prior written permission. ! 19: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 20: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 21: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 22: * ! 23: * @(#)mscp.h 7.5 (Berkeley) 6/28/90 ! 24: */ ! 25: ! 26: /* ! 27: * Definitions for the Mass Storage Control Protocol ! 28: * I WISH I KNEW WHAT MORE OF THESE WERE. IT SURE WOULD BE NICE ! 29: * IF DEC SOLD DOCUMENTATION FOR THEIR OWN CONTROLLERS. ! 30: */ ! 31: ! 32: /* ! 33: * Control message opcodes ! 34: */ ! 35: #define M_OP_ABORT 0x01 /* Abort command */ ! 36: #define M_OP_GETCMDST 0x02 /* Get command status command */ ! 37: #define M_OP_GETUNITST 0x03 /* Get unit status command */ ! 38: #define M_OP_SETCTLRC 0x04 /* Set controller characteristics command */ ! 39: #define M_OP_SEREX 0x07 /* Serious exception end message */ ! 40: #define M_OP_AVAILABLE 0x08 /* Available command */ ! 41: #define M_OP_ONLINE 0x09 /* Online command */ ! 42: #define M_OP_SETUNITC 0x0a /* Set unit characteristics command */ ! 43: #define M_OP_DTACCPATH 0x0b /* Determine access paths command */ ! 44: #define M_OP_ACCESS 0x10 /* Access command */ ! 45: #define M_OP_COMPCD 0x11 /* Compare controller data command */ ! 46: #define M_OP_ERASE 0x12 /* Erase command */ ! 47: #define M_OP_FLUSH 0x13 /* Flush command */ ! 48: #define M_OP_REPLACE 0x14 /* Replace command */ ! 49: #define M_OP_COMPHD 0x20 /* Compare host data command */ ! 50: #define M_OP_READ 0x21 /* Read command */ ! 51: #define M_OP_WRITE 0x22 /* Write command */ ! 52: #define M_OP_AVAILATTN 0x40 /* Available attention message */ ! 53: #define M_OP_DUPUNIT 0x41 /* Duplicate unit number attention message */ ! 54: #define M_OP_ACCPATH 0x42 /* Access path attention message */ ! 55: #define M_OP_END 0x80 /* End message flag */ ! 56: ! 57: ! 58: /* ! 59: * Generic command modifiers ! 60: */ ! 61: #define M_MD_EXPRS 0x8000 /* Express request */ ! 62: #define M_MD_COMP 0x4000 /* Compare */ ! 63: #define M_MD_CLSEX 0x2000 /* Clear serious exception */ ! 64: #define M_MD_ERROR 0x1000 /* Force error */ ! 65: #define M_MD_SCCHH 0x0800 /* Suppress caching (high speed) */ ! 66: #define M_MD_SCCHL 0x0400 /* Suppress caching (low speed) */ ! 67: #define M_MD_SECOR 0x0200 /* Suppress error correction */ ! 68: #define M_MD_SEREC 0x0100 /* Suppress error recovery */ ! 69: #define M_MD_SSHDW 0x0080 /* Suppress shadowing */ ! 70: #define M_MD_WBKNV 0x0040 /* Write back (non-volatile) */ ! 71: #define M_MD_WBKVL 0x0020 /* Write back (volatile) */ ! 72: #define M_MD_WRSEQ 0x0010 /* Write shadow set one unit at a time */ ! 73: ! 74: /* ! 75: * AVAILABLE command modifiers ! 76: */ ! 77: #define M_AVM_ALLCD 0x0002 /* All class drivers */ ! 78: #define M_AVM_SPINDOWN 0x0001 /* Spin down */ ! 79: ! 80: /* ! 81: * FLUSH command modifiers ! 82: */ ! 83: #define M_FLM_FLUSHENU 0x0001 /* Flush entire unit */ ! 84: #define M_FLM_VOLATILE 0x0002 /* Volatile only */ ! 85: ! 86: /* ! 87: * GET UNIT STATUS command modifiers ! 88: */ ! 89: #define M_GUM_NEXTUNIT 0x0001 /* Next unit */ ! 90: ! 91: /* ! 92: * ONLINE command modifiers ! 93: */ ! 94: #define M_OLM_RIP 0x0001 /* Allow self destruction */ ! 95: #define M_OLM_IGNMF 0x0002 /* Ignore media format error */ ! 96: ! 97: /* ! 98: * ONLINE and SET UNIT CHARACTERISTICS command modifiers ! 99: */ ! 100: #define M_OSM_ALTERHI 0x0020 /* Alter host identifier */ ! 101: #define M_OSM_SHADOWSP 0x0010 /* Shadow unit specified */ ! 102: #define M_OSM_CLEARWBL 0x0008 /* Clear write-back data lost */ ! 103: #define M_OSM_SETWRPROT 0x0004 /* Set write protect */ ! 104: ! 105: /* ! 106: * REPLACE command modifiers ! 107: */ ! 108: #define M_RPM_PRIMARY 0x0001 /* Primary replacement block */ ! 109: ! 110: /* ! 111: * End message flags ! 112: */ ! 113: #define M_EF_BBLKR 0x80 /* Bad block reported */ ! 114: #define M_EF_BBLKU 0x40 /* Bad block unreported */ ! 115: #define M_EF_ERLOG 0x20 /* Error log generated */ ! 116: #define M_EF_SEREX 0x10 /* Serious exception */ ! 117: ! 118: /* ! 119: * Controller flags ! 120: */ ! 121: #define M_CF_ATTN 0x80 /* Enable attention messages */ ! 122: #define M_CF_MISC 0x40 /* Enable miscellaneous error log messages */ ! 123: #define M_CF_OTHER 0x20 /* Enable other host's error log messages */ ! 124: #define M_CF_THIS 0x10 /* Enable this host's error log messages */ ! 125: #define M_CF_MLTHS 0x04 /* Multi-host */ ! 126: #define M_CF_SHADW 0x02 /* Shadowing */ ! 127: #define M_CF_576 0x01 /* 576 byte sectors */ ! 128: ! 129: /* ! 130: * Unit flags ! 131: */ ! 132: #define M_UF_REPLC 0x8000 /* Controller initiated bad block replacement */ ! 133: #define M_UF_INACT 0x4000 /* Inactive shadow set unit */ ! 134: #define M_UF_WRTPH 0x2000 /* Write protect (hardware) */ ! 135: #define M_UF_WRTPS 0x1000 /* Write protect (software or volume) */ ! 136: #define M_UF_SCCHH 0x8000 /* Suppress caching (high speed) */ ! 137: #define M_UF_SCCHL 0x4000 /* Suppress caching (low speed) */ ! 138: #define M_UF_RMVBL 0x0080 /* Removable media */ ! 139: #define M_UF_WBKNV 0x0040 /* Write back (non-volatile) */ ! 140: #define M_UF_576 0x0004 /* 576 byte sectors */ ! 141: #define M_UF_CMPWR 0x0002 /* Compare writes */ ! 142: #define M_UF_CMPRD 0x0001 /* Compare reads */ ! 143: ! 144: /* ! 145: * Error Log message format codes ! 146: */ ! 147: #define M_FM_CTLRERR 0x00 /* Controller error */ ! 148: #define M_FM_BUSADDR 0x01 /* Host memory access error */ ! 149: #define M_FM_DISKTRN 0x02 /* Disk transfer error */ ! 150: #define M_FM_SDI 0x03 /* SDI error */ ! 151: #define M_FM_SMLDSK 0x04 /* Small disk error */ ! 152: ! 153: /* ! 154: * Error Log message flags ! 155: */ ! 156: #define M_LF_SUCC 0x80 /* Operation successful */ ! 157: #define M_LF_CONT 0x40 /* Operation continuing */ ! 158: #define M_LF_SQNRS 0x01 /* Sequence number reset */ ! 159: ! 160: /* ! 161: * Status codes ! 162: */ ! 163: #define M_ST_MASK 0x1f /* Status code mask */ ! 164: #define M_ST_SUCCESS 0x00 /* Success */ ! 165: #define M_ST_INVALCMD 0x01 /* Invalid command */ ! 166: #define M_ST_ABORTED 0x02 /* Command aborted */ ! 167: #define M_ST_OFFLINE 0x03 /* Unit offline */ ! 168: #define M_ST_AVAILABLE 0x04 /* Unit available */ ! 169: #define M_ST_MFMTERR 0x05 /* Media format error */ ! 170: #define M_ST_WRPROT 0x06 /* Write protected */ ! 171: #define M_ST_COMPERR 0x07 /* Compare error */ ! 172: #define M_ST_DATAERR 0x08 /* Data error */ ! 173: #define M_ST_HOSTBUFERR 0x09 /* Host buffer access error */ ! 174: #define M_ST_CTLRERR 0x0a /* Controller error */ ! 175: #define M_ST_DRIVEERR 0x0b /* Drive error */ ! 176: #define M_ST_DIAG 0x1f /* Message from an internal diagnostic */ ! 177: ! 178: /* ! 179: * Subcodes of M_ST_OFFLINE ! 180: */ ! 181: #define M_OFFLINE_UNKNOWN (0 << 5) /* unknown or on other ctlr */ ! 182: #define M_OFFLINE_UNMOUNTED (1 << 5) /* unmounted or RUN/STOP at STOP */ ! 183: #define M_OFFLINE_INOPERATIVE (2 << 5) /* inoperative? */ ! 184: #define M_OFFLINE_DUPLICATE (4 << 5) /* duplicate unit number */ ! 185: #define M_OFFLINE_INDIAGNOSTIC (8 << 5) /* disabled by FS or diagnostic */ ! 186: ! 187: /* ! 188: * An MSCP packet begins with a header giving the length of ! 189: * the entire packet (including the header itself)(?), two bytes ! 190: * of device specific data, and the a whole bunch of variants ! 191: * depending on message type. ! 192: * ! 193: * N.B.: In most cases we distinguish between a `command' and ! 194: * an `end' variant as well. The command variant is that which ! 195: * is given to the controller; the `end' variant is its response. ! 196: */ ! 197: ! 198: /* ! 199: * Generic sequential message variant (command and response). ! 200: */ ! 201: struct mscpv_seq { ! 202: long seq_bytecount; /* byte count */ ! 203: #define seq_rbn seq_bytecount /* aka RBN (replace) */ ! 204: #define seq_outref seq_bytecount /* aka outref (abort/get cmd status) */ ! 205: long seq_buffer; /* buffer descriptor */ ! 206: long seq_mapbase; /* page map (first PTE) phys address */ ! 207: long seq_xxx1; /* ? */ /* unused */ ! 208: long seq_lbn; /* logical block number */ ! 209: long seq_xxx2; /* ? */ /* unused */ ! 210: long *seq_addr; /* pointer to cmd descriptor */ ! 211: long seq_software[4]; /* reserved to software; unused */ ! 212: }; ! 213: ! 214: /* ! 215: * Set Controller Characteristics command variant ! 216: */ ! 217: struct mscpv_sccc { ! 218: u_short sccc_version; /* MSCP version number */ ! 219: u_short sccc_ctlrflags; /* controller flags */ ! 220: u_short sccc_hosttimo; /* host timeout */ ! 221: u_short sccc_usefrac; /* use fraction */ ! 222: long sccc_time; /* time and date */ ! 223: long sccc_xxx1; /* ? */ ! 224: long sccc_errlgfl; /* ? */ ! 225: short sccc_xxx2; /* ? */ ! 226: short sccc_copyspd; /* ? */ ! 227: }; ! 228: ! 229: /* ! 230: * Set Controller Characteristics end variant ! 231: */ ! 232: struct mscpv_scce { ! 233: u_short scce_version; /* MSCP version number */ ! 234: u_short scce_ctlrflags; /* controller flags */ ! 235: u_short scce_ctlrtimo; /* controller timeout */ ! 236: u_short scce_ctlrcmdl; /* ??? */ ! 237: quad scce_ctlrid; /* controller ID */ ! 238: long scce_xxx[3]; /* ? */ ! 239: long scce_volser; /* volume serial number */ ! 240: }; ! 241: ! 242: /* ! 243: * On Line command variant ! 244: */ ! 245: struct mscpv_onlc { ! 246: long onlc_xxx1[4]; /* ? */ ! 247: long onlc_errlgfl; /* error log flag? */ ! 248: short onlc_xxx2; /* ? */ ! 249: short onlc_copyspd; /* copy speed? */ ! 250: }; ! 251: ! 252: /* ! 253: * On Line end variant ! 254: */ ! 255: struct mscpv_onle { ! 256: long onle_xxx1[3]; /* ? */ ! 257: /*???*/ short onle_xxx2; /* ? */ ! 258: u_char onle_drivetype; /* drive type index (same in guse) */ ! 259: char onle_xxx3; /* ? */ ! 260: long onle_mediaid; /* media type id (same in guse) */ ! 261: long onle_xxx4; /* ? */ ! 262: long onle_unitsize; /* unit size in sectors */ ! 263: long onle_volser; /* volume serial number */ ! 264: }; ! 265: ! 266: /* ! 267: * Get Unit Status end variant (and Avail Attn?) ! 268: */ ! 269: struct mscpv_guse { ! 270: u_short guse_multunit; /* multi-unit code */ ! 271: u_short guse_unitflags; /* unit flags */ ! 272: long guse_hostid; /* host id */ ! 273: long guse_unitid0; /*???*/ ! 274: short guse_unitid1; /*???*/ ! 275: u_char guse_drivetype; /* drive type index */ ! 276: u_char guse_unitid2; /*???*/ ! 277: long guse_mediaid; /* media type id (encoded) */ ! 278: short guse_shadowunit; /* shadow unit */ ! 279: short guse_shadowstat; /* shadow status */ ! 280: u_short guse_nspt; /* sectors per track */ ! 281: u_short guse_group; /* track group size */ ! 282: u_short guse_ngpc; /* groups per cylinder */ ! 283: u_short guse_xxx; /* reserved */ ! 284: u_short guse_rctsize; /* RCT size (sectors) */ ! 285: u_char guse_nrpt; /* RBNs per track */ ! 286: u_char guse_nrct; /* number of RCTs */ ! 287: }; ! 288: ! 289: /* ! 290: * Macros to break up and build media IDs. An ID encodes the port ! 291: * type in the top 10 bits, and the drive type in the remaining 22. ! 292: * The 10 bits, and 15 of the 22, are in groups of 5, with the value ! 293: * 0 representing space and values 1..26 representing A..Z. The low ! 294: * 7 bits represent a number in 0..127. Hence an RA81 on a UDA50 ! 295: * is <D><U><R><A>< >81, or 0x25641051. This encoding scheme is known ! 296: * in part in uda.c. ! 297: * ! 298: * The casts below are just to make pcc generate better code. ! 299: */ ! 300: #define MSCP_MEDIA_PORT(id) (((long)(id) >> 22) & 0x3ff) /* port */ ! 301: #define MSCP_MEDIA_DRIVE(id) ((long)(id) & 0x003fffff) /* drive */ ! 302: #define MSCP_MID_ECH(n, id) (((long)(id) >> ((n) * 5 + 7)) & 0x1f) ! 303: #define MSCP_MID_CHAR(n, id) \ ! 304: (MSCP_MID_ECH(n, id) ? MSCP_MID_ECH(n, id) + '@' : ' ') ! 305: #define MSCP_MID_NUM(id) ((id) & 0x7f) ! 306: /* for, e.g., RA81 */ ! 307: #define MSCP_MKDRIVE2(a, b, n) \ ! 308: (((a) - '@') << 17 | ((b) - '@') << 12 | (n)) ! 309: /* for, e.g., RRD50 */ ! 310: #define MSCP_MKDRIVE3(a, b, c, n) \ ! 311: (((a) - '@') << 17 | ((b) - '@') << 12 | ((c) - '@') << 7 | (n)) ! 312: ! 313: /* ! 314: * Error datagram variant. ! 315: */ ! 316: struct mscpv_erd { ! 317: quad erd_ctlrid; /* controller ID */ ! 318: u_char erd_ctlrsoftware; /* controller software version */ ! 319: u_char erd_ctlrhardware; /* controller hardware version */ ! 320: u_short erd_multiunit; /* multi-unit code (?) */ ! 321: union { ! 322: u_long un_busaddr; /* bus address, if mem access err */ ! 323: quad un_unitid; /* unit id, otherwise */ ! 324: } erd_un1; ! 325: #define erd_busaddr erd_un1.un_busaddr ! 326: #define erd_unitid erd_un1.un_unitid ! 327: u_char erd_unitsoftware; /* unit software version */ ! 328: u_char erd_unithardware; /* unit hardware version */ ! 329: union { ! 330: u_char un_b[2]; /* level, retry (if disk xfer err) */ ! 331: u_short un_s; /* cylinder (if small disk error) */ ! 332: } erd_un2; ! 333: #define erd_level erd_un2.un_b[0] ! 334: #define erd_retry erd_un2.un_b[1] ! 335: #define erd_sdecyl erd_un2.un_s ! 336: long erd_volser; /* volume serial number */ ! 337: u_long erd_hdr; /* `header' (block number) */ ! 338: u_char erd_sdistat[12]; /* SDI status information (?) */ ! 339: }; ! 340: ! 341: /* ! 342: * I am making brash assumptions about the first four bytes of all ! 343: * MSCP packets. These appear to be true for both UDA50s and TMSCP ! 344: * devices (TU81, TA81, TK50). DEC claim that these four bytes are ! 345: * not part of MSCP itself, yet at least the length is necessary ! 346: * for, e.g., error checking. ! 347: */ ! 348: struct mscp { ! 349: u_short mscp_msglen; /* length in bytes */ ! 350: u_char mscp_msgtc; /* type (high 4 bits) and credits */ ! 351: u_char mscp_vcid; /* virtual circuit ID */ ! 352: long mscp_cmdref; /* command reference number */ ! 353: u_short mscp_unit; /* unit number */ ! 354: u_short mscp_seqnum; /* sequence number */ ! 355: u_char mscp_opcode; /* opcode */ ! 356: #define mscp_format mscp_opcode /* aka format (datagrams) */ ! 357: u_char mscp_flags; /* flags */ ! 358: u_short mscp_modifier; /* modifier (commands) */ ! 359: #define mscp_status mscp_modifier /* aka status (ends) */ ! 360: #define mscp_event mscp_modifier /* aka event (datagrams) */ ! 361: union { ! 362: struct mscpv_seq un_seq; /* generic sequential msg */ ! 363: struct mscpv_sccc un_sccc; /* SCC command */ ! 364: struct mscpv_scce un_scce; /* SCC end */ ! 365: struct mscpv_onlc un_onlc; /* on line command */ ! 366: struct mscpv_onle un_onle; /* on line end */ ! 367: struct mscpv_guse un_guse; /* get unit status */ ! 368: struct mscpv_erd un_erd; /* error datagram */ ! 369: } mscp_un; ! 370: /*???*/ long mscp_xxx; /* pad to 64 bytes */ ! 371: }; ! 372: ! 373: /* ! 374: * Define message length according to the DEC specifications by dropping ! 375: * the four byte header. ! 376: */ ! 377: #define MSCP_MSGLEN (sizeof (struct mscp) - 4) ! 378: ! 379: /* ! 380: * Shorthand ! 381: */ ! 382: ! 383: /* ! 384: * Generic packet ! 385: */ ! 386: #define mscp_seq mscp_un.un_seq ! 387: ! 388: /* ! 389: * Set Controller Characteristics packet ! 390: */ ! 391: #define mscp_sccc mscp_un.un_sccc ! 392: ! 393: /* ! 394: * Set Controller Characteristics end packet ! 395: */ ! 396: #define mscp_scce mscp_un.un_scce ! 397: ! 398: /* ! 399: * Online / Set Unit Characteristics command packet ! 400: */ ! 401: #define mscp_onlc mscp_un.un_onlc ! 402: ! 403: /* ! 404: * Online end packet ! 405: */ ! 406: #define mscp_onle mscp_un.un_onle ! 407: ! 408: /* ! 409: * Get Unit Status end packet ! 410: */ ! 411: #define mscp_guse mscp_un.un_guse ! 412: ! 413: /* ! 414: * MSCP Error Log packet ! 415: */ ! 416: #define mscp_erd mscp_un.un_erd ! 417: ! 418: /* ! 419: * MSCP seq_addr field actually belongs to overall packet. ! 420: */ ! 421: #define mscp_addr mscp_seq.seq_addr ! 422: ! 423: /* ! 424: * Macros to break up mscp_msgtc, and types. ! 425: */ ! 426: #define MSCP_MSGTYPE(m) ((m) & 0xf0) ! 427: #define MSCP_CREDITS(m) ((m) & 0x0f) ! 428: ! 429: #define MSCPT_SEQ 0x00 /* sequential message */ ! 430: #define MSCPT_DATAGRAM 0x10 /* error datagram */ ! 431: #define MSCPT_CREDITS 0x20 /* credit notification */ ! 432: #define MSCPT_MAINTENANCE 0xf0 /* who knows */ ! 433: ! 434: ! 435: /* ! 436: * Here begin more perhaps brash assumptions about MSCP devices... ! 437: */ ! 438: ! 439: /* ! 440: * MSCP controllers have `command rings' and `response rings'. A ! 441: * command ring is a pool of MSCP packets that the host uses to give ! 442: * commands to the controller; a response ring is a pool of MSCP ! 443: * packets that the controller uses to give back responses. Entries ! 444: * in the command and response rings are `owned' by either the host ! 445: * or the controller; only the owner is allowed to alter any of the ! 446: * fields in the MSCP packet. Thus, free command packets are owned ! 447: * by the host, and free response packets by the controller. When ! 448: * the host gives a packet to the controller, it tells the controller ! 449: * by touching a device register; when the controller gives a response ! 450: * to the host, it generates an interrupt if enabled, and sets ! 451: * a device register as well. ! 452: * ! 453: * The pool is `described' by a set of pointers to the packets, along ! 454: * with the two flags below. ! 455: */ ! 456: #define MSCP_OWN 0x80000000 /* controller owns this packet */ ! 457: #define MSCP_INT 0x40000000 /* controller should interrupt */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.