/*-=-=-=-=-=-=-=-=-=-=-=- RCCL/RCI Notice of Copyright -=-=-=-=-=-=-=-=-=-=-*
 *									    *
 *	Copyright (C) 1987, 1991 by John E. Lloyd.			    *
 *									    *
 *	Information on copyright permissions, as well as a complete	    *
 *	disclaimer of warranty, is given in the file COPYRIGHT.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#ifndef _XYDDRIVER_H_
#define _XYDDRIVER_H_

#if !defined(sgi) || !defined(_AIX)
#define volatile
#endif

/* CSR flags and bits */
#define XYD_CSR_2		0x80
#define XYD_CSR_1		0x40
#define XYD_CSR_0		0x20
#define XYD_RESET		0x10
#define XYD_INTR_ENABLE		0x08
#define XYD_INTR_PENDING	0x04
#define XYD_GREEN_ON		0x02
#define XYD_RED_OFF		0x01

#define XYD_LISTEN		0x1234
#define XYD_READ_READY		0x1111
#define XYD_WRITE_READY		0x2222
#define XYD_SIGNAL_ACK		0x3333

#define XYD_INTR_MASK		0x0001

/* these bits are set in the 'pbuf' (protocol buf) register */
#define XYD_INTR_SEND		0x0001
#define XYD_SIGOUT		0x0002
#define XYD_SIGIN		0x0200

#define XYD_PORT_DIRECTIONS	0xf2	/* 0,2,3 input, 1,4,5,6,7 output */

#define XYD_DEFAULT_BLOCKTIME	100	/* 100 milliseconds */

struct xydreg { 
	unsigned volatile char unused1[0x80];
	unsigned volatile char intrInputs;
	unsigned volatile char csr;
  	unsigned volatile char intrPending;
	unsigned volatile char intrMask;
	unsigned volatile char intrClear;
	unsigned volatile char intrVector;
	unsigned volatile char outFlags;
	unsigned volatile char portDirection;
	unsigned volatile short pbuf;
	unsigned volatile short ibuf;
	unsigned volatile short obuf;
	unsigned volatile short spareBuf;
	unsigned volatile char unused2[0x370];
};

extern xydRead();
extern xydTestRead();
extern xydWrite();
extern xydTestWrite();

extern xydProbe();
extern xydAttach();
extern xydDetach();
extern xydSignal();

extern xydIoctl();

extern xydIntrAttach();
extern xydIntrHandler();

#endif
