xyreg.h revision 1.2
11.2Spk/*	$NetBSD: xyreg.h,v 1.2 1998/08/22 11:47:46 pk Exp $	*/
21.1Spk
31.1Spk/*
41.1Spk *
51.1Spk * Copyright (c) 1995 Charles D. Cranor
61.1Spk * All rights reserved.
71.1Spk *
81.1Spk * Redistribution and use in source and binary forms, with or without
91.1Spk * modification, are permitted provided that the following conditions
101.1Spk * are met:
111.1Spk * 1. Redistributions of source code must retain the above copyright
121.1Spk *    notice, this list of conditions and the following disclaimer.
131.1Spk * 2. Redistributions in binary form must reproduce the above copyright
141.1Spk *    notice, this list of conditions and the following disclaimer in the
151.1Spk *    documentation and/or other materials provided with the distribution.
161.1Spk * 3. All advertising materials mentioning features or use of this software
171.1Spk *    must display the following acknowledgement:
181.1Spk *      This product includes software developed by Charles D. Cranor.
191.1Spk * 4. The name of the author may not be used to endorse or promote products
201.1Spk *    derived from this software without specific prior written permission.
211.1Spk *
221.1Spk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
231.1Spk * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
241.1Spk * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
251.1Spk * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
261.1Spk * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
271.1Spk * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
281.1Spk * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
291.1Spk * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
301.1Spk * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
311.1Spk * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
321.1Spk */
331.1Spk
341.1Spk/*
351.1Spk * x y r e g . h
361.1Spk *
371.1Spk * this file contains the description of the Xylogics 450/451's hardware
381.1Spk * data structures.
391.1Spk *
401.1Spk * author: Chuck Cranor <chuck@ccrc.wustl.edu>
411.1Spk */
421.1Spk
431.2Spk#define XYC_MAXDEV	2		/* max devices per controller */
441.2Spk#define XYC_CTLIOPB	XYC_MAXDEV	/* controller's iopb */
451.2Spk#define XYC_RESETUSEC	1000000		/* max time for xyc reset (same as xdc?) */
461.2Spk#define XYC_MAXIOPB	(XYC_MAXDEV+1)	/* max # of iopbs that can be active */
471.2Spk#define XYC_MAXTIME	(4*1000000)	/* four seconds before we give up and reset */
481.2Spk#define XYC_MAXTRIES	4	/* max number of times to retry an operation */
491.2Spk#define XYC_INTERLEAVE	1	/* interleave (from disk label?) */
501.2Spk#define XYFM_BPS	0x200	/* must be 512! */
511.1Spk
521.1Spk/*
531.1Spk * xyc device interface
541.1Spk * (lives in VME address space)   [note: bytes are swapped!]
551.1Spk */
561.1Spk
571.1Spkstruct xyc {
581.1Spk	volatile u_char xyc_reloc_hi;        /* iopb relocation (low byte) */
591.1Spk	volatile u_char xyc_reloc_lo;        /* iopb relocation (high byte) */
601.1Spk	volatile u_char xyc_addr_hi;         /* iopb address (low byte) */
611.1Spk	volatile u_char xyc_addr_lo;         /* iopb address (high byte) */
621.1Spk	volatile u_char xyc_rsetup;          /* reset/update reg */
631.1Spk	volatile u_char xyc_csr;             /* control and status register */
641.1Spk};
651.1Spk
661.1Spk/*
671.1Spk * xyc_csr
681.1Spk */
691.1Spk
701.1Spk#define XYC_GBSY     0x80     /* go/busy */
711.1Spk#define XYC_ERR	     0x40     /* error */
721.1Spk#define XYC_DERR     0x20     /* double error! */
731.1Spk#define XYC_IPND     0x10     /* interrupt pending */
741.1Spk#define XYC_ADRM     0x08     /* 24-bit addressing */
751.1Spk#define XYC_AREQ     0x04     /* attention request */
761.1Spk#define XYC_AACK     0x02     /* attention ack. */
771.1Spk#define XYC_DRDY     0x01     /* drive ready */
781.1Spk
791.1Spk/*
801.1Spk * Input/Output Parameter Block (iopb)
811.1Spk *
821.1Spk * all controller commands are done via iopb's.   to start a command you
831.1Spk * must do this:
841.1Spk * [1] allocate space in DVMA space for the iopb
851.1Spk * [2] fill out all the fields of the iopb
861.1Spk * [3] if the controller isn't busy, start the iopb by loading the address
871.1Spk *     and reloc in the xyc's registers and setting the "go" bit [done]
881.1Spk * [4] controller busy: set AREQ bit, and wait for AACK bit.
891.1Spk *     add iopb to the chain, and clear AREQ to resume I/O
901.1Spk *
911.1Spk * when the controller is done with a command it may interrupt (if you
921.1Spk * ask it to) and it will set the XYC_IPND bit in the csr.   clear
931.1Spk * the interrupt by writing one to this bit.
941.1Spk *
951.1Spk * the format of the iopb is described in section 2.4 of the manual.
961.1Spk * note that it is byte-swapped on the sun.
971.1Spk */
981.1Spk
991.1Spkstruct xy_iopb {
1001.1Spk				 /* section 2.4.2: byte 1 */
1011.1Spk	volatile u_char resv1:1; /* reserved */
1021.1Spk	volatile u_char iei:1;	 /* interrupt on each IOPB done */
1031.1Spk	volatile u_char ierr:1;	 /* interrupt on error (no effect on 450) */
1041.1Spk	volatile u_char hdp:1;	 /* hold dual port drive */
1051.1Spk	volatile u_char asr:1;	 /* autoseek retry */
1061.1Spk	volatile u_char eef:1;	 /* enable extended fn. (overlap seek) */
1071.1Spk	volatile u_char ecm:2;	 /* ECC correction mode */
1081.1Spk#define XY_ECM 2		 /* use mode 2 (see section 2.4.2) */
1091.1Spk                                 /* section 2.4.1: byte 0 */
1101.1Spk	volatile u_char aud:1;	 /* auto-update iopb */
1111.1Spk	volatile u_char relo:1;	 /* enable multibus relocation (>16bit addrs)*/
1121.1Spk	volatile u_char chen:1;  /* chain enable, "next iopb" is valid */
1131.1Spk	volatile u_char ien:1;	 /* interrupt enable */
1141.1Spk	volatile u_char com:4;	 /* command */
1151.1Spk#define XYCMD_NOP 0x0		 /* no-op */
1161.1Spk#define XYCMD_WR  0x1		 /* write */
1171.1Spk#define XYCMD_RD  0x2		 /* read */
1181.1Spk#define XYCMD_WTH 0x3		 /* write track headers */
1191.1Spk#define XYCMD_RTH 0x4		 /* read track headers */
1201.1Spk#define XYCMD_SK  0x5		 /* seek */
1211.1Spk#define XYCMD_RST 0x6		 /* drive reset */
1221.1Spk#define XYCMD_WFM 0x7		 /* write format */
1231.1Spk#define XYCMD_RDH 0x8		 /* read header, data, and ECC */
1241.1Spk#define XYCMD_RDS 0x9		 /* read drive status */
1251.1Spk#define XYCMD_WRH 0xa		 /* write header, data, and ECC */
1261.1Spk#define XYCMD_SDS 0xb		 /* set drive size */
1271.1Spk#define XYCMD_ST  0xc		 /* self test */
1281.1Spk#define XYCMD_R	  0xd		 /* reserved */
1291.1Spk#define XYCMD_MBL 0xe		 /* maint. buffer load */
1301.1Spk#define XYCMD_MBD 0xf		 /* main. buffer dump */
1311.1Spk					/* section 2.4.4: byte 3 */
1321.1Spk	volatile u_char errno;		/* error or completion code */
1331.1Spk					/* section 2.4.3: byte 2 */
1341.1Spk	volatile u_char errs:1;		/* error summary bit */
1351.1Spk	volatile u_char resv2:2;	/* reserved */
1361.1Spk	volatile u_char ctyp:3;		/* controller type */
1371.1Spk#define XYCT_450 1			/* the 450 controller */
1381.1Spk	volatile u_char resv3:1;	/* reserved */
1391.1Spk	volatile u_char done:1;		/* done! */
1401.1Spk					/* section 2.4.6: byte 5 */
1411.1Spk	volatile u_char dt:2;		/* drive type */
1421.1Spk#define XYC_MAXDT 3			/* largest drive type possible */
1431.1Spk	volatile u_char resv4:4;	/* reserved */
1441.1Spk	volatile u_char unit:2;		/* unit # */
1451.1Spk					/* section 2.4.5: byte 4 */
1461.1Spk	volatile u_char bw:1;		/* byte(1)/word(0) xfer size */
1471.1Spk	volatile u_char intlv:4;	 /* interleave factor (0=1:1, 1=2:1, etc.) */
1481.1Spk	volatile u_char thro:3;		/* dma throttle (0=2,1=4,2=8, etc...) */
1491.1Spk#define XY_THRO 4			/* 4 == 32 dma cycles */
1501.1Spk					/* section 2.4.8: byte 7 */
1511.1Spk	volatile u_char sect;		 /* sector # */
1521.1Spk					/* section 2.4.7: byte 6 */
1531.1Spk	volatile u_char head;		/* head # */
1541.1Spk					/* section 2.4.9: byte 8,9 */
1551.1Spk	volatile u_short cyl;		/* cyl # */
1561.1Spk					/* section 2.4.10: byte a,b */
1571.1Spk	volatile u_short scnt;		/* sector count, also drive status */
1581.1Spk#define xy_dr_status scnt
1591.1Spk#define XYS_ONCL 0x80		 /* on-cylinder (active LOW) */
1601.1Spk#define XYS_DRDY 0x40		 /* drive ready (active LOW) */
1611.1Spk#define XYS_WRPT 0x20		 /* write protect */
1621.1Spk#define XYS_DPB  0x10		 /* dual-port busy */
1631.1Spk#define XYS_SKER 0x08		 /* hard seek error */
1641.1Spk#define XYS_DFLT 0x04		 /* disk fault */
1651.1Spk               	                  /* section 2.4.11: byte c,d */
1661.1Spk	volatile u_short dataa;		/* data address */
1671.1Spk					/* section 2.4.12: byte e,f */
1681.1Spk	volatile u_short datar;		/* data relocation pointer */
1691.1Spk					/* section 2.4.14: byte 11 */
1701.1Spk	volatile u_char subfn;		/* sub-function */
1711.1Spk					/* section 2.4.13: byte 10 */
1721.1Spk	volatile u_char hoff;		/* head offset for fixed/removeable drives */
1731.1Spk					/* section 2.4.15: byte 12,13 */
1741.1Spk	volatile u_short nxtiopb;	/* next iopb address (same relocation) */
1751.1Spk					/* section 2.4.16: byte 14,15 */
1761.1Spk	volatile u_short eccpat;	/* ecc pattern */
1771.1Spk					/* section 2.4.17: byte 16,17 */
1781.1Spk	volatile u_short eccaddr;	/* ecc address */
1791.1Spk};
1801.1Spk
1811.1Spk
1821.1Spk/*
1831.1Spk * errors (section 2.4.4.1)
1841.1Spk */
1851.1Spk
1861.1Spk/* software error codes */
1871.1Spk#define XY_ERR_FAIL 0xff         /* general total failure */
1881.1Spk#define XY_ERR_DERR 0xfe	 /* double error */
1891.1Spk/* no error */
1901.1Spk#define XY_ERR_AOK  0x00         /* success */
1911.1Spk
1921.1Spk#define XY_ERR_IPEN 0x01	 /* interrupt pending */
1931.1Spk#define XY_ERR_BCFL 0x03	 /* busy conflict */
1941.1Spk#define XY_ERR_TIMO 0x04	 /* operation timeout */
1951.1Spk#define XY_ERR_NHDR 0x05	 /* header not found */
1961.1Spk#define XY_ERR_HARD 0x06	 /* hard ECC error */
1971.1Spk#define XY_ERR_ICYL 0x07	 /* illegal cylinder address */
1981.1Spk#define XY_ERR_ISEC 0x0a	 /* illegal sector address */
1991.1Spk#define XY_ERR_SMAL 0x0d	 /* last sector too small */
2001.1Spk#define XY_ERR_SACK 0x0e	 /* slave ACK error (non-existent memory) */
2011.1Spk#define XY_ERR_CHER 0x12	 /* cylinder and head/header error */
2021.1Spk#define XY_ERR_SRTR 0x13	 /* auto-seek retry successful */
2031.1Spk#define XY_ERR_WPRO 0x14	 /* write-protect error */
2041.1Spk#define XY_ERR_UIMP 0x15	 /* unimplemented command */
2051.1Spk#define XY_ERR_DNRY 0x16	 /* drive not ready */
2061.1Spk#define XY_ERR_SZER 0x17	 /* sector count zero */
2071.1Spk#define XY_ERR_DFLT 0x18	 /* drive faulted */
2081.1Spk#define XY_ERR_ISSZ 0x19	 /* illegal sector size */
2091.1Spk#define XY_ERR_SLTA 0x1a	 /* self test a */
2101.1Spk#define XY_ERR_SLTB 0x1b	 /* self test b */
2111.1Spk#define XY_ERR_SLTC 0x1c	 /* self test c */
2121.1Spk#define XY_ERR_SOFT 0x1e	 /* soft ECC error */
2131.1Spk#define XY_ERR_SFOK 0x1f	 /* soft ECC error recovered */
2141.1Spk#define XY_ERR_IHED 0x20	 /* illegal head */
2151.1Spk#define XY_ERR_DSEQ 0x21	 /* disk sequencer error */
2161.1Spk#define XY_ERR_SEEK 0x25	 /* seek error */
2171.1Spk
2181.1Spk
2191.1Spk/* error actions */
2201.1Spk#define XY_ERA_PROG 0x10	 /* program error: quit */
2211.1Spk#define XY_ERA_SOFT 0x30         /* soft error: we recovered */
2221.1Spk#define XY_ERA_HARD 0x40         /* hard error: retry */
2231.1Spk#define XY_ERA_RSET 0x60         /* hard error: reset, then retry */
2241.1Spk#define XY_ERA_WPRO 0x90         /* write protected */
2251.1Spk
2261.1Spk
227