/*****************************************************************************/
/*  (C) Copyright 1998 by DNA Enterprises, Inc.                              */
/*  All rights reserved                                                      */
/*****************************************************************************/
/*  CIO_FIFO.H - Header file for cio_fifo.c                                  */
/*                                                                           */
/*                                                                           */
/*  FUNCTIONS:                                                               */
/*                                                                           */
/*                                                                           */
/*  STATIC FUNCTIONS:                                                        */
/*    None                                                                   */
/*                                                                           */
/*                                                                           */
/*  GLOBAL VARIABLES DEFINED                                                 */
/*                                                                           */
/*                                                                           */ 
/*****************************************************************************/

#ifndef _CIO_FIFO_H
#define _CIO_FIFO_H

/*---------------------------------------------------------------------------*/
/* INCLUDES AND LOCAL DEFINES                                                */
/*---------------------------------------------------------------------------*/


/*---------------------------------------------------------------------------*/
/* GLOBAL VARIABLES                                                          */
/*---------------------------------------------------------------------------*/


/*---------------------------------------------------------------------------*/
/* FILE LOCAL (STATIC) VARIABLES                                             */
/*---------------------------------------------------------------------------*/


/*---------------------------------------------------------------------------*/
/* FILE LOCAL (STATIC) PROTOTYPES                                            */
/*---------------------------------------------------------------------------*/

/*---------------------------------------------------------------------------*/
/* FUNCTIONS                                                                 */
/*---------------------------------------------------------------------------*/



/*****************************************************************************/
/*  int cio_pci_fifo_open(const char *path, unsigned flags, int mode)        */
/*                                                                           */ 
/*  This routine opens the FIFO channel to the host.                         */
/*                                                                           */
/*  Parameters:                                                              */
/*  - path parameter is ignored.                                             */
/*  - flags parameter specifies how the device is manipulated.               */
/*  - mode parameter is ignored.                                             */
/*                                                                           */
/*  Return:                                                                  */
/*  - a stream number on success or <0 on failure                            */
/*                                                                           */
/*  Notes:                                                                   */
/*  - this function utilizes the pci_fifo_open routine                       */
/*  - only one open stream is supported                                      */
/*                                                                           */ 
/*****************************************************************************/
int cio_pci_fifo_open(const char *path, unsigned flags, int mode);



/*****************************************************************************/
/*  int cio_pci_fifo_read(int fildes, char *bufptr, unsigned cnt)            */
/*                                                                           */ 
/*  This routine reads 'cnt' bytes of data from the FIFO.                    */
/*                                                                           */
/*  Parameters:                                                              */
/*  - fildes parameter is the file descriptor returned from a successful     */
/*      open call                                                            */
/*  - bufptr parameter is the location of the buffer where read data         */
/*      is placed.                                                           */
/*  - cnt parameter is the number of characters to be read from the device,  */
/*      note that this device requires that 4 bytes are read at once, so     */
/*      this value must be a multiple of 4. If it is not, a partial count    */
/*      will be returned                                                     */
/*                                                                           */
/*  Return:                                                                  */
/*  - the number of characters read or -1 on failure                         */
/*                                                                           */
/*  Notes:                                                                   */
/*  - this function will use the pci_fifo_async_receive routine and          */
/*      wait internally for the completion of the async transfer, this       */
/*      allows for the use of DMA transfers but will not return until        */
/*      complete                                                             */
/*                                                                           */ 
/*****************************************************************************/
int cio_pci_fifo_read(int fildes, char *bufptr, unsigned cnt);


/*****************************************************************************/
/*  int cio_pci_fifo_write(int fildes, const char *bufptr, unsigned cnt)     */
/*                                                                           */ 
/*  This routine writes 'cnt' bytes of data to the FIFO.                     */
/*                                                                           */
/*  Parameters:                                                              */
/*  - fildes parameter is the file descriptor returned from a successful     */
/*      open call                                                            */
/*  - bufptr parameter is the location of the buffer of data to be sent to   */
/*      the device, this  will be aligned to a 32bit address before sending  */
/*  - cnt parameter is the number of characters to be sent to the device,    */
/*      note that this device requires that 4 bytes are written at once, so  */
/*      the buffer is padded with zeros if cnt is not a multiple of 4        */
/*                                                                           */
/*  Return:                                                                  */
/*  - the number of non-zero padded characters written or -1 on failure      */
/*                                                                           */
/*  Notes:                                                                   */
/*  - this function will use the pci_fifo_async_send routine and wait        */
/*      internally for the completion of the async transfer, this allows     */
/*      for the use of DMA transfers but will not return until complete      */
/*                                                                           */ 
/*****************************************************************************/
int cio_pci_fifo_write(int fildes, char *bufptr, unsigned cnt);


/*****************************************************************************/
/*  long cio_pci_fifo_lseek(int fildes, long offset, int origin)             */
/*                                                                           */ 
/*  This routine is not supported.                                           */
/*                                                                           */
/*  Parameters:                                                              */
/*  -                                                                        */
/*                                                                           */
/*  Return:                                                                  */
/*  - always returns EOF since lseek is not supported                        */
/*                                                                           */
/*  Notes:                                                                   */
/*  - lseek is not supported                                                 */
/*                                                                           */ 
/*****************************************************************************/
fpos_t cio_pci_fifo_lseek(int fildes, long offset, int origin);


/*****************************************************************************/
/*  int cio_pci_fifo_close(int fildes)                                       */
/*                                                                           */ 
/*  This routine closes the FIFO device.                                     */
/*                                                                           */
/*  Parameters:                                                              */
/*  - fildes parameter is the file descriptor returned from a successful     */
/*      open call                                                            */
/*                                                                           */
/*  Return:                                                                  */
/*  - returns 0 on success or -1 on failure                                  */
/*                                                                           */
/*  Notes:                                                                   */
/*  - this function will utilize the pci_fifo_close routine                  */
/*                                                                           */ 
/*****************************************************************************/
int cio_pci_fifo_close(int fildes);


/*****************************************************************************/
/*  int cio_pci_fifo_unlink(const char *path)                                */
/*                                                                           */ 
/*  This routine is not supported.                                           */
/*                                                                           */
/*  Parameters:                                                              */
/*  -                                                                        */
/*                                                                           */
/*  Return:                                                                  */
/*  - always returns -1 since unlink is not supported                        */
/*                                                                           */
/*  Notes:                                                                   */
/*  - unlink is not supported                                                */
/*                                                                           */ 
/*****************************************************************************/
int cio_pci_fifo_unlink(const char *path);


/*****************************************************************************/
/*  int cio_pci_fifo_rename(const char *old_name, const char *new_name)      */
/*                                                                           */ 
/*  This routine is not supported.                                           */
/*                                                                           */
/*  Parameters:                                                              */
/*  -                                                                        */
/*                                                                           */
/*  Return:                                                                  */
/*  - always returns -1 since rename is not supported                        */
/*                                                                           */
/*  Notes:                                                                   */
/*  - rename is not supported                                                */
/*                                                                           */ 
/*****************************************************************************/
int cio_pci_fifo_rename(const char *old_name, const char *new_name);

#endif /* end of #ifndef _CIO_FIFO_H */