/*DDK*************************************************************************/
/*                                                                           */
/* COPYRIGHT    Copyright (C) 1992 IBM Corporation                           */
/*                                                                           */
/*    The following IBM OS/2 source code is provided to you solely for       */
/*    the purpose of assisting you in your development of OS/2 device        */
/*    drivers. You may use this code in accordance with the IBM License      */
/*    Agreement provided in the IBM Developer Connection Device Driver       */
/*    Source Kit for OS/2. This Copyright statement may not be removed.      */
/*                                                                           */
/*****************************************************************************/
/* SCCSID = "src/snooper/parallel/partype.h, parsnp, c.basedd, currbld 96/04/26" */
/****************************************************************************/
/************************** START OF SPECIFICATIONS ***************************/
/*                                                                            */
/*   SOURCE FILE NAME:  PARTYPE.H                                             */
/*                                                                            */
/*   DESCRIPTIVE NAME:  PARALLEL port snooper TYPEDEF include file.           */
/*                                                                            */
/*   FUNCTION: This module is the PARALLEL port snooper device driver         */
/*             TYPEDEF include file.                                          */
/*                                                                            */
/*   NOTES:                                                                   */
/*      DEPENDENCIES: None                                                    */
/*      RESTRICTIONS: None                                                    */
/*                                                                            */
/*   ENTRY POINTS:  None                                                      */
/*                                                                            */
/*   EXTERNAL REFERENCES:  None                                               */
/*                                                                            */
/* Change Log                                                                 */
/*                                                                            */
/*  Mark    yy/mm/dd  Programmer      Comment                                 */
/*  ----    --------  ----------      -------                                 */
/*          96/01/09  Frank Schroeder Original developer.                     */
/*                                                                            */
/**************************** END OF SPECIFICATIONS ***************************/
typedef struct _BIOSDATAAREA  /* BIOS Data Area */
{
  USHORT  parBaseAddr[4];     /* parallel port base address */

} BIOSDATAAREA, *NPBIOSDATAAREA, FAR *FPBIOSDATAAREA;

/*----------------------------------------------*/
/* timerElement_t used to manage internal timers*/
/*----------------------------------------------*/
typedef struct _timer_element_t
{
  USHORT                TimerCount;
  void                  (*TimeoutRtn)( void *pInst );

} timerElement_t;

#define TIMERS_PER_INSTANCE     2


typedef USHORT pio_info_t;

/*----------------------------------------------*/
/* parInstance_t defines per adapter information*/
/*----------------------------------------------*/
typedef struct _parInstance_t
{
  /*----------------------------------*/
  /* Pointer to next active instance  */
  /*----------------------------------*/
  struct _parInstance_t         *pNextInst;

  /*-------------------*/
  /* ADD Work Queue    */
  /*-------------------*/
  RPH                           FAR *pRP;
  RPH                           FAR *pRPHead;
  RPH                           FAR *pRPFoot;

  /*--------------------------------------*/
  /* Instance Flags field (see F_* below) */
  /*--------------------------------------*/
  ULONG                         Flags;

  /*-------------------------------*/
  /* Inner state machine variables */
  /*-------------------------------*/
  USHORT                        UseCount;
  USHORT                        State;

  USHORT                        DataCount;
  USHORT                        ReqDataCount;
  UCHAR                         FAR *pDataBuf;
  SEL                           GDTSel;
  ULONG                         LockHandle;

  /*-------------------------------*/
  /* Outer state machine variables */
  /*-------------------------------*/
  USHORT                        ReqUseCount;
  USHORT                        ReqState;
  void                          (*DoneRtn)( struct _parInstance_t *pInst );

  USHORT                        ProcUseCount;

  void                          (*IRQRtn)( struct _parInstance_t *pInst );

  pio_info_t                    pIO[1];

  /*-------------------------*/
  /* Instance timer elements */
  /*-------------------------*/
  timerElement_t                Timers[TIMERS_PER_INSTANCE];

  USHORT                        IdleTimeoutMS;
  USHORT                        TimeoutMS;

  USHORT                        ReturnCode;

  /*--------------------------*/
  /* Chipset register images  */
  /*--------------------------*/
  UCHAR                         ControlReg;
  UCHAR                         StatusReg;
  UCHAR                         IRQINFOIndex;

  /*-----------------------*/
  /* CommMode Information  */
  /*-----------------------*/
  UCHAR                         ExtReqByte;
  UCHAR                         ReqCommMode;
  UCHAR                         CurCommMode;

} parInstance_t;

/*----------------------------------------------*/
/* parInstance_t->Flags                         */
/*----------------------------------------------*/
#define F_WAIT_STATE            0x80000000
#define F_INTERRUPT_EXPECTED    0x40000000
#define F_NO_INTERRUPT          0x20000000
#define F_TIMEOUT               0x10000000
#define F_ADDRESS_CYCLE         0x08000000
#define F_WRITE_REQ             0x04000000
#define F_Q_ACTIVE              0x02000000
#define F_FIFO_SUPPORT          0x01000000
#define F_EPP_SUPPORT           0x00800000
#define F_CANCELLED             0x00400000
#define F_DIRECT_MODE           0x00200000

#define F_ALLOCATED             0x00000020
#define F_RLE_COMPRESS          0x00000010
#define F_FLUSH_REQ             0x00000008
#define F_RENEGOTIATE           0x00000004
#define F_DIR_REVERSE           0x00000002
#define F_BYTE_MODE             0x00000001


/* Timer IDs */
#define TIMER_ID_0              0       /* Polling Timer           */
#define TIMER_ID_1              1       /* InterCharacter Timeout  */
#define TIMER_ID_2              2       /* Elapsed Request Timeout */


#define MAX_LPT                 3

