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