#ifndef _BITREG_H_
#define _BITREG_H_

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

typedef struct bitregs {
  unsigned char reserved1[1];	/* reserved space */
  unsigned char lcmd;		/* local command register */
  unsigned char reserved2[1];	/* reserved space */
  unsigned char lstatus;	/* local status register */ 
  unsigned char reserved3[4];	/* reserved space */

  /* registers that apear only if the other side of the interface is plugged in */

  unsigned char reserved4[1];	/* reserved space */
  unsigned char rcsr;		/* remote command/status register */
  unsigned char reserved5[1];	/* reserved space */
  unsigned char addrPage;	/* remote node address page reg */
  unsigned char addrModify;	/* remote node addree modifier reg */
  unsigned char reserved6[2];	/* reserved space */
  unsigned char iack;		/* VME iack read register */
} Bit;

#define AMOD_A16_NOPRIV	0x29
#define AMOD_A16_PRIV	0x2d
#define AMOD_A24_NOPRIV 0x39
#define AMOD_A24_PRIV	0x3d

/* command bit settings in the lcmd register */

#define BIT_LC_ERR_RESET	0x80
#define BIT_LC_PSI_CLEAR	0x40
#define BIT_LC_PMI_SEND		0x20

/* status bit settings in the lstatus register */

#define BIT_LS_PARITY_ERR	0x80
#define BIT_LS_VME_BERR		0x40
#define BIT_LS_PSI_RECEIVED	0x20
#define BIT_LS_TIMEOUT_ERR	0x04
#define BIT_LS_PMI_SENT		0x02
#define BIT_LS_NO_REMOTE	0x01

/* command bit settings in the rcsr register */

#define BIT_RC_BUS_RESET	0x80
#define BIT_RC_PMI_CLEAR	0x40
#define BIT_RC_PSI_SEND		0x20
#define BIT_RC_BUS_LOCK		0x10
#define BIT_RC_USE_PAGEREG	0x08
#define	BIT_RC_IACKADD3		0x04
#define	BIT_RC_IACKADD2		0x02
#define	BIT_RC_IACKADD1		0x01

/* status bit settings in the remnodeCmd register */

#define BIT_RS_PSI_SENT		0x20
#define BIT_RS_BUS_NOTLOCKED	0x10
#define BIT_RS_USE_PAGEREG	0x08
#define BIT_RS_PMI_RECEIVED	0x02

#define BIT_OPEN	0x1

typedef struct {
	volatile int flags;

	volatile int intrCnt;
	volatile int qsize;
	/*volatile*/ struct pollqueue inpq;

	volatile Bit *bit;
} BitSoftc;

#endif
