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

#define VEM_LISTEN		0x1234
#define VEM_CONNECTED		0x4321
#define VEM_READ_READY	 	0x1111
#define VEM_WRITE_READY		0x2222
#define VEM_SIGNAL_ACK		0x3333

#define VEM_BUFSIZE		256

#define VEM_DEFAULT_BLOCKTIME	200	/* 200 milliseconds */

/* Shared memory control area */

struct vemdev {
  
   /* Data and control information written by the host */

   unsigned short hostMode;
   unsigned short hostStatus;
   unsigned short hostSignal;
   unsigned short hostCount;
   unsigned short hostChecksum;
   unsigned short hostReady;
   unsigned short hostSigReady;
   unsigned short hostBuf[VEM_BUFSIZE];


   /* Data and control information written by the target device */

   unsigned short targetMode;
   unsigned short targetStatus;
   unsigned short targetSig;
   unsigned short targetCount;
   unsigned short targetChecksum;
   unsigned short targetReady;
   unsigned short targetSigReady;
   unsigned short targetBuf[VEM_BUFSIZE];
};

extern vemRead();
extern vemTestRead();
extern vemWrite();
extern vemTestWrite();

extern vemProbe();
extern vemAttach();
extern vemDetach();
extern vemSignal();

extern vemIoctl();

struct vemregs {
  unsigned char reserved1[1];	/* reserved space */
  unsigned char cmdreg;		/* local command register */
  unsigned char reserved2[1];	/* reserved space */
  unsigned char statreg;	/* 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 remnodeCmd;	/* 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[1];	/* reserved space */
};

#define MEM_VME_AMSSIO	0x2d;	/* VME address mod. supervisor short I/O */

/* special diagnostic ioctls for the vem device */

#define IOC_PRINT_REGS	100

/* command bit settings in the remnodeCmd register */

#define	VEM_VME_IACKADD1	0x01
#define	VEM_VME_IACKADD2	0x02
#define	VEM_VME_IACKADD3	0x04
#define VEM_USEPAGEREG		0x08
#define VEM_LOCKVME		0x10
#define VEM_SETPRIT		0x20
#define VEM_CLEARPRIT		0x40
#define VEM_RESETVME		0x80

#endif
