#ifndef _XYDREG_H_
#define _XYDREG_H_

#ifdef KERNEL
#include "sys/rci.h"
#include "sys/poll.h"
#else
#include <sys/poll.h>
#include "rci.h"
#endif

typedef struct {
  unsigned char id[0x40];
  unsigned char unused1[0x40];
  unsigned char intin;
  unsigned char csr;
#define XYD_RED       0x01
#define XYD_RED_ON    0x00
#define XYD_RED_OFF   0x01
#define XYD_GREEN     0x02
#define XYD_GREEN_ON  0x02
#define XYD_GREEN_OFF 0x00
#define XYD_INTPEND   0x04
#define XYD_INTENB    0x08
#define XYD_RESET     0x10
#define XYD_USER      0xe0
  unsigned char intpend;
  unsigned char intmask;
  unsigned char intclear;
  unsigned char vector;
  unsigned char out;
  unsigned char dirs;
  unsigned char ports[8];
  unsigned char unused2[0x370];
  } Xyd;

/* defines max. number of actual XVME-240 units possible */
#define NUM_UNIT_BITS	4

/* defines the number of device sub-types possible for each unit */
#define NUM_DEV_TYPES	3

/* codes for each of the device sub-types */
#define XYD_TYPE	0
#define XY2DA_TYPE	1
#define XY2DB_TYPE	2

/* control masks and codes */
#define XYD_DIRMASK	0xf2
#define XY2D_DIRMASK	0x33
#define XYD_INTRMASK	0x01
#define XY2DA_INTRMASK	0x01
#define XY2DB_INTRMASK	0x10
#define XYD_INTRCLEAR   0xff
#define XY2DA_INTRCLEAR 0x01
#define XY2DB_INTRCLEAR 0x10

typedef struct {
	volatile int intrCnt;
	volatile int qsize;
	/*volatile*/ struct pollqueue inpq;
	unsigned int intrClear;		/* mask used to clear interrupts */
	unsigned int intrMask;		/* appropriate interrupt mask */
	int buf1;
	int type;
	int buf2;
} XydSubInfo;

typedef struct {
	volatile int flags;

	XydSubInfo subi[NUM_DEV_TYPES];

	volatile Xyd *xyd;
} XydSoftc;

#endif
