Home | History | Annotate | Line # | Download | only in dev
siopreg.h revision 1.1
      1  1.1  mw /*
      2  1.1  mw  * Copyright (c) 1990 The Regents of the University of California.
      3  1.1  mw  * All rights reserved.
      4  1.1  mw  *
      5  1.1  mw  * This code is derived from software contributed to Berkeley by
      6  1.1  mw  * Van Jacobson of Lawrence Berkeley Laboratory.
      7  1.1  mw  *
      8  1.1  mw  * Redistribution and use in source and binary forms, with or without
      9  1.1  mw  * modification, are permitted provided that the following conditions
     10  1.1  mw  * are met:
     11  1.1  mw  * 1. Redistributions of source code must retain the above copyright
     12  1.1  mw  *    notice, this list of conditions and the following disclaimer.
     13  1.1  mw  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1  mw  *    notice, this list of conditions and the following disclaimer in the
     15  1.1  mw  *    documentation and/or other materials provided with the distribution.
     16  1.1  mw  * 3. All advertising materials mentioning features or use of this software
     17  1.1  mw  *    must display the following acknowledgement:
     18  1.1  mw  *	This product includes software developed by the University of
     19  1.1  mw  *	California, Berkeley and its contributors.
     20  1.1  mw  * 4. Neither the name of the University nor the names of its contributors
     21  1.1  mw  *    may be used to endorse or promote products derived from this software
     22  1.1  mw  *    without specific prior written permission.
     23  1.1  mw  *
     24  1.1  mw  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25  1.1  mw  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  1.1  mw  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  1.1  mw  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28  1.1  mw  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  1.1  mw  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  1.1  mw  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  1.1  mw  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  1.1  mw  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  1.1  mw  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  1.1  mw  * SUCH DAMAGE.
     35  1.1  mw  *
     36  1.1  mw  *	@(#)scsireg.h	7.3 (Berkeley) 2/5/91
     37  1.1  mw  */
     38  1.1  mw 
     39  1.1  mw /*
     40  1.1  mw  * NCR 53C710 SCSI interface hardware description.
     41  1.1  mw  *
     42  1.1  mw  */
     43  1.1  mw 
     44  1.1  mw typedef struct {
     45  1.1  mw 	volatile unsigned char	siop_sien;	/* rw: SCSI Interrupt Enable */
     46  1.1  mw 	volatile unsigned char	siop_sdid;	/* rw: SCSI Destination ID */
     47  1.1  mw 	volatile unsigned char	siop_scntl1;	/* rw: SCSI control reg 1 */
     48  1.1  mw 	volatile unsigned char	siop_scntl0;	/* rw: SCSI control reg 0 */
     49  1.1  mw 	volatile unsigned char	siop_socl;	/* rw: SCSI Output Control Latch */
     50  1.1  mw 	volatile unsigned char	siop_sodl;	/* rw: SCSI Output Data Latch */
     51  1.1  mw 	volatile unsigned char	siop_sxfer;	/* rw: SCSI Transfer reg */
     52  1.1  mw 	volatile unsigned char	siop_scid;	/* rw: SCSI Chip ID reg */
     53  1.1  mw 	volatile unsigned char	siop_sbcl;	/* ro: SCSI Bus Control Lines */
     54  1.1  mw 	volatile unsigned char	siop_sbdl;	/* ro: SCSI Bus Data Lines */
     55  1.1  mw 	volatile unsigned char	siop_sidl;	/* ro: SCSI Input Data Latch */
     56  1.1  mw 	volatile unsigned char	siop_sfbr;	/* ro: SCSI First Byte Received */
     57  1.1  mw 	volatile unsigned char	siop_sstat2;	/* ro: SCSI status reg 2 */
     58  1.1  mw 	volatile unsigned char	siop_sstat1;	/* ro: SCSI status reg 1 */
     59  1.1  mw 	volatile unsigned char	siop_sstat0;	/* ro: SCSI status reg 0 */
     60  1.1  mw 	volatile unsigned char	siop_dstat;	/* ro: DMA status */
     61  1.1  mw 	volatile unsigned long	siop_dsa;	/* rw: Data Structure Address */
     62  1.1  mw 	volatile unsigned char	siop_ctest3;	/* ro: Chip test register 3 */
     63  1.1  mw 	volatile unsigned char	siop_ctest2;	/* ro: Chip test register 2 */
     64  1.1  mw 	volatile unsigned char	siop_ctest1;	/* ro: Chip test register 1 */
     65  1.1  mw 	volatile unsigned char	siop_ctest0;	/* ro: Chip test register 0 */
     66  1.1  mw 	volatile unsigned char	siop_ctest7;	/* rw: Chip test register 7 */
     67  1.1  mw 	volatile unsigned char	siop_ctest6;	/* rw: Chip test register 6 */
     68  1.1  mw 	volatile unsigned char	siop_ctest5;	/* rw: Chip test register 5 */
     69  1.1  mw 	volatile unsigned char	siop_ctest4;	/* rw: Chip test register 4 */
     70  1.1  mw 	volatile unsigned long	siop_temp;	/* rw: Temporary Stack reg */
     71  1.1  mw 	volatile unsigned char	siop_lcrc;	/* rw: LCRC value */
     72  1.1  mw 	volatile unsigned char	siop_ctest8;	/* rw: Chip test register 8 */
     73  1.1  mw 	volatile unsigned char	siop_istat;	/* rw: Interrupt Status reg */
     74  1.1  mw 	volatile unsigned char	siop_dfifo;	/* rw: DMA FIFO */
     75  1.1  mw 	volatile unsigned char	siop_dcmd;	/* rw: DMA Command Register */
     76  1.1  mw 	volatile unsigned char	siop_dbc2;	/* rw: DMA Byte Counter reg */
     77  1.1  mw 	volatile unsigned char	siop_dbc1;
     78  1.1  mw 	volatile unsigned char	siop_dbc0;
     79  1.1  mw 	volatile unsigned long	siop_dnad;	/* rw: DMA Next Address */
     80  1.1  mw 	volatile unsigned long	siop_dsp;	/* rw: DMA SCRIPTS Pointer reg */
     81  1.1  mw 	volatile unsigned long	siop_dsps;	/* rw: DMA SCRIPTS Pointer Save reg */
     82  1.1  mw 	volatile unsigned long	siop_scratch;	/* rw: Scratch Register */
     83  1.1  mw 	volatile unsigned char	siop_dcntl;	/* rw: DMA Control reg */
     84  1.1  mw 	volatile unsigned char	siop_dwt;	/* rw: DMA Watchdog Timer */
     85  1.1  mw 	volatile unsigned char	siop_dien;	/* rw: DMA Interrupt Enable */
     86  1.1  mw 	volatile unsigned char	siop_dmode;	/* rw: DMA Mode reg */
     87  1.1  mw 	volatile unsigned long	siop_addr;
     88  1.1  mw 
     89  1.1  mw } siop_regmap_t;
     90  1.1  mw 
     91  1.1  mw /*
     92  1.1  mw  * Register defines
     93  1.1  mw  */
     94  1.1  mw 
     95  1.1  mw /* Scsi control register 0 (scntl0) */
     96  1.1  mw 
     97  1.1  mw #define	SIOP_SCNTL0_ARB		0xc0	/* Arbitration mode */
     98  1.1  mw #	define	SIOP_ARB_SIMPLE	0x00
     99  1.1  mw #	define	SIOP_ARB_FULL	0xc0
    100  1.1  mw #define	SIOP_SCNTL0_START	0x20	/* Start Sequence */
    101  1.1  mw #define	SIOP_SCNTL0_WATN	0x10	/* (Select) With ATN */
    102  1.1  mw #define	SIOP_SCNTL0_EPC		0x08	/* Enable Parity Checking */
    103  1.1  mw #define	SIOP_SCNTL0_EPG		0x04	/* Enable Parity Generation */
    104  1.1  mw #define	SIOP_SCNTL0_AAP		0x02	/* Assert ATN on Parity Error */
    105  1.1  mw #define	SIOP_SCNTL0_TRG		0x01	/* Target Mode */
    106  1.1  mw 
    107  1.1  mw /* Scsi control register 1 (scntl1) */
    108  1.1  mw 
    109  1.1  mw #define	SIOP_SCNTL1_EXC		0x80	/* Extra Clock Cycle of data setup */
    110  1.1  mw #define	SIOP_SCNTL1_ADB		0x40	/* Assert Data Bus */
    111  1.1  mw #define	SIOP_SCNTL1_ESR		0x20	/* Enable Selection/Reselection */
    112  1.1  mw #define	SIOP_SCNTL1_CON		0x10	/* Connected */
    113  1.1  mw #define	SIOP_SCNTL1_RST		0x08	/* Assert RST */
    114  1.1  mw #define	SIOP_SCNTL1_PAR		0x04	/* Force bad Parity */
    115  1.1  mw #define	SIOP_SCNTL1_SND		0x02	/* Start Send operation */
    116  1.1  mw #define	SIOP_SCNTL1_RCV		0x01	/* Start Receive operation */
    117  1.1  mw 
    118  1.1  mw /* Scsi interrupt enable register (sien) */
    119  1.1  mw 
    120  1.1  mw #define	SIOP_SIEN_M_A		0x80	/* Phase Mismatch or ATN active */
    121  1.1  mw #define	SIOP_SIEN_FC		0x40	/* Function Complete */
    122  1.1  mw #define	SIOP_SIEN_STO		0x20	/* (Re)Selection timeout */
    123  1.1  mw #define	SIOP_SIEN_SEL		0x10	/* (Re)Selected */
    124  1.1  mw #define	SIOP_SIEN_SGE		0x08	/* SCSI Gross Error */
    125  1.1  mw #define	SIOP_SIEN_UDC		0x04	/* Unexpected Disconnect */
    126  1.1  mw #define	SIOP_SIEN_RST		0x02	/* RST asserted */
    127  1.1  mw #define	SIOP_SIEN_PAR		0x01	/* Parity Error */
    128  1.1  mw 
    129  1.1  mw /* Scsi chip ID (scid) */
    130  1.1  mw 
    131  1.1  mw #define	SIOP_SCID_VALUE(i)	(1<<i)
    132  1.1  mw 
    133  1.1  mw /* Scsi transfer register (sxfer) */
    134  1.1  mw 
    135  1.1  mw #define	SIOP_SXFER_DHP		0x80	/* Disable Halt on Parity error/ ATN asserted */
    136  1.1  mw #define	SIOP_SXFER_TP		0x70	/* Synch Transfer Period */
    137  1.1  mw 					/* see specs for formulas:
    138  1.1  mw 						Period = TCP * (4 + XFERP )
    139  1.1  mw 						TCP = 1 + CLK + 1..2;
    140  1.1  mw 					 */
    141  1.1  mw #define	SIOP_SXFER_MO		0x0f	/* Synch Max Offset */
    142  1.1  mw #	define	SIOP_MAX_OFFSET	8
    143  1.1  mw 
    144  1.1  mw /* Scsi output data latch register (sodl) */
    145  1.1  mw 
    146  1.1  mw /* Scsi output control latch register (socl) */
    147  1.1  mw 
    148  1.1  mw #define	SIOP_REQ		0x80	/* SCSI signal <x> asserted */
    149  1.1  mw #define	SIOP_ACK		0x40
    150  1.1  mw #define	SIOP_BSY		0x20
    151  1.1  mw #define	SIOP_SEL		0x10
    152  1.1  mw #define	SIOP_ATN		0x08
    153  1.1  mw #define	SIOP_MSG		0x04
    154  1.1  mw #define	SIOP_CD			0x02
    155  1.1  mw #define	SIOP_IO			0x01
    156  1.1  mw 
    157  1.1  mw #define	SIOP_PHASE(socl)	SCSI_PHASE(socl)
    158  1.1  mw 
    159  1.1  mw /* Scsi first byte received register (sfbr) */
    160  1.1  mw 
    161  1.1  mw /* Scsi input data latch register (sidl) */
    162  1.1  mw 
    163  1.1  mw /* Scsi bus data lines register (sbdl) */
    164  1.1  mw 
    165  1.1  mw /* Scsi bus control lines register (sbcl).  Same as socl */
    166  1.1  mw 
    167  1.1  mw /* DMA status register (dstat) */
    168  1.1  mw 
    169  1.1  mw #define	SIOP_DSTAT_DFE		0x80	/* DMA FIFO empty */
    170  1.1  mw #define	SIOP_DSTAT_RES		0x60
    171  1.1  mw #define	SIOP_DSTAT_ABRT		0x10	/* Aborted */
    172  1.1  mw #define	SIOP_DSTAT_SSI		0x08	/* SCRIPT Single Step */
    173  1.1  mw #define	SIOP_DSTAT_SIR		0x04	/* SCRIPT Interrupt Instruction */
    174  1.1  mw #define	SIOP_DSTAT_WTD		0x02	/* Watchdog Timeout Detected */
    175  1.1  mw #define	SIOP_DSTAT_OPC		0x01	/* Invalid SCRIPTS Opcode */
    176  1.1  mw 
    177  1.1  mw /* Scsi status register 0 (sstat0) */
    178  1.1  mw 
    179  1.1  mw #define	SIOP_SSTAT0_M_A		0x80	/* Phase Mismatch or ATN active */
    180  1.1  mw #define	SIOP_SSTAT0_FC		0x40	/* Function Complete */
    181  1.1  mw #define	SIOP_SSTAT0_STO		0x20	/* (Re)Selection timeout */
    182  1.1  mw #define	SIOP_SSTAT0_SEL		0x10	/* (Re)Selected */
    183  1.1  mw #define	SIOP_SSTAT0_SGE		0x08	/* SCSI Gross Error */
    184  1.1  mw #define	SIOP_SSTAT0_UDC		0x04	/* Unexpected Disconnect */
    185  1.1  mw #define	SIOP_SSTAT0_RST		0x02	/* RST asserted */
    186  1.1  mw #define	SIOP_SSTAT0_PAR		0x01	/* Parity Error */
    187  1.1  mw 
    188  1.1  mw /* Scsi status register 1 (sstat1) */
    189  1.1  mw 
    190  1.1  mw #define	SIOP_SSTAT1_ILF		0x80	/* Input latch (sidl) full */
    191  1.1  mw #define	SIOP_SSTAT1_ORF		0x40	/* output reg (sodr) full */
    192  1.1  mw #define	SIOP_SSTAT1_OLF		0x20	/* output latch (sodl) full */
    193  1.1  mw #define	SIOP_SSTAT1_AIP		0x10	/* Arbitration in progress */
    194  1.1  mw #define	SIOP_SSTAT1_LOA		0x08	/* Lost arbitration */
    195  1.1  mw #define	SIOP_SSTAT1_WOA		0x04	/* Won arbitration */
    196  1.1  mw #define	SIOP_SSTAT1_RST		0x02	/* SCSI RST current value */
    197  1.1  mw #define	SIOP_SSTAT1_SDP		0x01	/* SCSI SDP current value */
    198  1.1  mw 
    199  1.1  mw /* Scsi status register 2 (sstat2) */
    200  1.1  mw 
    201  1.1  mw #define	SIOP_SSTAT2_FF		0xf0	/* SCSI FIFO flags (bytecount) */
    202  1.1  mw #	define SIOP_SCSI_FIFO_DEEP	8
    203  1.1  mw #define	SIOP_SSTAT2_SDP		0x08	/* Latched (on REQ) SCSI SDP */
    204  1.1  mw #define	SIOP_SSTAT2_MSG		0x04	/* Latched SCSI phase */
    205  1.1  mw #define	SIOP_SSTAT2_CD		0x02
    206  1.1  mw #define	SIOP_SSTAT2_IO		0x01
    207  1.1  mw 
    208  1.1  mw /* Chip test register 0 (ctest0) */
    209  1.1  mw 
    210  1.1  mw #define	SIOP_CTEST0_RES		0xfc
    211  1.1  mw #define	SIOP_CTEST0_RTRG	0x02	/* Real Target mode */
    212  1.1  mw #define	SIOP_CTEST0_DDIR	0x01	/* Xfer direction (1-> from SCSI bus) */
    213  1.1  mw 
    214  1.1  mw /* Chip test register 1 (ctest1) */
    215  1.1  mw 
    216  1.1  mw #define	SIOP_CTEST1_FMT		0xf0	/* Byte empty in DMA FIFO bottom (high->byte3) */
    217  1.1  mw #define	SIOP_CTEST1_FFL		0x0f	/* Byte full in DMA FIFO top, same */
    218  1.1  mw 
    219  1.1  mw /* Chip test register 2 (ctest2) */
    220  1.1  mw 
    221  1.1  mw #define	SIOP_CTEST2_RES		0xc0
    222  1.1  mw #define	SIOP_CTEST2_SOFF	0x20	/* Synch Offset compare (1-> zero Init, max Tgt */
    223  1.1  mw #define	SIOP_CTEST2_SFP		0x10	/* SCSI FIFO Parity */
    224  1.1  mw #define	SIOP_CTEST2_DFP		0x08	/* DMA FIFO Parity */
    225  1.1  mw #define	SIOP_CTEST2_TEOP	0x04	/* True EOP (a-la 5380) */
    226  1.1  mw #define	SIOP_CTEST2_DREQ	0x02	/* DREQ status */
    227  1.1  mw #define	SIOP_CTEST2_DACK	0x01	/* DACK status */
    228  1.1  mw 
    229  1.1  mw /* Chip test register 3 (ctest3) read-only, top of SCSI FIFO */
    230  1.1  mw 
    231  1.1  mw /* Chip test register 4 (ctest4) */
    232  1.1  mw 
    233  1.1  mw #define	SIOP_CTEST4_RES		0x80
    234  1.1  mw #define	SIOP_CTEST4_ZMOD	0x40	/* High-impedance outputs */
    235  1.1  mw #define	SIOP_CTEST4_SZM		0x20	/* ditto, SCSI "outputs" */
    236  1.1  mw #define	SIOP_CTEST4_SLBE	0x10	/* SCSI loobpack enable */
    237  1.1  mw #define	SIOP_CTEST4_SFWR	0x08	/* SCSI FIFO write enable (from sodl) */
    238  1.1  mw #define	SIOP_CTEST4_FBL		0x07	/* DMA FIFO Byte Lane select (from ctest6)
    239  1.1  mw 					   4->0, .. 7->3 */
    240  1.1  mw 
    241  1.1  mw /* Chip test register 5 (ctest5) */
    242  1.1  mw 
    243  1.1  mw #define	SIOP_CTEST5_ADCK	0x80	/* Clock Address Incrementor */
    244  1.1  mw #define	SIOP_CTEST5_BBCK	0x40	/* Clock Byte counter */
    245  1.1  mw #define	SIOP_CTEST5_ROFF	0x20	/* Reset SCSI offset */
    246  1.1  mw #define	SIOP_CTEST5_MASR	0x10	/* Master set/reset pulses (of bits 3-0) */
    247  1.1  mw #define	SIOP_CTEST5_DDIR	0x08	/* (re)set internal DMA direction */
    248  1.1  mw #define	SIOP_CTEST5_EOP		0x04	/* (re)set internal EOP */
    249  1.1  mw #define	SIOP_CTEST5_DREQ	0x02	/* (re)set internal REQ */
    250  1.1  mw #define	SIOP_CTEST5_DACK	0x01	/* (re)set internal ACK */
    251  1.1  mw 
    252  1.1  mw /* Chip test register 6 (ctest6)  DMA FIFO access */
    253  1.1  mw 
    254  1.1  mw /* Chip test register 7 (ctest7) */
    255  1.1  mw 
    256  1.1  mw #define	SIOP_CTEST7_RES		0xe0
    257  1.1  mw #define	SIOP_CTEST7_STD		0x10	/* Disable selection timeout */
    258  1.1  mw #define	SIOP_CTEST7_DFP		0x08	/* DMA FIFO parity bit */
    259  1.1  mw #define	SIOP_CTEST7_EVP		0x04	/* Even parity (to host bus) */
    260  1.1  mw #define	SIOP_CTEST7_DC		0x02	/* Drive DC pin low on SCRIPT fetches */
    261  1.1  mw #define	SIOP_CTEST7_DIFF	0x01	/* Differential mode */
    262  1.1  mw 
    263  1.1  mw /* DMA FIFO register (dfifo) */
    264  1.1  mw 
    265  1.1  mw #define	SIOP_DFIFO_FLF		0x80	/* Flush (spill) DMA FIFO */
    266  1.1  mw #define	SIOP_DFIFO_CLF		0x40	/* Clear DMA and SCSI FIFOs */
    267  1.1  mw #define	SIOP_DFIFO_BO		0x3f	/* FIFO byte offset counter */
    268  1.1  mw 
    269  1.1  mw /* Interrupt status register (istat) */
    270  1.1  mw 
    271  1.1  mw #define	SIOP_ISTAT_ABRT		0x80	/* Abort operation */
    272  1.1  mw #define	SIOP_ISTAT_RES		0x70
    273  1.1  mw #define	SIOP_ISTAT_CON		0x08	/* Connected */
    274  1.1  mw #define	SIOP_ISTAT_PRE		0x04	/* Pointer register empty */
    275  1.1  mw #define	SIOP_ISTAT_SIP		0x02	/* SCSI Interrupt pending */
    276  1.1  mw #define	SIOP_ISTAT_DIP		0x01	/* DMA Interrupt pending */
    277  1.1  mw 
    278  1.1  mw 
    279  1.1  mw /* DMA Mode register (dmode) */
    280  1.1  mw 
    281  1.1  mw #define	SIOP_DMODE_BL_MASK	0xc0	/* 0->1 1->2 2->4 3->8 */
    282  1.1  mw #define	SIOP_DMODE_BW16		0x20	/* Bus Width is 16 bits */
    283  1.1  mw #define	SIOP_DMODE_286		0x10	/* 286 mode */
    284  1.1  mw #define	SIOP_DMODE_IO_M		0x08	/* xfer data to memory or I/O space */
    285  1.1  mw #define	SIOP_DMODE_FAM		0x04	/* fixed address mode */
    286  1.1  mw #define	SIOP_DMODE_PIPE		0x02	/* SCRIPTS in Pipeline mode */
    287  1.1  mw #define	SIOP_DMODE_MAN		0x01	/* SCRIPTS in Manual start mode */
    288  1.1  mw 
    289  1.1  mw /* DMA interrupt enable register (dien) */
    290  1.1  mw 
    291  1.1  mw #define	SIOP_DIEN_RES		0xe0
    292  1.1  mw #define	SIOP_DIEN_ABRT		0x10	/* On Abort */
    293  1.1  mw #define	SIOP_DIEN_SSI		0x08	/* On SCRIPTS sstep */
    294  1.1  mw #define	SIOP_DIEN_SIR		0x04	/* On SCRIPTS intr instruction */
    295  1.1  mw #define	SIOP_DIEN_WTD		0x02	/* On watchdog timeout */
    296  1.1  mw #define	SIOP_DIEN_OPC		0x01	/* On SCRIPTS illegal opcode */
    297  1.1  mw 
    298  1.1  mw /* DMA control register (dcntl) */
    299  1.1  mw 
    300  1.1  mw #define	SIOP_DCNTL_CF_MASK	0xc0	/* Clock frequency dividers:
    301  1.1  mw 						0 --> 37.51..50.00 Mhz, div=2
    302  1.1  mw 						1 --> 25.01..37.50 Mhz, div=1.5
    303  1.1  mw 						2 --> 16.67..25.00 Mhz, div=1
    304  1.1  mw 						3 --> reserved
    305  1.1  mw 					 */
    306  1.1  mw #define	SIOP_DCNTL_S16		0x20	/* SCRIPTS fetches 16bits at a time */
    307  1.1  mw #define	SIOP_DCNTL_SSM		0x10	/* Single step mode */
    308  1.1  mw #define	SIOP_DCNTL_LLM		0x08	/* Enable Low-level mode */
    309  1.1  mw #define	SIOP_DCNTL_STD		0x04	/* Start SCRIPTS operation */
    310  1.1  mw #define	SIOP_DCNTL_RES		0x02
    311  1.1  mw #define	SIOP_DCNTL_RST		0x01	/* Software reset */
    312  1.1  mw 
    313  1.1  mw /* psns/pctl phase lines as bits */
    314  1.1  mw #define	PHASE_MSG	0x04
    315  1.1  mw #define	PHASE_CD	0x02		/* =1 if 'command' */
    316  1.1  mw #define	PHASE_IO	0x01		/* =1 if data inbound */
    317  1.1  mw /* Phase lines as values */
    318  1.1  mw #define	PHASE		0x07		/* mask for psns/pctl phase */
    319  1.1  mw #define	DATA_OUT_PHASE	0x00
    320  1.1  mw #define	DATA_IN_PHASE	0x01
    321  1.1  mw #define	CMD_PHASE	0x02
    322  1.1  mw #define	STATUS_PHASE	0x03
    323  1.1  mw #define	BUS_FREE_PHASE	0x04
    324  1.1  mw #define	ARB_SEL_PHASE	0x05	/* Fuji chip combines arbitration with sel. */
    325  1.1  mw #define	MESG_OUT_PHASE	0x06
    326  1.1  mw #define	MESG_IN_PHASE	0x07
    327  1.1  mw 
    328  1.1  mw /* SCSI Messages */
    329  1.1  mw 
    330  1.1  mw #define	MSG_CMD_COMPLETE	0x00
    331  1.1  mw #define MSG_EXT_MESSAGE		0x01
    332  1.1  mw #define	MSG_SAVE_DATA_PTR	0x02
    333  1.1  mw #define	MSG_RESTORE_PTR		0x03
    334  1.1  mw #define	MSG_DISCONNECT		0x04
    335  1.1  mw #define	MSG_INIT_DETECT_ERROR	0x05
    336  1.1  mw #define	MSG_ABORT		0x06
    337  1.1  mw #define	MSG_REJECT		0x07
    338  1.1  mw #define	MSG_NOOP		0x08
    339  1.1  mw #define	MSG_PARITY_ERROR	0x09
    340  1.1  mw #define	MSG_BUS_DEVICE_RESET	0x0C
    341  1.1  mw #define	MSG_IDENTIFY		0x80
    342  1.1  mw #define	MSG_IDENTIFY_DR		0xc0	/* (disconnect/reconnect allowed) */
    343  1.1  mw #define	MSG_SYNC_REQ 		0x01
    344  1.1  mw 
    345  1.1  mw /* SCSI Commands */
    346  1.1  mw 
    347  1.1  mw #define CMD_TEST_UNIT_READY	0x00
    348  1.1  mw #define CMD_REQUEST_SENSE	0x03
    349  1.1  mw #define	CMD_INQUIRY		0x12
    350  1.1  mw #define CMD_SEND_DIAGNOSTIC	0x1D
    351  1.1  mw 
    352  1.1  mw #define CMD_REWIND		0x01
    353  1.1  mw #define CMD_FORMAT_UNIT		0x04
    354  1.1  mw #define CMD_READ_BLOCK_LIMITS	0x05
    355  1.1  mw #define CMD_REASSIGN_BLOCKS	0x07
    356  1.1  mw #define CMD_READ		0x08
    357  1.1  mw #define CMD_WRITE		0x0A
    358  1.1  mw #define CMD_WRITE_FILEMARK	0x10
    359  1.1  mw #define CMD_SPACE		0x11
    360  1.1  mw #define CMD_MODE_SELECT		0x15
    361  1.1  mw #define CMD_RELEASE_UNIT	0x17
    362  1.1  mw #define CMD_ERASE		0x19
    363  1.1  mw #define CMD_MODE_SENSE		0x1A
    364  1.1  mw #define CMD_LOADUNLOAD		0x1B
    365  1.1  mw #define CMD_RECEIVE_DIAG	0x1C
    366  1.1  mw #define CMD_SEND_DIAG		0x1D
    367  1.1  mw #define CMD_P_A_MEDIA_REMOVAL	0x1E
    368  1.1  mw #define CMD_READ_CAPACITY	0x25
    369  1.1  mw #define CMD_READ_EXT		0x28
    370  1.1  mw #define CMD_WRITE_EXT		0x2A
    371  1.1  mw #define CMD_READ_DEFECT_DATA	0x37
    372  1.1  mw #define		SD_MANUFAC_DEFECTS	0x14000000
    373  1.1  mw #define		SD_GROWN_DEFECTS	0x0c000000
    374  1.1  mw #define CMD_READ_BUFFER		0x3B
    375  1.1  mw #define CMD_WRITE_BUFFER	0x3C
    376  1.1  mw #define CMD_READ_FULL		0xF0
    377  1.1  mw #define CMD_MEDIA_TEST		0xF1
    378  1.1  mw #define CMD_ACCESS_LOG		0xF2
    379  1.1  mw #define CMD_WRITE_FULL		0xFC
    380  1.1  mw #define CMD_MANAGE_PRIMARY	0xFD
    381  1.1  mw #define CMD_EXECUTE_DATA	0xFE
    382  1.1  mw 
    383  1.1  mw /* SCSI status bits */
    384  1.1  mw 
    385  1.1  mw #define	STS_CHECKCOND	0x02	/* Check Condition (ie., read sense) */
    386  1.1  mw #define	STS_CONDMET	0x04	/* Condition Met (ie., search worked) */
    387  1.1  mw #define	STS_BUSY	0x08
    388  1.1  mw #define	STS_INTERMED	0x10	/* Intermediate status sent */
    389  1.1  mw #define	STS_EXT		0x80	/* Extended status valid */
    390  1.1  mw 
    391  1.1  mw /* command descriptor blocks */
    392  1.1  mw 
    393  1.1  mw struct scsi_cdb6 {
    394  1.1  mw 	u_char	cmd;		/* command code */
    395  1.1  mw 	u_char	lun:  3,	/* logical unit on ctlr */
    396  1.1  mw 		lbah: 5;	/* msb of read/write logical block addr */
    397  1.1  mw 	u_char	lbam;		/* middle byte of l.b.a. */
    398  1.1  mw 	u_char	lbal;		/* lsb of l.b.a. */
    399  1.1  mw 	u_char	len;		/* transfer length */
    400  1.1  mw 	u_char	xtra;
    401  1.1  mw };
    402  1.1  mw 
    403  1.1  mw struct scsi_cdb10 {
    404  1.1  mw 	u_char	cmd;		/* command code */
    405  1.1  mw 	u_char	lun: 3,		/* logical unit on ctlr */
    406  1.1  mw 		   : 4,
    407  1.1  mw 		rel: 1;		/* l.b.a. is relative addr if =1 */
    408  1.1  mw 	u_char	lbah;		/* msb of read/write logical block addr */
    409  1.1  mw 	u_char	lbahm;		/* high middle byte of l.b.a. */
    410  1.1  mw 	u_char	lbalm;		/* low middle byte of l.b.a. */
    411  1.1  mw 	u_char	lbal;		/* lsb of l.b.a. */
    412  1.1  mw 	u_char	reserved;
    413  1.1  mw 	u_char	lenh;		/* msb transfer length */
    414  1.1  mw 	u_char	lenl;		/* lsb transfer length */
    415  1.1  mw 	u_char	xtra;
    416  1.1  mw };
    417  1.1  mw 
    418  1.1  mw /* basic sense data */
    419  1.1  mw 
    420  1.1  mw struct scsi_sense {
    421  1.1  mw 	u_char	valid: 1,	/* l.b.a. is valid */
    422  1.1  mw 		class: 3,
    423  1.1  mw 		code:  4;
    424  1.1  mw 	u_char	vu:    4,	/* vendor unique */
    425  1.1  mw 		lbah:  4;
    426  1.1  mw 	u_char	lbam;
    427  1.1  mw 	u_char	lbal;
    428  1.1  mw };
    429  1.1  mw 
    430  1.1  mw struct scsi_xsense {
    431  1.1  mw 	u_char	valid: 1,	/* l.b.a. is valid */
    432  1.1  mw 		class: 3,
    433  1.1  mw 		code:  4;
    434  1.1  mw 	u_char	segment;
    435  1.1  mw 	u_char	filemark: 1,
    436  1.1  mw 		eom:      1,
    437  1.1  mw 		ili:      1,	/* illegal length indicator */
    438  1.1  mw 		rsvd:	  1,
    439  1.1  mw 		key:	  4;
    440  1.1  mw 	u_char	info1;
    441  1.1  mw 	u_char	info2;
    442  1.1  mw 	u_char	info3;
    443  1.1  mw 	u_char	info4;
    444  1.1  mw 	u_char	len;		/* additional sense length */
    445  1.1  mw };
    446  1.1  mw 
    447  1.1  mw /* inquiry data */
    448  1.1  mw struct scsi_inquiry {
    449  1.1  mw 	u_char	type;
    450  1.1  mw 	u_char	qual;
    451  1.1  mw 	u_char	version;
    452  1.1  mw 	u_char	rsvd;
    453  1.1  mw 	u_char	len;
    454  1.1  mw 	char	class[3];
    455  1.1  mw 	char	vendor_id[8];
    456  1.1  mw 	char	product_id[16];
    457  1.1  mw 	char	rev[4];
    458  1.1  mw };
    459  1.1  mw 
    460  1.1  mw struct scsi_format_parms {		/* physical BFI format */
    461  1.1  mw 	u_short	reserved;
    462  1.1  mw 	u_short	list_len;
    463  1.1  mw 	struct defect {
    464  1.1  mw 		unsigned cyl  : 24;
    465  1.1  mw 		unsigned head : 8;
    466  1.1  mw 		long	bytes_from_index;
    467  1.1  mw 	} defect[127];
    468  1.1  mw } format_parms;
    469  1.1  mw 
    470  1.1  mw struct scsi_reassign_parms {
    471  1.1  mw 	u_short	reserved;
    472  1.1  mw 	u_short	list_len;	/* length in bytes of defects only */
    473  1.1  mw 	struct new_defect {
    474  1.1  mw 		unsigned lba;	/* logical block address */
    475  1.1  mw 	} new_defect[2];
    476  1.1  mw } reassign_parms;
    477  1.1  mw 
    478  1.1  mw struct scsi_modesel_hdr {
    479  1.1  mw 	u_char	rsvd1;
    480  1.1  mw 	u_char	media_type;
    481  1.1  mw 	u_char 	rsvd2;
    482  1.1  mw 	u_char	block_desc_len;
    483  1.1  mw 	u_int	density		: 8;
    484  1.1  mw 	u_int	number_blocks	:24;
    485  1.1  mw 	u_int	rsvd3		: 8;
    486  1.1  mw 	u_int	block_length	:24;
    487  1.1  mw };
    488  1.1  mw 
    489  1.1  mw struct scsi_modesense_hdr {
    490  1.1  mw 	u_char	len;
    491  1.1  mw 	u_char	media_type;
    492  1.1  mw 	u_char 	wp    : 1;
    493  1.1  mw 	u_char 	rsvd1 : 7;
    494  1.1  mw 	u_char	block_desc_len;
    495  1.1  mw 	u_int	density		: 8;
    496  1.1  mw 	u_int	number_blocks	:24;
    497  1.1  mw 	u_int	rsvd2		: 8;
    498  1.1  mw 	u_int	block_length	:24;
    499  1.1  mw };
    500  1.1  mw 
    501  1.1  mw /*
    502  1.1  mw  * Mode Select / Mode sense "pages"
    503  1.1  mw  */
    504  1.1  mw 
    505  1.1  mw /*
    506  1.1  mw  * Page One - Error Recovery Parameters
    507  1.1  mw  */
    508  1.1  mw struct scsi_err_recovery {
    509  1.1  mw 	u_char	page_savable	: 1;	/* save parameters */
    510  1.1  mw 	u_char	reserved	: 1;
    511  1.1  mw 	u_char	page_code	: 6;	/* = 0x01 */
    512  1.1  mw 	u_char	page_length;		/* = 6 */
    513  1.1  mw 	u_char	awre		: 1;	/* auto write realloc enabled */
    514  1.1  mw 	u_char	arre		: 1;	/* auto read realloc enabled */
    515  1.1  mw 	u_char	tb		: 1;	/* transfer block */
    516  1.1  mw 	u_char 	rc		: 1;	/* read continuous */
    517  1.1  mw 	u_char	eec		: 1;	/* enable early correction */
    518  1.1  mw 	u_char	per		: 1;	/* post error */
    519  1.1  mw 	u_char	dte		: 1;	/* disable transfer on error */
    520  1.1  mw 	u_char	dcr		: 1;	/* disable correction */
    521  1.1  mw 	u_char	retry_count;
    522  1.1  mw 	u_char	correction_span;
    523  1.1  mw 	u_char	head_offset_count;
    524  1.1  mw 	u_char	strobe_offset_count;
    525  1.1  mw 	u_char	recovery_time_limit;
    526  1.1  mw };
    527  1.1  mw 
    528  1.1  mw /*
    529  1.1  mw  * Page Two - Disconnect / Reconnect Control Parameters
    530  1.1  mw  */
    531  1.1  mw struct scsi_disco_reco {
    532  1.1  mw 	u_char	page_savable	: 1;	/* save parameters */
    533  1.1  mw 	u_char	rsvd		: 1;
    534  1.1  mw 	u_char	page_code	: 6;	/* = 0x02 */
    535  1.1  mw 	u_char	page_length;		/* = 10 */
    536  1.1  mw 	u_char	buffer_full_ratio;	/* write, how full before reconnect? */
    537  1.1  mw 	u_char	buffer_empty_ratio;	/* read, how full before reconnect? */
    538  1.1  mw 
    539  1.1  mw 	u_short	bus_inactivity_limit;	/* how much bus time for busy */
    540  1.1  mw 	u_short	disconnect_time_limit;	/* min to remain disconnected */
    541  1.1  mw 	u_short	connect_time_limit;	/* min to remain connected */
    542  1.1  mw 	u_short	reserved_1;
    543  1.1  mw };
    544  1.1  mw 
    545  1.1  mw /*
    546  1.1  mw  * Page Three - Direct Access Device Format Parameters
    547  1.1  mw  */
    548  1.1  mw struct scsi_format {
    549  1.1  mw 	u_char	page_savable	: 1;	/* save parameters */
    550  1.1  mw 	u_char	rsvd		: 1;
    551  1.1  mw 	u_char	page_code	: 6;	/* = 0x03 */
    552  1.1  mw 	u_char	page_length;		/* = 22 */
    553  1.1  mw 	u_short	tracks_per_zone;	/*  Handling of Defects Fields */
    554  1.1  mw 	u_short	alt_sect_zone;
    555  1.1  mw 	u_short alt_tracks_zone;
    556  1.1  mw 	u_short	alt_tracks_vol;
    557  1.1  mw 	u_short	sect_track;		/* Track Format Field */
    558  1.1  mw 	u_short data_sect;		/* Sector Format Fields */
    559  1.1  mw 	u_short	interleave;
    560  1.1  mw 	u_short	track_skew_factor;
    561  1.1  mw 	u_short	cyl_skew_factor;
    562  1.1  mw 	u_char	ssec		: 1;	/* Drive Type Field */
    563  1.1  mw 	u_char	hsec		: 1;
    564  1.1  mw 	u_char	rmb		: 1;
    565  1.1  mw 	u_char	surf		: 1;
    566  1.1  mw 	u_char	ins		: 1;
    567  1.1  mw 	u_char	reserved_1	: 3;
    568  1.1  mw 	u_char	reserved_2;
    569  1.1  mw 	u_char	reserved_3;
    570  1.1  mw 	u_char	reserved_4;
    571  1.1  mw };
    572  1.1  mw 
    573  1.1  mw /*
    574  1.1  mw  * Page Four - Rigid Disk Drive Geometry Parameters
    575  1.1  mw  */
    576  1.1  mw struct scsi_geometry {
    577  1.1  mw 	u_char	page_savable	: 1;	/* save parameters */
    578  1.1  mw 	u_char	rsvd		: 1;
    579  1.1  mw 	u_char	page_code	: 6;	/* = 0x04 */
    580  1.1  mw 	u_char	page_length;		/* = 18 */
    581  1.1  mw 	u_char	cyl_ub;			/* number of cylinders */
    582  1.1  mw 	u_char	cyl_mb;
    583  1.1  mw 	u_char	cyl_lb;
    584  1.1  mw 	u_char	heads;			/* number of heads */
    585  1.1  mw 	u_char	precomp_cyl_ub;		/* cylinder to start precomp */
    586  1.1  mw 	u_char	precomp_cyl_mb;
    587  1.1  mw 	u_char	precomp_cyl_lb;
    588  1.1  mw 	u_char	current_cyl_ub;		/* cyl to start reduced current */
    589  1.1  mw 	u_char	current_cyl_mb;
    590  1.1  mw 	u_char	current_cyl_lb;
    591  1.1  mw 	u_short	step_rate;		/* drive step rate */
    592  1.1  mw 	u_char	landing_cyl_ub;		/* landing zone cylinder */
    593  1.1  mw 	u_char	landing_cyl_mb;
    594  1.1  mw 	u_char	landing_cyl_lb;
    595  1.1  mw 	u_char	reserved_1;
    596  1.1  mw 	u_char	reserved_2;
    597  1.1  mw 	u_char	reserved_3;
    598  1.1  mw };
    599  1.1  mw 
    600  1.1  mw /*
    601  1.1  mw  * Page 0x38 - Cache Control Parameters
    602  1.1  mw  */
    603  1.1  mw struct scsi_cache {
    604  1.1  mw 	u_char	page_savable	: 1;	/* save parameters */
    605  1.1  mw 	u_char	rsvd		: 1;
    606  1.1  mw 	u_char	page_code	: 6;	/* = 0x38 */
    607  1.1  mw 	u_char	page_length;		/* = 14 */
    608  1.1  mw 	u_char rsvd_1	: 1;
    609  1.1  mw 	u_char wie	: 1; 		/* write index enable */
    610  1.1  mw 	u_char rsvd_2	: 1;
    611  1.1  mw 	u_char ce	: 1; 		/* cache enable */
    612  1.1  mw 	u_char table_size : 4;
    613  1.1  mw 	u_char	prefetch_threshold;
    614  1.1  mw 	u_char	maximum_threshold;
    615  1.1  mw 	u_char	maximumprefetch_multiplier;
    616  1.1  mw 	u_char	minimum_threshold;
    617  1.1  mw 	u_char	minimum_prefetch_multiplier;
    618  1.1  mw 	u_char	reserved[8];
    619  1.1  mw };
    620  1.1  mw 
    621  1.1  mw /*
    622  1.1  mw  * Driver ioctl's for various scsi operations.
    623  1.1  mw  */
    624  1.1  mw #ifndef _IOCTL_
    625  1.1  mw #include "ioctl.h"
    626  1.1  mw #endif
    627  1.1  mw 
    628  1.1  mw /*
    629  1.1  mw  * Control for SCSI "format" mode.
    630  1.1  mw  *
    631  1.1  mw  * "Format" mode allows a privileged process to issue direct SCSI
    632  1.1  mw  * commands to a drive (it is intended primarily to allow on-line
    633  1.1  mw  * formatting).  SDIOCSFORMAT with a non-zero arg will put the drive
    634  1.1  mw  * into format mode; a zero arg will take it out.  When in format
    635  1.1  mw  * mode, only the process that issued the SDIOCFORMAT can read or
    636  1.1  mw  * write the drive.
    637  1.1  mw  *
    638  1.1  mw  * In format mode, process is expected to
    639  1.1  mw  *	- do SDIOCSCSICOMMAND to supply cdb for next SCSI op
    640  1.1  mw  *	- do read or write as appropriate for cdb
    641  1.1  mw  *	- if i/o error, optionally do SDIOCSENSE to get completion
    642  1.1  mw  *	  status and sense data from last scsi operation.
    643  1.1  mw  */
    644  1.1  mw 
    645  1.1  mw struct scsi_fmt_cdb {
    646  1.1  mw 	int len;		/* cdb length (in bytes) */
    647  1.1  mw 	u_char cdb[28];		/* cdb to use on next read/write */
    648  1.1  mw };
    649  1.1  mw 
    650  1.1  mw struct scsi_fmt_sense {
    651  1.1  mw 	u_int status;		/* completion status of last op */
    652  1.1  mw 	u_char sense[28];	/* sense data (if any) from last op */
    653  1.1  mw };
    654  1.1  mw 
    655  1.1  mw #define	SDIOCSFORMAT		_IOW('S', 0x1, int)
    656  1.1  mw #define	SDIOCGFORMAT		_IOR('S', 0x2, int)
    657  1.1  mw #define	SDIOCSCSICOMMAND	_IOW('S', 0x3, struct scsi_fmt_cdb)
    658  1.1  mw #define	SDIOCSENSE		_IOR('S', 0x4, struct scsi_fmt_sense)
    659  1.1  mw 
    660  1.1  mw extern void siopreset (int unit);
    661  1.1  mw extern void siopstart (int unit);
    662  1.1  mw extern int siopgo (int ctlr, int slave, int unit, struct buf *bp, struct scsi_fmt_cdb *cdb, int pad);
    663  1.1  mw extern void siopdone (int unit);
    664  1.1  mw #if 0
    665  1.1  mw extern int siopintr2 (int unit);
    666  1.1  mw #else
    667  1.1  mw extern int siopintr2 (void);
    668  1.1  mw #endif
    669