/*-=-=-=-=-=-=-=-=-=-=-=- 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 _XY2DDRIVER_H_
#define _XY2DDRIVER_H_

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

/* CSR flags and bits */
#define XY2D_RESET		0x10
#define XY2D_INTR_ENABLE	0x08
#define XY2D_INTR_PENDING	0x04
#define XY2D_GREEN_ON		0x02
#define XY2D_RED_OFF		0x01

/* output protocol bits for the outFlags register */
#define XY2D_INTR_SEND1		0x01
#define XY2D_SIGOUT1		0x02
#define XY2D_INTR_SEND2		0x10
#define XY2D_SIGOUT2		0x20

/* input protocol bits for the intrInputs register */
#define XY2D_INTR_REQ1		0x01
#define XY2D_SIGIN1		0x02
#define XY2D_INTR_REQ2		0x10
#define XY2D_SIGIN2		0x20

/* signature bits for the current output data buffer */
#define XY2D_LISTEN		0x1234
#define XY2D_READ_READY		0x1111
#define XY2D_WRITE_READY	0x2222
#define XY2D_SIGNAL_ACK		0x3333

#define XY2D_PORT_DIRECTIONS	0x33	/* 2,3,6,7 input, 0,1,4,5 output */
#define XY2D_INTR_MASK		(XY2D_INTR_REQ1|XY2D_INTR_REQ2)

#define XY2D_DEFAULT_BLOCKTIME	100	/* 100 milliseconds */

struct xy2dreg { 
	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 buf[4];
	unsigned volatile char unused2[0x370];
};

extern xy2dRead();
extern xy2dTestRead();
extern xy2dWrite();
extern xy2dTestWrite();

extern xy2dProbe();
extern xy2dAttach();
extern xy2dDetach();
extern xy2dSignal();

extern xy2dIoctl();

extern xy2dIntrAttach();
extern xy2dIntrHandler();

#endif
