1 /*        $NetBSD: rsp.h,v 1.3 2017/05/22 17:12:11 ragge Exp $ */
2 /*
3  * Copyright (c) 1995 Ludd, University of Lule}, Sweden.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 
28 /*
29  * The Radial Serial Protocol (RSP) that TU58 (DECtape II) uses
30  * is a strange animal that is sent over serial lines.
31  * Most packet types can match the struct rsp, but some can't (i.e.
32  * data packets).
33  * More about RSP can be read in Digital Peripherals Handbook, p. 92.
34  */
35 
36 struct rsp {
37           char      rsp_typ;  /* Packet type */
38           char      rsp_sz;             /* Packet size */
39           char      rsp_op;             /* Operation */
40           char      rsp_mod;  /* Modifier */
41           char      rsp_drv;  /* Tape drive number */
42           char      rsp_sw;             /* Switches */
43           char      rsp_xx1;  /* Unused, always zero */
44           char      rsp_xx2;  /* Unused, always zero */
45           short     rsp_cnt;  /* Byte count to transfer */
46           short     rsp_blk;  /* Block number */
47           short     rsp_sum;  /* Checksum of packet */
48 };
49 
50 /* Types of packets */
51 #define   RSP_TYP_DATA                  001       /* DATA packet */
52 #define   RSP_TYP_COMMAND               002       /* COMMAND packet */
53 #define   RSP_TYP_INIT                  004       /* INITIALIZE packet */
54 #define   RSP_TYP_BOOT                  010       /* BOOTSTRAP packet (PDP11) */
55 #define   RSP_TYP_CONTINUE    020       /* CONTINUE packet */
56 #define   RSP_TYP_XOFF                  023       /* XOFF packet */
57 
58 /* Operation types */
59 #define   RSP_OP_NOP                    000       /* No operation */
60 #define   RSP_OP_RESET                  001       /* Reset */
61 #define   RSP_OP_READ                   002       /* Read data */
62 #define   RSP_OP_WRITE                  003       /* Write data */
63 #define   RSP_OP_POS                    005       /* Position tape */
64 #define   RSP_OP_DIAG                   007       /* internal diagnose */
65 #define   RSP_OP_GSTAT                  010       /* Get status */
66 #define   RSP_OP_SSTAT                  011       /* Set status */
67 #define   RSP_OP_END                    0100      /* End packet */
68 
69 /* Modifier */
70 #define   RSP_MOD_VERIFY                001       /* Verify read data */
71 #define   RSP_MOD_OK                    000       /* Success */
72 #define   RSP_MOD_RETR                  001       /* Success w/ retries */
73 #define   RSP_MOD_FAIL                  -1        /* Failed self-test */
74 #define   RSP_MOD_PART                  -2        /* Partial operation */
75 #define   RSP_MOD_NET                   -8        /* Non-existent tape drive */
76 #define   RSP_MOD_NOC                   -9        /* No cartridge */
77 #define   RSP_MOD_WP                    -11       /* Write protected */
78 #define   RSP_MOD_DERR                  -17       /* Data error */
79 #define   RSP_MOD_SERR                  -32       /* Seek error */
80 #define   RSP_MOD_STOP                  -33       /* Motor stopped */
81 #define   RSP_MOD_INVAL                 -48       /* Invalid opcode */
82 #define   RSP_MOD_INVBLK                -55       /* Invalid bloch number */
83 
84