#ifndef _RCIIOCTL_H_6cc9da59_
#define _RCIIOCTL_H_6cc9da59_

#include <sys/ioctl.h>
#ifndef ITIMER_REAL
#include <sys/time.h>
#endif
#include "../rciext/crashinfo.h"
#ifdef vax
#include "../rciext/kacomm.h"
#endif

/* -=-=- Basic ioctls for RCI devices -=-=- */

/* argument to ATTACH and EXECUTE calls */
struct RCI_fxn_arg {
  int (*function)();
  int argument;
  } ;

struct RCI_fxn_arg4 {
  int (*fxn)();
  int arg[4];
  int rval;
  } ;

/* argument to HEARTBEAT call */
struct RCI_heartbeat {
  int howoften;
  int (*function)();
  int argument;
  } ;

/* blackboard structure, part of INTERFACE call */
struct RCI_bboard {
  int time_rt[1];
  /* actually, a full page allocated, so we can make it user-writeable */
  } ;

/* return from INTERFACE call */
struct RCI_interface {
  int *time;
#ifdef vax
  struct kabboard *bboards[4];
#endif
#ifdef sun
  struct RCI_bboard *bboards[1];
#endif
  unsigned char *IOpage;
  unsigned char *bus;
  int (*signal)();
  int (*printf)();
  int (*badaddr)();
  int (*timeout)();
  int (*sigslave)();
  int (*useracc)();
  int (*vslock)();
  int (*vsunlock)();
  int (*kutcall)();
  int (*uprintf)();
  struct timeval (*wallclock)();
  int (*setTrace)();
  int (*clearTrace)();
  int (*spare1)();
  int (*spare2)();
  int (*spare3)();
  int (*spare4)();
  int (*lockWriteBuf)();
  int (*lockReadBuf)();
  } ;

/* argument to TIMEOUT call */
struct RCI_timeout {
  int clockno;
  int when;
  int (*function)();
  int argument;
  } ;

#ifdef __GNUC__

#define RCIIOC_CONFIRM   _IO('R',1)
#define RCIIOC_ATTACH    _IOW('R',2,struct RCI_fxn_arg)
#define RCIIOC_EXECUTE   _IOW('R',3,struct RCI_fxn_arg)
#define RCIIOC_DETACH    _IO('R',4)
#define RCIIOC_REQSIGS   _IO('R',5)
#define RCIIOC_HEARTBEAT _IOW('R',6,struct RCI_heartbeat)
#define RCIIOC_ONCRASH   _IOW('R',7,int)
#define RCIIOC_GETCRASH  _IOW('R',8,CRASHINFO*)
#define RCIIOC_INTERFACE _IOR('R',9,struct RCI_interface)
#define RCIIOC_TIMEOUT   _IOW('R',10,struct RCI_timeout)
#define RCIIOC_KRNLEXEC  _IOWR('R',11,struct RCI_fxn_arg4)
#define RCIIOC_KUTEXEC   _IOWR('R',12,struct RCI_fxn_arg4)

#define RCIIOC_GETCLKRATE	_IOR('R',20,int)
#define RCIIOC_SETCLKRATE	_IOW('R',21,int)
#define RCIIOC_SETCLKDEBUG	_IOW('R',22,int)
#define RCIIOC_CLKSTATUS	_IOR('R',23,int)
#define RCIIOC_CLKENABLE	_IO('R',24)
#define RCIIOC_CLKDISABLE	_IO('R',25)

#else

#define RCIIOC_CONFIRM   _IO(R,1)
#define RCIIOC_ATTACH    _IOW(R,2,struct RCI_fxn_arg)
#define RCIIOC_EXECUTE   _IOW(R,3,struct RCI_fxn_arg)
#define RCIIOC_DETACH    _IO(R,4)
#define RCIIOC_REQSIGS   _IO(R,5)
#define RCIIOC_HEARTBEAT _IOW(R,6,struct RCI_heartbeat)
#define RCIIOC_ONCRASH   _IOW(R,7,int)
#define RCIIOC_GETCRASH  _IOW(R,8,CRASHINFO*)
#define RCIIOC_INTERFACE _IOR(R,9,struct RCI_interface)
#define RCIIOC_TIMEOUT   _IOW(R,10,struct RCI_timeout)
#define RCIIOC_KRNLEXEC  _IOWR(R,11,struct RCI_fxn_arg4)
#define RCIIOC_KUTEXEC   _IOWR(R,12,struct RCI_fxn_arg4)

#define RCIIOC_GETCLKRATE	_IOR(R,20,int)
#define RCIIOC_SETCLKRATE	_IOW(R,21,int)
#define RCIIOC_SETCLKDEBUG	_IOW(R,22,int)
#define RCIIOC_CLKSTATUS	_IOR(R,23,int)
#define RCIIOC_CLKENABLE	_IO(R,24)
#define RCIIOC_CLKDISABLE	_IO(R,25)

#endif

/* -=-=- Basic ioctls for RCI clock devices -=-=- */

#endif
