/*++
 ****************************************************************************
 * Copyright (c) 1999-2000 Digi International Inc., All Rights Reserved
 *
 * This software contains proprietary and confidential information of Digi
 * International Inc.  By accepting transfer of this copy, Recipient agrees
 * to retain this software in confidence, to prevent disclosure to others,
 * and to make no use of this software other than that for which it was
 * delivered.  This is an unpublished copyrighted work of Digi International
 * Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
 * prohibited.
 *
 * Restricted Rights Legend
 *
 * Use, duplication, or disclosure by the Government is subject to
 * restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
 * Technical Data and Computer Software clause at DFARS 252.227-7031 or
 * subparagraphs (c)(1) and (2) of the Commercial Computer Software -
 * Restricted Rights at 48 CFR 52.227-19, as applicable.
 *
 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
 *
 ****************************************************************************

Module Name:

   DigiDga.h

Abstract:

   This module contains the header to DigiDga.h.  Now this file will not contain
   much data, but will attempt to make the Dga module portable

Author:

   Dave E. Jones

--*/

#ifndef __DIGIDGA_H
#define __DIGIDGA_H

#if !NT5_BUILD && !_M_IA64
// NT5 and newer DDKs define these types.  They float (at compile time) from 32 to 64
// bit width depending on the size of pointers in the system being compiled for.
// Define it for NT4.
typedef ULONG        ULONG_PTR, *PULONG_PTR;
typedef LONG         LONG_PTR,  *PLONG_PTR;
typedef int          INT_PTR,   *PINT_PTR;
typedef unsigned int UINT_PTR,  *PUINT_PTR;
#endif

#define	MAX_PORTS				256
#define	MAX_IRPS				 64
#define PORT_ERROR_FILE_SIZE	 13
#define MAX_DMODE_PORTS			256
#define MAX_DMODE_RX_BUFFER		  5
#define MAX_DMODE_PUT_EVENT		 10
#define BUFFER_SIZE			   4096
#define NUM_OVERLAPPED			  3

// Application Defines
#define MONITOR_DATA		(1<<0)
#define MONITOR_MSTAT		(1<<1)
#define MONITOR_EVENTS		(1<<2)
#define TIMESTAMP_FORMAT	"%10.3lf"

typedef unsigned long ULONG, *PULONG;
typedef unsigned short USHORT, *PUSHORT;
typedef unsigned char UCHAR, *PUCHAR;
typedef UCHAR BOOLEAN;           
typedef LONG NTSTATUS;


#define DIGITRACE         DEBUG_00100000


#define IOCTL_DIGI_CONTROLLER_SPECIAL		CTL_CODE(FILE_DEVICE_CONTROLLER, 2048, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_DIGI_GET_CONTROLLER_DATA		CTL_CODE(FILE_DEVICE_CONTROLLER, 2051, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_DIGI_GET_PORT_STATUS			CTL_CODE(FILE_DEVICE_CONTROLLER, 2055, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_DIGI_GET_PORT_TRACE			CTL_CODE(FILE_DEVICE_CONTROLLER, 2056, METHOD_BUFFERED, FILE_ANY_ACCESS)


typedef struct _CARD_STATUS
{
   ULONG State;
   ULONG Type;
   PVOID DeviceExt;
   ULONG NumberOfPorts;
   struct 
   {
      USHORT Count;
      USHORT LowTide;
      USHORT HighTide;
      USHORT Size;
   } PutPool;
   struct 
   {
      USHORT Count;
      USHORT LowTide;
      USHORT HighTide;
      USHORT Size;
   } GetPool;
   struct 
   {
      USHORT Count;
      USHORT LowTide;
      USHORT HighTide;
      USHORT Size;
   } RxPool;
   struct 
   {
      USHORT Count;
      USHORT LowTide;
      USHORT HighTide;
      USHORT Size;
   } ExtRxPool;

   UCHAR OpenPorts[MAX_PORTS];

} CARD_STATUS, *PCARD_STATUS;


typedef struct _PORT_STATUS
{
   ULONG		State;
   ULONG		Speed;

   USHORT		Tin;
   USHORT		Tout;
   USHORT		Tmax;
   USHORT		Rin;
   USHORT		Rout;
   USHORT		Rmax;
   USHORT		Edelay;
   USHORT		Iflag;
   USHORT		Oflag;
   USHORT		Cflag;
   USHORT		Xflag;
   USHORT		Ttime;

   USHORT		Estat;
   USHORT		Norun;
   USHORT		Noflow;
   USHORT		Nframe;
   USHORT		Nparity;
   USHORT		Nbreak;
   USHORT		Ltime;

   UCHAR		Iempty;
   UCHAR		Ilow;
   UCHAR		Idata;
   UCHAR		Xon;
   UCHAR		Xoff;
   UCHAR		Mflow;
   UCHAR		Tbusy;
   UCHAR		Mstat;
   UCHAR		Mint;
   UCHAR		Buffer[3];

   struct 
   {
      ULONG		Bin, Bout, Bmax, ScannedBytes, InsertCount;
      BOOLEAN	ScanForSpecialChar;
      struct 
	  {
         LARGE_INTEGER		Time;
         ULONG				Interval;
         ULONG				Multiplier;
         ULONG				Total;
         PVOID				Irp;
      } Timeout;
   } Read;

   struct 
   {
      struct 
	  {
         LARGE_INTEGER  Time;
         ULONG			Constant;
         ULONG			Multiplier;
         PVOID			Irp;

      } Timeout;

   }  Write;
   struct 
   {
      ULONG			History;
	  ULONG			Mask;
	  ULONG			Active;
      PVOID			Irp;

   }  Wait;

} PORT_STATUS, *PPORT_STATUS;


typedef enum 
{
   TRACETYPE_READ,
   TRACETYPE_WRITE,
   TRACETYPE_IOCTL,
   TRACETYPE_MODEM_STATUS

} TRACE_TYPE;

typedef struct 
{
   TRACE_TYPE     FunctionType;
   LARGE_INTEGER  Time;
   UCHAR          ModemStatus;
   ULONG_PTR      Length;

} TRACE_HEADER;

typedef struct 
{
   ULONG_PTR      Irp;
   ULONG_PTR      Status;

} READ_TRACE, WRITE_TRACE;

typedef struct 
{
   ULONG_PTR      Irp;
   ULONG_PTR      Status;
   ULONG_PTR      IoctlType;

} IOCTL_TRACE;



#define DIGI_IOCTL_DBGOUT     0x00000001
#define DIGI_IOCTL_TRACE      0x00000002
#define DIGI_IOCTL_DBGBREAK   0x00000003

typedef struct _DIGI_IOCTL_
{
   ULONG dwCommand;
   ULONG dwBufferLength;
   CHAR Char[1024];

} DIGI_IOCTL, *PDIGI_IOCTL;






#endif
