/*
 * $Header: /smsa/bsd:include/dev/winc.h:bsd  1.8  $
 * $Source: /smsa/bsd:include/dev/winc.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 */
/*
 *	ARM Winchester disc interface - hardware control structures
 *
 *	Author: J.M. Collins, Xi Software Ltd 1986.
 *	Mods:	Mark Taunton, Acorn Computers Ltd 1989.
 *
 */

#ifndef __dev_winc_h
#define __dev_winc_h

/*
 *	Define the device structure.
 */

typedef struct	winc_dev 
{
    volatile unsigned int
	hdc_command,			/*  Write  */
	hdc_parameter,			/*  Write  */
	hdc_data_in,			/*  Read  */
	hdc_filler[5],
	hdc_status,				/*  Read  */
	hdc_result,				/*  Read  */
	hdc_data_out;			/*  Write  */
} HDC, *HDCRef;

/* Internal ST506 controller, where fitted */
#define	IHD_CREGS	((HDCRef)0x32D0000)

/*
 * Address of registers on an ST506 expansion card:
 * XHD_CON(slot) gives address of interrupt/page control/status reg;
 * XHD_HDC(slot) gives address of hard disc controller registers 
 */
#define XHD_CON(slot) ((volatile unsigned char *)(XCB_ADDRESS(MEDIUM,slot)+0x3000))
#define XHD_HDC(slot) ((HDCRef)(XCB_ADDRESS(MEDIUM,slot)+0x2000))

/* Bits in a winchester expansion card control byte */
#define XHD_CON_IRQ	(1 << 3)
#define XHD_CON_HS3	(1 << 6)
#define XHD_CON_IENABLE	(1 << 7)

/*
 *	Command codes.
 */

#define	CSpecify	0xE8
#define	CPollingOn	0x10
#define	CPollingOff	0x18
#define	CCheckDrive	0x28
#define	CRestore	0xC8
#define	CSeek		0xC0
#define	CRead		0x40
#define	CWrite		0x87
#define	CFormat		0xA3
#define	CReadId		0x60
#define	CRecall		0x08
#define COpenBuffWrite	0x30
#define COpenBuffRead	0x38
#define CMemToBuff	0x90
#define CBuffToMem	0x50
#define CAbort		0xFF

/*
 *	Define bits in status byte.  Incorporate the 8-bit shift.
 */

#define	HDC_BSY		0x8000
#define	HDC_CPR		0x4000
#define	HDC_CED		0x2000
#define	HDC_SED		0x1000
#define	HDC_DER		0x0800
#define	HDC_ABN		0x0400
#define	HDC_POL		0x0200

/*
 *	No of cylinders to reserve at the front of the disc for boot and
 *	suchwhat.
 */
#define	BOOTSTART	0
#define	BOOTCYLS	4

/*
 *	Beware of the confusion between "sectors" in param.h meaning 512 bytes
 *	"sectors" here meaning 256 bytes, and blocks meaning 512 bytes or
 *	1024 bytes according to context (here 512 bytes).
 *	The driver uses the terminology "blocks" to mean 512 bytes, and
 *	"sectors" to mean 256.
 */
#define	SECSPERBLK	2
#define	BYTESPERSEC	256
#define BYTESPERBLK	BYTESPERSEC*SECSPERBLK

#endif/*__dev_winc_h*/

/* EOF winc.h */
