/* **************************
 * *                        *
 * *   RDA Kernel Driver    *
 * *  Private Declarations  *
 * *                        *
 * **************************
 *
 * File: rda/kernelmod/kernelmod.h
 */

/* Prefix for diagnostic messages from the driver
 */
#define KERNMSG KERN_INFO RDA_DRIVER_NAME ": " 

/* ------------------------------
 * State variables for a serial I/O channel.
 */
#define IOSFIFOSIZE 100
struct ioSerialFIFO {		/* FIFOs between IOCTLs and IntHandlers */
  int wPtr, rPtr ;		/*   Write and Read pointers (offsets) */
  unsigned short buf[ IOSFIFOSIZE ] ; /* Buffered chars w/optional housekeeping */
  int iErrors ;			/* Error count */
} ;
struct ioSerialTx {		/* State of serial Tx encoder */
  int iData ;			/*   Output word being serialized */
  int iBitState ; 		/*   State of Tx bit encoder */
  int iParity ;			/*   Running parity of output stream */
  struct semaphore sem ;	/*   lock for multiple IOCTL writers */
  struct ioSerialFIFO fifo ;	/*   Source of data to encode */
} ;
struct ioSerialRx {		/* State of serial Rx decoder */
  int iData ;			/*   Input word being serialized */
  int iBitState ; 		/*   State of Rx bit decoder */
  int iBit3x ;			/*   Cycles for original 3x bit sampling */
  int iParity ;			/*   Running parity of input stream */
  int iFlushed ;		/*   Number of startup reads flushed so far */
  struct semaphore sem ;	/*   lock for multiple IOCTL readers */
  struct ioSerialFIFO fifo ;
} ;
struct intActionWorkTTY {	/* Top-level container */
  struct intActionArgsTTY args ;/*   Original user specifications */
  struct ioSerialTx Tx ;	/*   Transmitter state */
  struct ioSerialRx Rx ;	/*   Receiver state */
} ;

/* ------------------------------
 * Function Prototypes
 */
int rda_ioctl_check( unsigned int cmd_a, unsigned long arg_a ) ;

int proc_calc_metrics
( char *buf_a, char **start_a, off_t offset_a, int count_a,
  int *eof, int len_a ) ;

int rdabrds_init( void ) ;
void rdabrds_exit( void ) ;
int rdabrds_proc_read_nodeinfo( char *buf_a, int count_a ) ;

int rdabrds_proc_read_configspace
( char *buf_a, char **start_a, off_t offset_a,
  int count_a, int *eof_a, void *data_a ) ;

int rdabrds_proc_read_boardlog
( char *buf_a, char **start_a, off_t offset_a,
  int count_a, int *eof_a, void *data_a ) ;

int rdabrds_proc_write_reconfig
( struct file *file_a, const char *buffer_a,
  unsigned long count_a, void *data_a ) ;

int rvpio_init( void ) ;
void rvpio_exit( void ) ;
int rvpio_proc_read_nodeinfo( char *buf_a, int count_a ) ;

int  ioSerialGetTxBit( struct intActionWorkTTY *pIO_a ) ;
void ioSerialPutRxBit( struct intActionWorkTTY *pIO_a, int iRxBit_a ) ;

/* ------------------------------
 * Global shared variables
 */
extern struct file_operations rdabrds_fops_c ;
extern struct file_operations rvpproc_fops_c ;
extern struct file_operations rvpuser_fops_c ;
