File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / sys / stand / vddc.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:24:19 2019 UTC (6 years, 11 months ago) by root
Branches: bsd, MAIN
CVS tags: v12b, HEAD
Power 6/32 Unix version 1.2b

/*
**	Header file for the VDDC (Versabus Direct Disk Controller) Driver
*/

/*
**	DCB Command Codes
*/

#define	RD		0x80		/* Read Data */
#define	FTR		0xc0		/* Full Track Read */
#define	RAS		0x90		/* Read and Scatter */
#define	C		0xa0		/* Compare */
#define	FTC		0xe0		/* Full Track Compare */
#define	RHDE		0x180		/* Read Header, Data & ECC (not used) */
#define	WD		0x00		/* Write Data */
#define	FTW		0x40		/* Full Track Write */
#define	WTC		0x20		/* Write Then Compare */
#define	FTWTC		0x60		/* Full Track Write Then Compare */
#define	GAW		0x10		/* Gather and Write */
#define	WDE		0x100		/* Write Data & ECC (not used) */
#define	FSECT		0x900		/* Format Sector */
#define	GWC		0x30		/* Gather Write & Compare */
#define	VDSTART		0x800		/* Start drives */
#define	VDRELEASE	0xa00		/* Stop drives */
#define	SEEK		0xb00		/* Seek */
#define	INIT		0xc00		/* Initialize VDDC */
#define	DIAG		0xd00		/* Diagnose (self-test) VDDC */
#define	RSTCFG		0xe00		/* Reset/Configure VDDC/DDI/Drive(s) */
#define	VDSTATUS	0xf00		/* VDDC Status */

#define	ABORT		0x80000000	/* ABORT active i/o */

/*
**	Error / Status Symbolic Constants
*/

#define	HCRCERR		0x1		/* Header CRC Error */
#define	HCMPERR		0x2		/* Header Compare Error */
#define	WPTERR		0x4		/* Write Protect Error/Status */
#define	SZTIMEOUT	0x8		/* Seize timeout Error */
#define	DSEEKERR	0x10		/* Disk Seek Error */
#define	UCDATERR	0x20		/* Uncorrectable Data Error */
#define	NOTCYLERR	0x40		/* Not on Cylinder Error */
#define	DRVNRDY		0x80		/* Drive Not Ready Error/Status */
#define	ALTACC		0x100		/* Alternate (track) accessed Status */
#define	SEEKSTRT	0x200		/* Seek Started Status */
#define	INVDADR		0x400		/* Invalid Disk Address Error */
#define	DNEMEM		0x800		/* Non-Existant Memory Error */
#define	PARERR		0x1000		/* Memory Parity Error */
#define	DCOMPERR	0x2000		/* Data Compare Error */
#define	DDIRDY		0x4000		/* DDI Ready Error/Status */
#define	OPABRT		0x8000		/* Operator Abort (Host) Error/Status */
#define	DSERLY		0x10000		/* Data Strobe Early */
#define	DSLATE		0x20000		/* Data Strobe Late */
#define	TOPLUS		0x40000		/* Track Offset Plus */
#define	TOMNUS		0x80000		/* Track Offset Minus */
#define	CPDCRT		0x100000	/* Cntlr Performed Data Correction */
#define	HRDERR		0x200000	/* Hard Error */
#define	SFTERR		0x400000	/* Soft Error (retry succesful) */
#define	ANYERR		0x800000	/* Any Error */
#define INVCMD		0x1000000	/* Programmer error */


/*
**	DCB Status Symbolic Constants
*/

#define	DCBABT		0x10000000	/* DCB Aborted */
#define	DCBUSC		0x20000000	/* DCB Unsuccesfully Completed */
#define	DCBCMP		0x40000000	/* DCB Complete */
#define	DCBSTR		0x80000000	/* DCB Started */

/*
**	MDCB Status Symbolic Constants
*/

#define	CTLRBSY		0x10000000	/* Cntlr Busy */
#define	INTCCDE		0x60000000	/* Interrupt Cause Code */
#define	DCBINT		0x80000000	/* DCB Interrupt Flag */


/*
**	Hard Error Types
*/

#define	HTYPES	(HCRCERR|HCMPERR|WPTERR|SZTIMEOUT|DSEEKERR|UCDATERR|NOTCYLERR| \
		 DRVNRDY|INVDADR|DNEMEM|PARERR|DCOMPERR)


/*
**	Errors
*/

#define	ERRS	0x3FFF
#define	CANRETRY	(SZTIMEOUT|DSEEKERR|NOTCYLERR|DCOMPERR|UCDATERR| \
			 PARERR|DNEMEM|HCRCERR|HCMPERR)
/*
**	VDDC Interrupt Modes
*/

#define	NOINT	0x0		/* No Interrupt */
#define	INTERR	0x2		/* Interrupt on Error */
#define	INTSUC	0x1		/* Interrupt on Success */
#define	INTDUN	0x3		/* Interrupt on Error or Success */

#define	CMD_MASK 0xFF0		/* Command code mask */
				/* When a tabular approach can be used */
				/* again change this back to 0x1F0 */

struct	size
{
	daddr_t	nblocks;
	int	block0;
};



#define	VDMF	0x8000		/* Manufacturer Fault 1=good sector */
#define	VDUF	0x4000		/* User Fault 1=good sector */
#define	VDALT	0x2000		/* Alternate Sector 1=alternate */
#define	VDWPT	0x1000		/* Write Protect 1=Read Only Sector */

/*
**	Addr of Memory-Mapped I/O port for VDDC Control Register
*/

/*
**	Address of Memory-Mapped I/O Port for VDDC H/W Reset
*/

#define	VDDC_RESET(addr)	*(addr + 4) = 0;	/* reset controller */

/*
**	Start i/o to/from controller.
*/

#define VDDC_ATTENTION(ctrl,mdcbadr)  \
			{ movow(((int)mdcbadr & 0xffff0000)>>16,ctrl) ;\
			  movow( (int)mdcbadr & 0xffff, ctrl+2);\
			}

/*
**	Abort controller operation.
*/

#define VDDC_ABORT(ctrl)  \
			{ \
			  movow((ABORT & 0xffff0000)>>16,ctrl) ;\
			  movow(ABORT & 0xffff, ctrl+2);\
			}

#define	POLLTILLDONE(c, a, x)	{ vdtimeout = 1000*(x); \
			 uncache((char *)&a); \
			 while (!(a & (DCBCMP | DCBABT))) { \
				DELAY(1000); \
				vdtimeout--; \
				uncache((char *)&a); \
				if (vdtimeout <= 0) { \
					printf("VDDC: Controller timeout"); \
					VDDC_ABORT(c); \
					DELAY(20000); \
					uncache((char *)&a); \
					break; \
				} \
			 } \
			}


/* Disk Address */

typedef struct {
	char	track;			/* all 8 bits */
	char	sector;			/* low order 5 bits */
	short	cylinder;		/* low order 12 bits */
} dskadr;

/* DCB Trailer Formats */

/* Read / Write Trailer */

typedef struct {
	char		*memadr;	/* memory address */
	unsigned long	wcount;		/* 16 bit word count */
	dskadr		disk;		/* disk address */
} trrw;

/* Seek trailer format */

typedef struct {
	dskadr	seekaddr;
} trseek;

/* Format Trailer */

typedef struct {
	char	*addr;			/* data buffer to be filled on sector*/
	long	nsectors;		/* # of sectors to be formatted */
	dskadr	disk;			/* Disk physical address info */
	dskadr  hdr;			/* Header address info */
} trfmt;


/* Reset / Configure Trailer */

typedef struct {
	long	ncyl;			/* # cylinders */
	long	nsurfaces;		/* # surfaces */
	long	nsectors;		/* # sectors */
} treset;				/* # of sectors is defined by VDDC */
					/* as 32/track of 512 data bytes each */


/* DCB Format */

typedef struct fmtdcb{
	struct fmtdcb	*nxtdcb;	/* next dcb in chain or End of Chain */
	short	intflg;			/* interrupt settings and flags */
	short	opcode;			/* DCB Command code etc... */
	long	operrsta;		/* Error & Status info */
	short	fill;			/* not used */
	char	devselect;		/* Drive selection */
	char	trailcnt;		/* Trailer Word Count */
	long	err_memadr;		/* Error memory address */
	short	fill2;			/* not used */
	short	err_wcount;		/* Error word count */
	char	err_trk;		/* Error track/sector */
	char	err_sec;		/* Error track/sector */
	short	err_cyl;		/* Error cylinder adr */
	union	{
		trseek	seektrail;	/* seek command trailer */
		trrw	rwtrail;	/* read/write trailer */
		trfmt	fmtrail;	/* format trailer */
		treset	resetrail;	/* reset/configure trailer */
	} trail;
} fmt_dcb;


/* MDCB Format */

typedef struct {
	fmt_dcb	*firstdcb;		/* first dcb in chain */
	fmt_dcb	*procdcb;		/* dcb being processed */
	fmt_dcb	*intdcb;		/* dcb causing interrupt */
	long	vddcstat;		/* VDDC status */
} fmt_mdcb;


/* the total # of drive types possible */
#define NVDDRV	4

#define	XSD	0
#define	XFD	1
#define	SMD	2
#define	FSD	3


typedef struct {
	long	par_start;
	long	par_len;
} par_tab;

typedef struct {
	short	secsiz;			/* Number of bytes in a sector  */
	short	nsec;			/* Number of sectors per track */
	short	ntrak;			/* Number of tracks per cylinder */
	short	ncyl;			/* Number of cylinders */
	char	*type_name;		/* Name of drive */
	par_tab	fs_a;			/* partition a (root file system) */
	par_tab	fs_b;			/* partition b (swap) */
	par_tab	fs_c;			/* partition c (user data) */
	par_tab	fs_d;			/* partition d (maintenance cyls) */
	par_tab	fs_e;			/* partition e (all user data area) */
	par_tab	fs_f;			/* partition f (whole disk) */
	par_tab	fs_g;			/* partition g (non existant) */
	par_tab	fs_h;			/* partition h (non existant) */
} fs_tab;

/* Physical information for known disk drives.  */
#ifdef VDGENDATA
long	vddcaddr[] = { 0xf2000, 0xf2100, 0xf2200, 0xf2300 };
long	vdtimeout = 0;

fs_tab	vdst[] = {
	{512, 48,	24,	711,	"xsd",	/* 515 Mb FSD */
		{0, 30528},		/* xsd0a cyl 0 - 52 */
		{30528,	 30528},	/* xsd3b cyl 53 - 105 */
		{61056,	 345600}, 	/*xfsd3c cyl 106 - 705 */
		{406656, 2880}, 	/* xfsd3d cyl 706 - 710 */
		{0,	 406656},	/* xfsd3e cyl 0 - 705 */
		{0,	 409536}, 	/* xfsd3f cyl 0 - 710 */
		{0, 0},	{0, 0}		/* non existant partitions */
	},
	{512, 32,	24,	711,	"xfd",	/* 340 Mb FSD */
		{0,	 20352},	/* xfsd3a cyl 0 - 52 */
		{20352,	 20352},	/* xfsd3b cyl 53 - 105 */
		{40704,	 230400},	/* xfsd3c cyl 106 - 705 */
		{271104, 1920},		/* xfsd3d cyl 706 - 710 */
		{0,	 271104},	/* xfsd3e cyl 0 - 705 */
		{0,	 273024},	/* xfsd3f cyl 0 - 710 */
		{0, 0},	{0, 0}		/* non existant partitions */
	},
	{512, 32,	19,	823,	"smd",	/* 300 Mb SMD */
		{0,	 20064},	/* smd3a cyl 0 - 65 */
		{20064,	 13680},	/* smd3b cyl 66 - 110 */
		{33744,	 214928},	/* smd3c cyl 111 - 817 */
		{248672, 1520},		/* smd3d cyl 818 - 822 */
		{0,	 248672},	/* smd3e cyl 0 - 817 */
		{0,	 250192},	/* smd3f cyl 0 - 822 */
		{0, 0},	{0, 0}		/* non existant partitions */
	},
	{512, 32,	10,	823,	"fsd",	/* 160 Mb FSD */
		{0,	 9600},		/* fsd3a cyl   0 -  59 */
		{0,	 12000},	/* fsd3b cyl  60 - 134 */
		{0,	 108480},	/* fsd3c cyl 135 - 812 */
		{0,	 800},		/* fsd3d cyl 813 - 822 */
		{0,	 130080},	/* fsd3e cyl   0 - 812 */
		{0,	 131680},	/* fsd3f cyl   0 - 822 */
		{0, 0},	{0, 0}       /* non existant partitions */
	}
};
#else
extern long	vddcaddr[];
extern long	vdtimeout = 0;

extern fs_tab	vdst[];
#endif


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.