/* $Id: hps.asynch.h,v 2.7 91/10/21 10:45:54 steve Exp $ */
/****************************************************************/
/* hps.asynch.h													*/
/****************************************************************/
/*																*/
/*                 Confidential Information                     */
/*      Limited Distribution to Authorized Persons Only         */
/*     Created 1985 and Protected as an Unpublished Work        */
/*          Under the U.S. Copyright Act of 1976.               */
/*         Copyright (c) 1985, Systech Corporation              */
/*                  All Rights Reserved                         */
/*																*/
/*	THIS SOFTWARE IS LICENSED BY AND IS THE	CONFIDENTIAL AND 	*/
/*	PROPRIETARY PROPERTY OF SYSTECH COMPUTER CORPORATION AND 	*/
/*	MAY NOT, WITHOUT THE PRIOR WRITTEN CONSENT OF SYSTECH 		*/
/*	COMPUTER CORPORATION, BE REPRODUCED, USED OR DISCLOSED 		*/
/*	EXCEPT IN ACCORDANCE WITH A SYSTECH COMPUTER CORPORATION 	*/
/*	SOFTWARE LICENSE AGREEMENT.									*/
/****************************************************************/
/*																*/
/* HPS Asynchronous Application Package Header File				*/
/*																*/
/* This header file contains definitions required by host		*/
/* programs * to communicate with the HPS Asynchronous			*/
/* Application.													*/
/*																*/
/* Precede with:												*/
/*	#include "hps.types.h"										*/
/*	#include "hps.iocb.h"										*/
/*	#include "hps.onb.h"										*/
/*	#include "hps.net.h"										*/
/*																*/
/****************************************************************/

/* Unique upper digit for queue IDs, task IDs, etc. */

#define ASYNCH_ID	40
#define MEM_ID		50

/* Asynch Application Task Parameters */

#define ASYNCH_TID	(ASYNCH_ID + 1)	/* Startup task ID			*/
#define ASYNCH_PRI	175				/* Startup task pritority	*/

#define A_HREQ_TID	(ASYNCH_ID + 6)	/* Host Request Task ID		*/
#define A_HREQ_PRI	6				/* Host Request pri.		*/

#define A_HWREQ_TID	(ASYNCH_ID + 4)	/* Host Write-Request Task ID*/
#define A_HWREQ_PRI	3				/* Host Write-Request pri.	*/

#define A_HRREQ_TID	(ASYNCH_ID + 5)	/* Host Read-Request Task ID*/
#define A_HRREQ_PRI	4				/* Host Read-Request pri.	*/

#define A_REMIF_TID	(ASYNCH_ID + 3)	/* Remote interface task ID	*/
#define A_REMIF_PRI	2				/* Remote interface priority*/

#define A_READ_TID	(ASYNCH_ID + 7)	/* Remote interface task ID	*/
#define A_READ_PRI	5				/* Remote interface priority*/


/* VRTX Queue IDs */

/* IOCB queues: */
#define ASYNCH_IOCBQ_SIZE	26
#define ASYNCH_DEV			50				/* OPEN, CLOSE, IOCTL	*/
#define ASYNCH_IOCBQ		(ASYNCH_ID | 0x01)
#define ASYNCH_R_DEV		51				/* READ					*/
#define ASYNCH_R_IOCBQ		(ASYNCH_ID | 0x02)
#define ASYNCH_W_DEV		52				/* WRITE				*/
#define ASYNCH_W_IOCBQ		(ASYNCH_ID | 0x01)

/* Network queues: */
#define ASYNCH_CNETQ_SIZE	200					/* Control channel	*/
#define ASYNCH_CSKT			20
#define ASYNCH_CNETQ		(ASYNCH_ID | 0x04)
#define ASYNCH_PSKT			23
#define ASYNCH_PNETQ		(ASYNCH_ID | 0x08)
#define ASYNCH_PNETQ_SIZE	36
#define ASYNCH_DNETQ_SIZE	165
#define ASYNCH_R_DNETQ		(ASYNCH_ID | 0x05)	/* Read channel		*/
#define ASYNCH_R_DSKT		21
#define ASYNCH_W_DNETQ		(ASYNCH_ID | 0x06)	/* Write channel	*/
#define ASYNCH_W_DSKT		22

/* fake remote queues for 6830 ie no LAN version */
#if (HPS6830 || HPS6236)
#define RIOCTL_Q		(ASYNCH_ID | 0x3)	/* "remote" contol  info q */
#define RIOCTL_Q_SIZE	20					/* "remote" contol  info q */

/* output buffer pool use 512 byte buffers */
#define A_OUTBUF_Q		MEM_512_Q

/* output buffer data structure */
#define A_OUTBUF_DATA	(512 - sizeof(SBH))
typedef struct
{
	SBH	sbh;
	char	data[A_OUTBUF_DATA];	/* data portion */
} A_OUTBUF;

/* end of 6830 stuff */
#endif

#ifdef HPS_68XX
/* Memory management queues: */
#define MEM_16_Q		MEM_ID
#define MEM_16_Q_SIZE	50
#define MEM_32_Q		(MEM_ID + 1)
#define MEM_32_Q_SIZE	8
/* #define MEM_64_Q		(MEM_ID + 2) */
#define A_CSEND_Q		(MEM_ID + 3)
#define A_CSEND_Q_SIZE	16
#define MEM_512_Q		(MEM_ID + 4)
#endif

/* Memory management queues: */
#define MEM_16_Q		MEM_ID
#define MEM_32_Q		(MEM_ID + 1)
/* #define MEM_64_Q		(MEM_ID + 2) */
#define A_CSEND_Q		(MEM_ID + 3)
#define MEM_512_Q		(MEM_ID + 4)

#define A_CSEND_Q_SIZE	16

#ifdef HPS_68XX
#if (HPS6830 || HPS6236)
#define MEM_512_Q_SIZE	96
#define MEM_64_Q_SIZE	20
#else	/* HPS6840, 6860, 6945 */
#define MEM_512_Q_SIZE	175
#define MEM_64_Q_SIZE	1000
#endif
#endif

#if (HPS6830 || HPS6236)
#define MEM_16_Q_SIZE	50
#define MEM_32_Q_SIZE	8
#define MEM_64_Q_SIZE	20
#define MEM_512_Q_SIZE	96
#else
#	if HPS624X
#	define MEM_16_Q_SIZE	100
#	define MEM_32_Q_SIZE	16
#	define MEM_64_Q_SIZE	2048
#	define MEM_512_Q_SIZE	175
#	else									/* HPS6840, 6860, 6945 */
#	define MEM_16_Q_SIZE	50
#	define MEM_32_Q_SIZE	8
#	define MEM_64_Q_SIZE	1000
#	define MEM_512_Q_SIZE	175
#	endif
#endif


/* #define A_NETHEAD_Q		MEM_64_Q */
#define A_NETHEAD_Q		(MEM_ID + 2)
/* #define A_NETBUF_Q		MEM_64_Q */
/* #define A_SBH_Q		MEM_64_Q */
#define MCB_MEM_Q		MEM_32_Q
#define A_INBUF_Q		MEM_512_Q

/* Buffer sizes */

#define EBUF_SIZE	16		/* Echo buffer size */

#define EDIT_BSIZE	255		/* Edit buffer size */

#define MIN_OBUFS	20		/* used keep output tasks from */
							/* consuming all the 64 byte buffers */
							/* Was originally in hps.custom.h lw */

#define MW_BUFSIZE	2048	/* multiple write buffer size */
#define RD_BUFSIZE	4096	/* multiple read buffer size */

/****************************************************************/
/* ASCII character codes.  The asynch application also uses the	*/
/* usual UNIX escapes, \b, \f, \n, \r, and \t.					*/
/****************************************************************/

#define ASCII_EOT	0x04
#define ASCII_BEL	0x07


/* HPS Data Stream Codes: */

#define HPS_ESC		0x00		/* Data Stream Escape				*/

#define HPS_ETX		0x80		/* End of block						*/
#define HPS_MARK	0x81		/* End of data						*/
#define HPS_CL_MARK	0x81		/* End of data: CLOSE				*/
#define HPS_DELAY	0x82		/* Insert real-time delay			*/
#define HPS_BREAK	0x83		/* Tramsmit BREAK					*/
#define HPS_NBREAK	0x84		/* Stop Tramsmitting BREAK			*/
#define HPS_FL_MARK	0x85		/* End of data: FLUSH				*/
#define HPS_WT_MARK	0x86		/* End of data: WAITO				*/
#define HPS_NOP		0x87		/* No operation						*/

#define E_ERROR		0x01		/* Rockwell 65C52 status registers	*/
#define E_2ERROR	0x02		/* 685561 status registers			*/


/* Message codes for ASYNCH_CSKT */

#define RC_BUSY			1
#define RC_OPEN			2
#define RC_CLOSE		3
#define RC_MODEMSTAT	7
#define RC_ACK			8
#define RC_MARK			9
#define RC_NODEV		16
#define RC_NOFLUSH		17
#define RC_CHSTATUS		23		/* Remote channel status			*/

#define CR_OPEN			4		/* Open channel						*/
#define CR_CLOSE		5		/* Close channel					*/
#define CR_IOCTL		6		/* Set operating parameters			*/
#define CR_START_IN		10		/* Resume sending input to controller*/
#define CR_STOP_IN		11		/* Stop sending input to controller	*/
#define CR_STOP			12		/* Stop sending output to UART		*/
#define CR_START		13		/* Resume sending output to UART	*/
#define CR_DISABLE		14		/* Disable UART receiver			*/
#define CR_ENABLE		15		/* Enable UART receiver				*/
#define CR_FLUSH		18		/* Start flushing remote output		*/
#define CR_NOFLUSH		19		/* Stop flushing remote output		*/
#define CR_ACK			20		/* Acknowledge incoming data message*/
#define CR_XON			21		/* Restart X-off'ed output			*/
#define CR_CHSTATUS		22		/* Request channel status			*/
#define CR_OVERRIDE		24		/* Close channel, even if OPENed by	*/
								/* another host.					*/
#define CR_FLUSHI		25		/* Flush input and put an 			*/
								/* HPS_FL_MARK in input data		*/
#define CR_WAITI		26		/* Put an HPS_WT_MARK in input data */
#define	CR_STARTI		27		/* Send an X-ON character			*/
#define	CR_STOPI		28		/* Send an X-OFF character			*/


/* Other */

#define MAXCOL		132		/* Maximum column # for line-printers	*/

/* To take advantage of remote lager buffer size */
#define A_BLOCK_VAR
#define A_BLOCK	a_block
/* #define A_BLOCK	122 */
#define A_MAXOUT	244

/* Input processing data buffer */
#define A_INBUF_DATA (512 - (sizeof(SBH) + 2*sizeof(short) + 2*sizeof(char *)))
typedef struct
{
	SBH		sbh;
	short	flags;
	short	length;
	char	*cptr;
	char	*end;
	char	data[A_INBUF_DATA];
} A_INBUF;


/* Output processing data buffer header */
typedef struct
{
	SBH		sbh;		/* System buffer header				*/
	char	*data;		/* Pointer to data area				*/
	short	qid;		/* Queue from which data area alocated	*/
} A_SBH;


/* Asynch Application's network buffers */
typedef struct
{
	SBH		sbh;		/* Network system buffer header		*/
	QEH		qeh;		/* Network queue element header		*/
	short	qid;
} A_NETHEAD;

#define A_NETBUF_DATA	(64 - sizeof(SBH))
typedef struct
{
	SBH		sbh;				/* Network system buffer header	*/
	char	data[A_NETBUF_DATA];/* Data area					*/
} A_NETBUF;

/* DGA 1/13/88 Added this data structure to help support custom code */
/* This structure contains the output buffer list management variables. */

typedef struct
{
	A_NETBUF	*head;	/* Free list head					*/
	long 		mbox;	/* Semaphore for waiting processes	*/
	short		waiting;/* Number of processes waiting		*/
	short		count;	/* Number of blocks on free list	*/
} OBLIST;

/****************************************************************/
/* This structure is the Asynchronous Application's IOCB.  The	*/
/* address of one of these may be passed to the HPS controller	*/
/* through the HPS raw device driver.							*/
/****************************************************************/

typedef struct a_iocb
{
	IOCBHDR	hdr;			/* Standard HPS IOCB header			*/
	bit16	command;		/* OPEN, CLOSE, READ, WRITE, IOCTL	*/
	bit16	cmd_modifier;	/* For ioctl functions				*/
	struct a_iocb *link;	/* For lists of IOCBs				*/
	bit32	cmd_param;		/* Optional parameter for some cmds */
} A_IOCB;



/* Station control structure */

typedef struct
	{
		bit32			st_sem;
#ifdef HPS6236
		bit8			st_ch[17];
		bit8			st_res1;
		bit16			st_res2;
#else
		bit8			st_ch[16];
#endif
		A_NETHEAD	   *st_qe;
		A_NETBUF	   *st_tail;
		A_NETBUF	   *st_hbp;
		char		   *st_hptr;
		struct prfinfo *st_prfp;
		bit8			st_address;
		bit8			st_flags;
#ifdef STEPUP
		bit16			st_wrchans;   /* count of number of channels on the
									  ch_wrnext linked list waiting
									  to output their data to a station   */
#else
		bit16			st_res3;
#endif
	} ST;

/* Bits for st_flags: */

#define ST_STATE			0x0F
#define ST_UNASSIGNED		0x00
#define ST_ONLINE			0x01
#define ST_ACTIVE			0x02
#define ST_ON_SUSPECT		0x03
#define ST_OFF_SUSPECT		0x04
#define ST_OFFLINE			0x05
#define ST_VERY_ACTIVE		0x06
#define ST_ON_TENTATIVE		0x07
#define ST_OFF_TENTATIVE	0x08
#define ST_CHANGED			0x10
#define ST_DUPLICATE		0x20
#define ST_CONFIRMED		0x40


/* Remote channel status structure */

#ifdef STEPUP
#define RCH_RESERVE	21
#else
#define RCH_RESERVE	23
#endif
typedef struct
{
	bit16	s_rxcount;					/* Buffered receive data			*/
	bit16	s_txcount;					/* Buffered transmit data			*/
	bit16	s_flags;					/* Copy of remote's channel flags	*/
	bit8	s_exflags;					/* Copy of remote's channel flags	*/
	bit8	s_host;						/* NW address of channel's host		*/
	bit8	s_option;					/* Cluster options available		*/
	bit8	s_reserved[RCH_RESERVE];	/* For expansion					*/
#ifdef STEPUP
	bit16	s_txbufsz;					/* Size of transmit buffer			*/
#endif
} RCH_STATUS;

/* Bit Definitions for s_option: */
#define	S_WAITI_FLSHI	0x01	/* Cluster supports CR_WAITI and CR_FLUSHI	*/
#define	S_TCXON			0x02	/* Cluster supports TCXON options 2 & 3		*/
#define	S_RXANYPAR		0x04	/* Cluster supports "ignore receive parity"	*/

/* Open Command Modifiers: */
#define CLOSE_ANYWAY	0x01	/* Send a CR_OVERRIDE to close channel */

/* Read/Write Command Modifiers: */
#define SINGLE_CHANNEL	0x00	/* Single channel read/write operation */
#define MULTI_CHANNEL	0x01	/* Multi- channel read/write operation */

/* IOCTL Command Modifiers: */

/* Set/Get parameters: */
#define AIOC_SETC   0x00  /* Set system configuration			*/
#define AIOC_GETC   0x01  /* Get system configuration			*/
#define AIOC_SETA   0x02  /* Set asynch protocol parameters		*/
#define AIOC_GETA   0x03  /* Get asynch protocol parameters		*/
#define AIOC_SETF   0x04  /* Set flow control parameters		*/
#define AIOC_GETF   0x05  /* Get flow control parameters		*/
#define AIOC_SETI   0x06  /* Set input processing parameters	*/
#define AIOC_GETI   0x07  /* Get input processing parameters	*/
#define AIOC_SETO   0x08  /* Set output processing parameters	*/
#define AIOC_GETO   0x09  /* Get output processing parameters	*/
#define AIOC_SETE   0x0A  /* Set echo parameters				*/
#define AIOC_GETE   0x0B  /* Get echo parameters				*/
#define AIOC_SETG   0x0C  /* set prot,flow,in,out,echo as a group*/
#define AIOC_GETG   0x0D  /* get prot,flow,in,out,echo as a group*/
#define AIOC_SETX   0x0E  /* Set auxiliary parameters			*/
#define AIOC_GETX   0x0F  /* Get auxiliary parameters			*/
#define AIOC_GETT	0x28  /* Get tally information */
#define AIOC_SETN	0x29  /* Set special modes for NTX channels	*/
#define AIOC_GETN	0x2A  /* Get special modes for NTX channels	*/
#define AIOC_GETV	0x30  /* Get TCS version parameters			*/
#define AIOC_GETB	0x31  /* Get number of data bytes transferred*/
#define AIOC_SETM	0x32  /* Set special software modes			*/
#define AIOC_GETM	0x33  /* Get special software modes			*/

/* I/O Control: */
#define AIOC_STOP		0x10	/* Suspend output					*/
#define AIOC_START		0x11	/* Resume output					*/
#define AIOC_RETYPE		0x12	/* Retype (re-echo) pending input	*/
#define AIOC_FLSHI		0x13	/* Flush (i.e. clear) input pipeline*/
#define AIOC_FLSHO		0x14	/* Flush (i.e. clear) output pipeline*/
#define AIOC_WAITO		0x15	/* Wait for output pipline to empty	*/
#define AIOC_GETS		0x16	/* Get channel status information	*/
#define AIOC_DISABLE	0x17	/* Disable UART receiver			*/
#define AIOC_ENABLE		0x18	/* Enable USRT receiver				*/
#define AIOC_TYPE		0x19	/* Accept character as keyboard input*/
#define AIOC_REPROCESS	0x1A	/* Re-process pending input			*/
#define AIOC_XON		0x1B	/* Override remote X-off			*/
#define AIOC_STOPI		0x1C	/* Suspend input					*/
#define AIOC_STARTI		0x1D	/* Resume input						*/
#define AIOC_WAITI		0x1E	/* Wait for input pipline to empty	*/
#define AIOC_NWAITO		0x1F	/* Asynchronous wait for output to empty	*/


/* Line Control: */
#define AIOC_BRK    0x20 /* Put data line into SPACEing state  */
#define AIOC_NBRK   0x21 /* Put data line into MARKing state   */
#define AIOC_DSR    0x22 /* Put DSR line into SPACEing state   */
#define AIOC_DSNR   0x23 /* Put DSR line into MARKing state    */
#define AIOC_CTS    0x24 /* Put CTS line into SPACEing state   */
#define AIOC_NCTS   0x25 /* Put CTS line into MARKing state    */
#define AIOC_DELAY  0x26 /* Insert real-time delay             */
#define AIOC_BDNB   0x27 /* Break, Delay, No Break             */




/* Structure for AIOC_SETC and AIOC_GETC: */
typedef struct
{
   	bit8  c_station; /* Station address for channel          */
   	bit8  c_number;  /* Port number, within station          */
} A_CONF;





/* Structures for AIOC_SETA and AIOC_GETA: */
typedef struct
{
    bit8    a_bps;    /* Baud rate - see codes below       */
    bit8    a_length; /* Character length: 5, 6, 7, or 8   */
    bit8    a_parity; /* Parity - see codes below          */
    bit8    a_stops;  /* Stop bits - see codes below       */
} A_P;

typedef struct
{
    A_P    a_r;   /* UART Receiver parameters       */
    A_P    a_t;   /* UART Transmitter parameters    */
} A_PROT;

/* Baud rate codes for a_bps: */
#define A_45    0x01    /* 45.5  bps      */
#define A_50    0x02    /* 50    bps      */
#define A_75    0x03    /* 75    bps      */
#define A_110   0x04    /* 110   bps      */
#define A_134   0x05    /* 134.5 bps      */
#define A_150   0x06    /* 150   bps      */
#define A_200	0x20    /* 200   bps	  */
#define A_300   0x07    /* 300   bps      */
#define A_600   0x08    /* 600   bps      */
#define A_1050  0x09    /* 1050  bps      */
#define A_1200  0x0A    /* 1200  bps      */
#define A_1800  0x0B    /* 1800  bps      */
#define A_2000  0x0C    /* 2000  bps      */
#define A_2400  0x0D    /* 2400  bps      */
#define A_3000  0x0E    /* 3000  bps      */
#define A_3600  0x0F    /* 3600  bps      */
#define A_4200  0x10    /* 4200  bps      */
#define A_4800  0x11    /* 4800  bps      */
#define A_5400  0x12    /* 5400  bps      */
#define A_6000  0x13    /* 6000  bps      */
#define A_6600  0x14    /* 6600  bps      */
#define A_7200  0x15    /* 7200  bps      */
#define A_7800  0x16    /* 7800  bps      */
#define A_8400  0x17    /* 8400  bps      */
#define A_9000  0x18    /* 9000  bps      */
#define A_9600  0x19    /* 9600  bps      */
#define A_102K  0x1A    /* 10.2K bps      */
#define A_108K  0x1B    /* 10.8K bps      */
#define A_192K  0x1C    /* 19.2K bps      */
#define A_384K  0x1D    /* 38.4K bps      */
#define A_EXT   0x1E    /* External       */
#define A_EXT16 0x1F    /* External / 16  */
#define A_UNSUP 0xFF    /* Unsupported baud rate */

/* Parity codes for a_parity: */
#define A_ODD    0x01  /* Generate/Accept odd parity       */
#define A_EVEN   0x02  /* Generate/Accept even parity      */
#define A_MARK   0x03  /* Generate/Accept mark parity      */
#define A_SPACE  0x04  /* Generate/Accept space parity     */
#define A_NONE   0x05  /* No parity bit                    */
#define A_EITHER 0x06  /* Accept either parity (rec. only) */

/* Stop bit codes for a_stops: */
#define A_STOP1  0x01  /* 1 stop bit        */
#define A_STOP15 0x02  /* 1.5 stop bits     */
#define A_STOP2  0x03  /* 2 stop bits       */

/* bit for modem control signals			*/
#define A_DTR		0x01		/* input */
#define A_DSR		0x02		/* output: bit set means active */
#define A_CTS		0x04		/* output: bit set means active */
#define A_RTS		0x08		/* input */
#define A_CD		0x10		/* input */
#define A_FAILED	0x40		/* input: cluster online, port failed s/t	*/
#define A_ONLINE	0x80		/* input: cluster online, port OK			*/

#define MODEM_BITS	(A_DTR | A_DSR | A_CTS | A_RTS | A_CD | A_ONLINE | A_FAILED)
#define DONT_CARES	(MODEM_BITS << 8)


/* Structure for AIOC_SETF and AIOC_GETF: */
typedef struct
{
   	bit8   f_type;		/* Flow-control protocol						*/
   	bit8   f_hiwater;	/* High-water level								*/
   	bit8   f_lowater;	/* Low-water level								*/
   	bit8   f_xon;		/* X-on or ETX character (software protocol)	*/
   	bit8   f_xoff;		/* X-off or ACK character   (software protocol)	*/
   	bit8   f_flags;		/* Flow control options (see FL_??? below		*/
} A_FLOW;

/* Flow-control type codes, for f_type: */
#define FL_IXONXOFF	0x01		/* Input X-on/X-off				*/
#define FL_OXONXOFF	0x02		/* Output X-on/X-off			*/
#define FL_IETXACK	0x04		/* Input ETX/ACK				*/
#define FL_OETXACK	0x08		/* Output ETX/ACK				*/
#define FL_ODCD		0x08		/* Output DCD					*/
#define FL_IRTSCTS	0x10		/* Input RTS/CTS				*/
#define FL_ORTSCTS	0x20		/* Output RTS/CTS				*/
#define FL_IDSRDTR	0x40		/* Input DSR/DTR				*/
#define FL_ODSRDTR	0x80		/* Output DSR/DTR				*/

/* Hardware line polarity: */
#define FL_SPACE	0x01		/* SPACE state enables xmitter		*/
#define FL_MARK		0x02		/* MARK state enables xmitter		*/
#define FL_IXANY	0x04		/* Use any character as X-on		*/



/* Structure for AIOC_SETI and AIOC_GETI: */
typedef struct
{
	bit16	i_blocks;		/* Select Input Processing Blocks	*/
	bit16	i_nescape;		/* Number of input escapes			*/
	bit8	i_escape[8];	/* Input escape characters			*/
	bit16	i_except;		/* Exception processing modes		*/
	bit8	i_break;		/* Input code for line break		*/
	bit8	i_parity;		/* Input code for parity error		*/
	bit8	i_framing;		/* Input code for framing error		*/
	bit8	i_overrun;		/* Input code for overrun error		*/
	bit8	i_shift;		/* I_UCONLY "shift" character		*/
	bit8	i_options;		/* Input processing options			*/
	bit16	i_ntraps;		/* Number of trap characters: 0-8	*/
	bit8	i_traps[8];		/* Trap characters					*/
	bit8	i_tflags[8];	/* Trap character option flags		*/
	bit8	i_xtab[256];	/* Input translation table			*/
	bit16	i_ntline;		/* Number of line terminators		*/
	bit8	i_tline[8];		/* Terminate line					*/
	bit8	i_tlflags[8];	/* Line terminator option flags		*/
	bit16	i_nsynch;		/* Number of synchronized traps		*/
	bit8	i_synch[8];		/* Synchronized trap characters		*/
	bit8	i_sflags[8];	/* Synch trap option flags			*/
} A_IPARAM;

/* The following is the local version of the A_IPARAM structure.  It*/
/* differs from the above only in that the i_xtab is declared as a 	*/
/* (bit8 *) rather than an actual array 							*/

typedef struct
{
	bit16	i_blocks;		/* Select Input Processing Blocks	*/
	bit16	i_nescape;		/* Number of input escapes			*/
	bit8	i_escape[8];	/* Input escape characters			*/
	bit16	i_except;		/* Exception processing modes		*/
	bit8	i_break;		/* Input code for line break		*/
	bit8	i_parity;		/* Input code for parity error		*/
	bit8	i_framing;		/* Input code for framing error		*/
	bit8	i_overrun;		/* Input code for overrun error		*/
	bit8	i_shift;		/* I_UCONLY "shift" character		*/
	bit8	i_options;		/* Input processing options			*/
	bit16	i_ntraps;		/* Number of trap characters: 0-8	*/
	bit8	i_traps[8];		/* Trap characters					*/
	bit8	i_tflags[8];	/* Trap character option flags		*/
	bit8	*i_xtab;		/* Input translation table			*/
	bit16	i_ntline;		/* Number of line terminators		*/
	bit8	i_tline[8];		/* Terminate line					*/
	bit8	i_tlflags[8];	/* Line terminator option flags		*/
	bit16	i_nsynch;		/* Number of synchronized traps		*/
	bit8	i_synch[8];		/* Synchronized trap characters		*/
	bit8	i_sflags[8];	/* Synch trap option flags			*/
} L_IPARAM;

/* Processing Blocks for i_blocks: */
#define	I_XERRS		0x0001	/* Process line exceptions			*/
#define	I_MSBZ		0x0002	/* Strip MSB						*/
#define	I_UCONLY	0x0004	/* Keyboard is upper-case only		*/
#define	I_TRAP		0x0008	/* Trap special characters			*/
#define	I_XLATE		0x0010	/* Translate characters				*/
#define	I_EXTEND	0x0200	/* Parse SI/SO code extension		*/
#define	I_ECHO		0x0020	/* Echo								*/
#define	I_EDIT		0x0040	/* Edit lines						*/
#define	I_THROTTLE	0x0080	/* Throttle raw input				*/
#define	I_SYNCH		0x0100	/* Indicate synchronized traps		*/
#define	I_MARKFF	0x0400	/* Double FF in data stream			*/

/* Line Exception processing mode bits for i_except: */
#define	I_BBITS		0x0007	/* BREAK control bits:				*/
#define	I_BIGNORE	0x0000	/* Ignore BREAK condition			*/
#define	I_BINPUT	0x0001	/* Encode BREAK into input			*/
#define	I_BTRAP		0x0002	/* BREAK --> asynch trap			*/
#define	I_BSTRAP	0x0003	/* BREAK --> synch trap				*/
#define	I_BDATA		0x0004	/* BREAK (null) into input			*/
#define	I_BMARK		0x0005	/* Mark 0xFF, 0x00, 0xnn into input	*/
#define	I_BRKINT	0x0007	/* Asynch trap, and flush buffers	*/

#define	I_PBITS		0x0038	/* Parity error control bits:		*/
#define	I_PIGNORE	0x0000	/* Ignore parity errors				*/
#define	I_PINPUT	0x0008	/* Encode parity error into input	*/
#define	I_PTRAP		0x0010	/* Parity error --> asynch trap		*/
#define	I_PSTRAP	0x0018	/* Parity error --> synch trap		*/
#define	I_PDATA		0x0020	/* Parity error data into input		*/
#define	I_PMARK		0x0028	/* Mark 0xFF, 0x00, 0xnn into input	*/

#define	I_FBITS		0x01C0	/* Framing error control bits:		*/
#define	I_FIGNORE	0x0000	/* Ignore framing errors			*/
#define	I_FINPUT	0x0040	/* Encode frame error into input	*/
#define	I_FTRAP		0x0080	/* Frame error --> asynch trap		*/
#define	I_FSTRAP	0x00C0	/* Frame error --> synch trap		*/
#define	I_FDATA		0x0100	/* Frame error data into input		*/
#define	I_FMARK		0x0140	/* Mark 0xFF, 0x00, 0xnn into input	*/

#define	I_OBITS		0x0E00	/* Overrun erro control bits:		*/
#define	I_OIGNORE	0x0000	/* Ignore overrun errors			*/
#define	I_OINPUT	0x0200	/* Encode O'run error into input	*/
#define	I_OTRAP		0x0400	/* O'run error --> asynch trap		*/
#define	I_OSTRAP	0x0600	/* O'run error --> synch trap		*/
#define	I_ODATA		0x0800	/* O'run error data into input		*/
#define	I_OMARK		0x0A00	/* Mark 0xFF, 0x00, 0xnn into input	*/

#define	I_CBITS		0x7000	/* Modem status change control bits:*/
#define	I_CIGNORE	0x0000	/* Ignore modem status changes		*/
#define	I_CTRAP		0x1000	/* Modem status change-->asynch trap*/
#define	I_CSTRAP	0x2000	/* Modem status change--> synch trap*/


/* Option bits for i_options: */
#define I_SHIFT		0x01	/* Enable I_UCONLY shift character	*/

#define I_XLATE_ESC	0x02	/* Make I_XLATE sensitive to escapes*/
#define I_XLATE_NON	0x04	/* Translate unless escaped			*/
#define I_XLATE_CN	0x08	/* Translate CR to NL				*/
#define I_XLATE_NC	0x10	/* Translate NL to CR				*/

#define I_ERR_BEL	0x20	/* Echo ASCII BEL (0x07) on line errors	*/


/* Option bits for i_tflags: */
#define I_DELETE	0x01	/* Delete trapped character from input	*/
#define I_FLUSHI	0x02	/* Flush input on trap				*/
#define I_FLUSHO	0x04	/* Flush output on trap				*/
#define I_EVENT		0x08	/* Generate an asynch event			*/

/* Option bits for i_tlflags: */
/* The following bit definition matches the I_DELETE above */
/* #define I_DELETE	0x01	/* Delete line terminator from input	*/


/* "Asynch Event" codes: */
#define AE_RERROR	0x01	/* Remote communication error		*/
#define AE_BREAK	0x02	/* BREAK encountered				*/
#define AE_MODEM	0x03	/* Modem status changed				*/
#define AE_PE		0x04	/* Parity error encountered			*/
#define AE_FE		0x05	/* Framing error encountered		*/
#define AE_OE		0x06	/* Overrun error encountered		*/
#define AE_TRAP		0x07	/* Trap character encountered		*/
#define AE_STRAP	0x08	/* Trap character encountered		*/
#define	AE_NWAITO	0x09	/* Asynchronous WAITO encountered	*/


/* Edit characters (i_echars) indexes: */
#define	TE_NONE		-1
#define	TE_ECHAR	0	/* Erase character		*/
#define	TE_TIME		0	/* Input aging time		*/
#define	TE_EWORD	1	/* Erase word			*/
#define	TE_MIN		1	/* Minimum char count	*/
#define	TE_ELINE	2	/* Erase line			*/
#define	TE_RLINE	3	/* Re-type line			*/
						/* 4-7 reserved			*/


/* Structure for AIOC_SETO and AIOC_GETO: */
typedef struct
{
	bit16	o_lowat;		/* Output buffer low water mark			*/
	bit16	o_hiwat;		/* Output buffer high water mark		*/
	bit16	o_blocks;		/* Output processing blocks				*/
	bit8	o_xtab[256];	/* Output translation table				*/
	bit16	o_nspec;		/* Number of output special characters	*/
	bit8	o_spec[8];		/* Special output characters			*/
	bit8	o_shift;		/* O_SHIFT?? "shift" character			*/
	bit8	o_bsdly;		/* Backspace delay						*/
	bit8	o_ffdly;		/* Form-feed delay						*/
	bit8	o_crdly;		/* Carriage-return delay				*/
	bit8	o_htdly;		/* Horizontal tab delay					*/
	bit8	o_lfdly;		/* Line-feed delay						*/
	bit8	o_vtdly;		/* Vertical tab deleay					*/
	bit8	o_fill;			/* Fill character						*/
} A_OPARAM;

/* The following is the local version of the A_OPARAM structure.  It*/
/* differs from the above only in that the o_xtab is declared as a 	*/
/* (bit8 *) rather than an actual array 							*/

typedef struct
{
	bit16	o_lowat;		/* Output buffer low water mark			*/
	bit16	o_hiwat;		/* Output buffer high water mark		*/
	bit16	o_blocks;		/* Output processing blocks				*/
	bit8	*o_xtab;		/* Output translation table				*/
	bit16	o_nspec;		/* Number of output special characters	*/
	bit8	o_spec[8];		/* Special output characters			*/
	bit8	o_shift;		/* O_SHIFT?? "shift" character			*/
	bit8	o_bsdly;		/* Backspace delay						*/
	bit8	o_ffdly;		/* Form-feed delay						*/
	bit8	o_crdly;		/* Carriage-return delay				*/
	bit8	o_htdly;		/* Horizontal tab delay					*/
	bit8	o_lfdly;		/* Line-feed delay						*/
	bit8	o_vtdly;		/* Vertical tab deleay					*/
	bit8	o_fill;			/* Fill character						*/
} L_OPARAM;

/* Default values for o_hiwat and o_lowat */
#if (HPS6830 || HPS6236)
#define O_LOW		400
#define O_HIGH		432
#else
#define O_LOW		100
#define O_HIGH		432
#endif

/* Bits for o_blocks: */
#define O_NOEOT		0x0001	/* Filter EOT						*/
#define O_XTABS		0x0002	/* Expand tabs						*/
#define O_SHIFTUC	0x0004	/* Shift upper case alphabetics		*/
#define O_SHIFTSP	0x0008	/* Shift special output chars		*/
#define O_XLATE		0x0010	/* Translate characters				*/
#define O_XNL		0x0020	/* Translate NL to CR-LF			*/
#define O_EXTEND	0x0800	/* Generate SI/SO code extension	*/
#define O_NLZERO	0x0040	/* Newline moves to column zero		*/
#define O_LPR		0x0080	/* Do line-printer buffering		*/
#define O_DELAYS	0x0100	/* Enable output delays				*/
#define O_NOCR		0x0200	/* No CR at column zero				*/
#define O_NOFF		0x0400	/* No form-feed at top of page		*/

/* Codes for o_??dly: */
#define D_TYPE		0x80		/* Mask to get type:		*/
#define D_TIMED		0x80		/* Timed delay				*/
#define D_FILL		0x00		/* Character-fill delay		*/

#define D_FIXED		0x40		/* Fixed delay				*/
#define D_PROP		0x00		/* Proportional delay		*/

#define D_VALUE		0x3F		/* Mask to get value		*/



/* Structure for AIOC_SETE and AIOC_GETE: */
typedef struct
{
	bit16	e_modes;		/* Echo modes						*/
	bit8	e_chars[8];		/* Line edit characters				*/
	bit8	e_crtdel[8];	/* String to delete char from CRT	*/
	bit8	e_alarm[8];		/* String to send on "alarm"		*/
	bit8	e_start;		/* LPR start deletion				*/
	bit8	e_stop;			/* LPR stop deletion				*/
} A_EPARAM;

/* Echo mode bits (e_modes): */
#define E_DELETE	0x0006	/* Display deletion control bits:		*/
#define E_NONE		0x0000	/* Don't use any special delete codes	*/
#define E_NOEOF		0x0001	/* Do not echo EOF character			*/
#define E_CRT		0x0002	/* Use CRT type delete					*/
#define E_LPR		0x0004	/* Use printer type delete				*/
#define E_CHAR		0x0008	/* Enable character delete function		*/
#define E_WORD		0x0010	/* Enable word delete function			*/
#define E_LINE		0x0020	/* Enable line delete function			*/
#define E_RETYPE	0x0040	/* Enable retype function				*/

#define E_CTRL		0x0080	/* Echo controls as ^X					*/
#define E_ALARM		0x0100	/* Echo overrun as alarm string			*/
#define E_NEWLINE	0x0200	/* Echo newline after line delete		*/
#define E_NLONLY	0x0400	/* Echo newline characers only			*/
#define E_ERONLY	0x0800	/* Echo character-delete sequence		*/
#define E_NOEOT		0x1000	/* Do not echo ASCII EOT character		*/
#define E_CLEANUP	0x2000	/* Retype fouled input					*/
#define E_NOERASE	0x4000	/* Don't use CRT erase for line delete	*/
#define E_BACKSPACE	0x8000	/* Backspace after echoing e_backspace	*/

/* structure for AIOC_SETG/GETG */
typedef struct
{
	A_PROT		a_prot;
	A_FLOW		a_flow;
	A_IPARAM	a_iparam;
	A_OPARAM	a_oparam;
	A_EPARAM	a_eparam;
} A_GROUP;

/* Structure for AIOC_GETS: */
typedef struct
{
	bit16	s_modem;		/* Modem status bits						*/
	bit16	s_in_chars;		/* Number of input chars queued on board	*/
	bit16	s_out_chars;	/* Number of output chars queued on board	*/
} A_STAT;


/* Structure for AIOC_SETX and AIOC_GETX: */
typedef struct
{
	/* Auxiliary parameters for line printers: */
	bit8	p_lines;		/* Number of lines per page			*/
	bit8	p_cols;			/* Number of columns per line		*/
	bit8	p_indent;		/* Number of spaces to indent		*/

	/* Auxiliary parameter for E_BACKSPACE: */
	bit8	e_backspace;	/* Backspace over this character	*/

	bit8	x_pad[60];		/* Reserved; must be zero.			*/
} A_XPARAM;


/* Bits for b_flags: */
#define B_BLOCKED	0x0001	/* Data blocked into lines		*/
#define B_SYNTRAP	0x0002	/* Synchronous trap				*/
#define B_SYNWAIT	0x0004	/* Synchronized WAITI MARK		*/


/* Structure for AIOC_GETB: */
typedef struct
{
    int	sc_read;			/* single channel read */
    int	mc_read;			/* multi channel read  */
    int	sc_write;			/* single channel write*/
    int	mc_write;			/* multi channel write */
} A_XBYTES;

/* command parameters */
#define GETB_CLEAR 		1	/* command param to clear read and write info */
#define GETB_NCLEAR 	0	/* command param to not clear read and write info */


/* Structure for AIOC_GETT: */
typedef struct
{
	bit32 read;			/* tally of chars read */
	bit32 write;		/* tally of chars written */
	bit32 framing;		/* tally of framing errors */
	bit32 parity;		/* tally of parity errors */
	bit32 overrun;		/* tally of overrun errors */
	bit32 tbreak;		/* tally of break errors */
	bit32 dtr;			/* tally of dtr transitions */
	bit32 rts;			/* tally of rts transitions */
	bit32 cd;			/* tally of cd transitions */
	bit32 failed;		/* tally of failed port transitions */
	bit32 online;		/* tally of online transitions */
	bit32 future[5];	/* tally "for future use" */
} A_TALLY;

/* command parameters */
#define GETT_CLEAR 		1	/* command param to clear tally info */
#define GETT_NCLEAR 	0	/* command param to not clear tally info */

/****************************************************************/
/* A channel control structure resides in controller RAM for	*/
/* each serial channel controlled by the AAP.  The channel		*/
/* control structure holds all of the channel's configuration	*/
/* information, as well as pointers to the input and output		*/
/* buffers, line buffer, character counts etc. This is the		*/
/* channel control structure:									*/
/*																*/	
/*      ******************WARNING***********************		*/
/* 		The CH structure has alignment considerations between   */
/*		RISC-based machines(sun4) and non-RISC-based machines (sun2) */
/*		where consideration should be taken when adding or moving	*/
/*		a field within this structure.  The following rules		*/
/*		should be adhered to:									*/
/*		1)  structures that are not aligned within themselves   */
/*			will have to be aligned. Mismatches of byte, word	*/
/*			and longs will have to be aligned to the size of    */
/*			of the largest element in the structure.            */
/*			An example of this requirement is the SEM structure */
/*			where there is a word and a long declared in the    */
/*			structure.  This structure therefore needs a word   */
/*			pad to align it up to the size of the largest 		*/
/*			element (a long-word).								*/
/*		2)  When structures are nested they will not have to    */
/*			be padded if that structure adheres to rule 1 above. */
/*			However, consideration should be taken as to how	*/
/*			it fits within the structure that it is being nested in.  */
/*			A further explanation of this follows in 3) below   */
/*		3)  The remaining 8 bytes of padding throughout the		*/
/*			CH structure is associated with rule 1 above, where */
/*			in 4 places there are word elements followed by		*/
/*			long elements.  Note that this is a little tricky   */
/*			because this also depends upon whether the element before it	*/
/*			was on a word or long-word boundary.  An example of */
/*			this is the A_EPARAM declaration which is followed  */
/*			by the ch_sflags declaration.  Both of these are    */
/*			actually aligned on word boundaries (obvious isn't */
/*			it!!)  so there does not need to be any padding.    */
/*		4)  Finally, there is a two byte pad at the end of the  */
/*			CH structure since the whole structure has to be    */
/*			aligned to the size of the largest element (a long-word)	*/
/****************************************************************/

#ifdef HPS_ALIGN
typedef struct ch_cntrl
	{
		SEM			ch_csem;
		short		ch_cflags;		/* Configuration state flags			*/
		short		ch_channel;
		ST	    	*ch_cstation;
		A_IOCB   	*ch_ciocb;		/* Pending IOCTL IOCB					*/
		A_CONF		ch_conf;		/* Network configuration info			*/
		/*
		 *	WARNING:  This is the A_GROUP structure.  Don't move these
		 *	structures around---TCS depends on this for AIOC_[SG]ETG.
		 *	BUG:  This should be the A_GROUP structure, but then a lot
		 *  of code would need to change in the TCS.
		 */
		A_PROT		ch_prot;		/* Asynchronous protocol info			*/
		A_FLOW		ch_flow;		/* Flow control protocol info			*/
		A_IPARAM	ch_input;		/* Input processing parameters			*/
		A_OPARAM	ch_output;		/* Output processing parameters			*/
		A_EPARAM	ch_echo;		/* Echo parameters						*/
		/*
		 *	End of A_GROUP.
		 */
		A_TALLY		ch_tally;		/* TCS tally information				*/
		bit8		ch_olines;		/* Output processing lines per page		*/
		bit8		ch_ocols;		/* Output processing columns per line	*/
		bit8		ch_oindent;		/* Output processing indent				*/
		bit8		res2;			/* pad out the 3 bit8 in a row          */
		short		ch_sflags;		/* Channel state flags					*/
		struct ch_ctrl	*ch_sflink;	/* Link into timeout list				*/
		struct ch_ctrl	*ch_sblink;	/* Link into timeout list				*/
		short		ch_stimer;
		bit16		res3;			/* pad to align ch_stimer field         */
		A_IOCB   	*ch_soiocb;		/* Pending OPEN IOCB					*/
		A_IOCB   	*ch_sciocb;		/* Pending CLOSE IOCB					*/
		A_IOCB   	*ch_swiocb;		/* Pending AIOC_WAITO IOCB				*/
		A_IOCB   	*ch_wiocb;		/* Pending AIOC_WAITI IOCB				*/
		A_IOCB   	*ch_fiocb;		/* Pending AIOC_FLSHI IOCB				*/
		short		ch_flflag;		/* HPS_FL_MARK counter					*/
		short		ch_smodem;		/* Modem control status 				*/
		bit16		res4;			/* pad to align ch_smodem field         */
		long		ch_iflags;		/* Input state flags					*/
		A_IOCB   	*ch_iiocb;		/* Pending READ IOCBs (head pointer)	*/
		A_INBUF  	*ch_ihead;		/* Head of input buffer chain			*/
		A_INBUF  	*ch_itail;		/* Tail of input buffer chain			*/
		char     	*ch_iptr;
		short		ch_icount;		/* # of input characters buffered		*/
		bit16		res5;			/* pad to align ch_icount field         */
		struct ch_ctrl	*ch_iflink;	/* Link into timeout list				*/
		struct ch_ctrl	*ch_iblink;	/* Link into timeout list				*/
		short		ch_itimer;
		bit8		ch_idone;		/* For data stream escape processing	*/
		bit8		ch_inesc;		/* For data stream escape processing	*/
		bit8		ch_ibuf[8];		/* For data stream escape processing	*/
		char	    ch_ilbuf[EDIT_BSIZE+1];	/* Input line buffer			*/
		char	    *ch_ilptr;		/* Input line pinter					*/
		short		ch_iecount;		/* Number of characters in edit buffer	*/
		bit16		ch_pendwait;	/* flag that pending waito in progress  */
		long		ch_oflags;		/* Output state flags					*/
		A_IOCB   	*ch_oiocb;		/* Waiting WRITE IOCBs					*/
#if (HPS6830 || HPS6236)
		A_OUTBUF 	*ch_ohead;		/*  Head of output data buffer chain	*/
		A_OUTBUF 	*ch_otail;		/*  Tail of output data buffer chain	*/
		CHANNEL		*rch;		/* pointer to the "remote" channel data str*/
#else
		A_NETBUF 	*ch_ohead;		/* Head of output data buffer chain		*/
		A_NETBUF 	*ch_otail;		/* Tail of output data buffer chain		*/
#endif
		char     	*ch_optr;		/* Output character pointer				*/
		short		ch_ocount;		/* # of output characters buffered		*/
		short		ch_ospace;		/* Space remaining in remote			*/
		bit8		ch_omod;		/* ETX count 							*/
		bit8		ch_olcol;		/* "Logical" column count				*/
		bit8		ch_opcol;		/* "Physical" column count				*/
		bit8		ch_opline;		/* "Physical" line number				*/
		struct ch_ctrl	*ch_owaiting;/* Link into waiting list				*/
		short	ch_eflags;			/* Echo state flags			 			*/
#ifdef STEPUP
		bit16		ch_obufsz;		/* Size of cluster output buffer		*/
		struct ch_cntrl *ch_wrnext;  /* link list of pointers to channels
										waiting to write out their data
										to a station - st_wrchans will
										keep count of how many on this list
										for each station                    */
		bit16	 	ch_wtflag;		/* Number of Wait Marks in Edit Bfr		*/
		bit16		res7;			/* pad to align							*/
#else
		bit16	 	ch_wtflag;		/* Number of Wait Marks in Edit Bfr		*/
#endif
	}	CH;
#else
			/*  HPS_62XX PRODUCTS-with translate tables	*/
#ifdef HPS_62XX
	typedef struct ch_cntrl
	{
		SEM			ch_csem;
		short		ch_cflags;		/* Configuration state flags			*/
		short		ch_channel;
		ST	    	*ch_cstation;
		A_IOCB   	*ch_ciocb;		/* Pending IOCTL IOCB					*/
		A_CONF		ch_conf;		/* Network configuration info			*/
		/*
		 *	WARNING:  This is the A_GROUP structure.  Don't move these
		 *	structures around---TCS depends on this for AIOC_[SG]ETG.
		 *	BUG:  This should be the A_GROUP structure, but then a lot
		 *  of code would need to change in the TCS.
		 */
		A_PROT		ch_prot;		/* Asynchronous protocol info			*/
		A_FLOW		ch_flow;		/* Flow control protocol info			*/
		A_IPARAM	ch_input;		/* Input processing parameters			*/
		A_OPARAM	ch_output;		/* Output processing parameters			*/
		A_EPARAM	ch_echo;		/* Echo parameters						*/
		/*
		 *	End of A_GROUP.
		 */
		A_TALLY		ch_tally;		/* TCS tally information				*/
		bit8		ch_olines;		/* Output processing lines per page		*/
		bit8		ch_ocols;		/* Output processing columns per line	*/
		bit8		ch_oindent;		/* Output processing indent				*/
		short		ch_sflags;		/* Channel state flags					*/
		struct ch_ctrl	*ch_sflink;	/* Link into timeout list				*/
		struct ch_ctrl	*ch_sblink;	/* Link into timeout list				*/
		short		ch_stimer;
		A_IOCB   	*ch_soiocb;		/* Pending OPEN IOCB					*/
		A_IOCB   	*ch_sciocb;		/* Pending CLOSE IOCB					*/
		A_IOCB   	*ch_swiocb;		/* Pending AIOC_WAITO IOCB				*/
		A_IOCB   	*ch_wiocb;		/* Pending AIOC_WAITI IOCB				*/
		A_IOCB   	*ch_fiocb;		/* Pending AIOC_FLSHI IOCB				*/
		short		ch_flflag;		/* HPS_FL_MARK counter					*/
		short		ch_smodem;		/* Modem control status 				*/
		long		ch_iflags;		/* Input state flags					*/
		A_IOCB   	*ch_iiocb;		/* Pending READ IOCBs (head pointer)	*/
		A_INBUF  	*ch_ihead;		/* Head of input buffer chain			*/
		A_INBUF  	*ch_itail;		/* Tail of input buffer chain			*/
		char     	*ch_iptr;
		short		ch_icount;		/* # of input characters buffered		*/
		struct ch_ctrl	*ch_iflink;	/* Link into timeout list				*/
		struct ch_ctrl	*ch_iblink;	/* Link into timeout list				*/
		short		ch_itimer;
		bit8		ch_idone;		/* For data stream escape processing	*/
		bit8		ch_inesc;		/* For data stream escape processing	*/
		bit8		ch_ibuf[8];		/* For data stream escape processing	*/
		char	    ch_ilbuf[EDIT_BSIZE+1];	/* Input line buffer			*/
		char	    *ch_ilptr;		/* Input line pinter					*/
		short		ch_iecount;		/* Number of characters in edit buffer	*/
		bit16	 	ch_wtflag;		/* Number of Wait Marks in Edit Bfr		*/
		bit16		ch_pendwait;	/* flag that pending waito in progress  */
		long		ch_oflags;		/* Output state flags					*/
		A_IOCB   	*ch_oiocb;		/* Waiting WRITE IOCBs					*/
#if (HPS6830 || HPS6236)
		A_OUTBUF 	*ch_ohead;		/*  Head of output data buffer chain	*/
		A_OUTBUF 	*ch_otail;		/*  Tail of output data buffer chain	*/
		CHANNEL		*rch;		/* pointer to the "remote" channel data str*/
#else
		A_NETBUF 	*ch_ohead;		/* Head of output data buffer chain		*/
		A_NETBUF 	*ch_otail;		/* Tail of output data buffer chain		*/
#endif
		char     	*ch_optr;		/* Output character pointer				*/
		short		ch_ocount;		/* # of output characters buffered		*/
		short		ch_ospace;		/* Space remaining in remote			*/
		bit8		ch_omod;		/* ETX count 							*/
		bit8		ch_olcol;		/* "Logical" column count				*/
		bit8		ch_opcol;		/* "Physical" column count				*/
		bit8		ch_opline;		/* "Physical" line number				*/
		struct ch_ctrl	*ch_owaiting;/* Link into waiting list				*/
		short	ch_eflags;			/* Echo state flags			 			*/
#ifdef STEPUP
		struct ch_cntrl *ch_wrnext;  /* link list of pointers to channels
										waiting to write out their data
										to a station - st_wrchans will
										keep count of how many on this list
										for each station                    */
		bit16		ch_obufsz;		/* Size of cluster output buffer		*/
#endif
	}	CH;
#else							
			/*  NON-HPS_62XX PRODUCTS-no translate tables	*/
	typedef struct ch_cntrl
	{
		SEM			ch_csem;
		short		ch_cflags;		/* Configuration state flags			*/
		short		ch_channel;
		ST	    	*ch_cstation;
		A_IOCB   	*ch_ciocb;		/* Pending IOCTL IOCB					*/
		A_CONF		ch_conf;		/* Network configuration info			*/
		/*
		 *	WARNING:  This is the A_GROUP structure.  Don't move these
		 *	structures around---TCS depends on this for AIOC_[SG]ETG.
		 *	BUG:  This should be the A_GROUP structure, but then a lot
		 *  of code would need to change in the TCS.
		 */
		A_PROT		ch_prot;		/* Asynchronous protocol info			*/
		A_FLOW		ch_flow;		/* Flow control protocol info			*/
		L_IPARAM	ch_input;		/* Input processing parameters			*/
		L_OPARAM	ch_output;		/* Output processing parameters			*/
		A_EPARAM	ch_echo;		/* Echo parameters						*/
		/*
		 *	End of A_GROUP.
		 */
		A_TALLY		ch_tally;		/* TCS tally information				*/
		bit8		ch_olines;		/* Output processing lines per page		*/
		bit8		ch_ocols;		/* Output processing columns per line	*/
		bit8		ch_oindent;		/* Output processing indent				*/
		short		ch_sflags;		/* Channel state flags					*/
		struct ch_ctrl	*ch_sflink;	/* Link into timeout list				*/
		struct ch_ctrl	*ch_sblink;	/* Link into timeout list				*/
		short		ch_stimer;
		A_IOCB   	*ch_soiocb;		/* Pending OPEN IOCB					*/
		A_IOCB   	*ch_sciocb;		/* Pending CLOSE IOCB					*/
		A_IOCB   	*ch_swiocb;		/* Pending AIOC_WAITO IOCB				*/
		A_IOCB   	*ch_wiocb;		/* Pending AIOC_WAITI IOCB				*/
		A_IOCB   	*ch_fiocb;		/* Pending AIOC_FLSHI IOCB				*/
		short		ch_flflag;		/* HPS_FL_MARK counter					*/
		short		ch_smodem;		/* Modem control status 				*/
		long		ch_iflags;		/* Input state flags					*/
		A_IOCB   	*ch_iiocb;		/* Pending READ IOCBs (head pointer)	*/
		A_INBUF  	*ch_ihead;		/* Head of input buffer chain			*/
		A_INBUF  	*ch_itail;		/* Tail of input buffer chain			*/
		char     	*ch_iptr;
		short		ch_icount;		/* # of input characters buffered		*/
		struct ch_ctrl	*ch_iflink;	/* Link into timeout list				*/
		struct ch_ctrl	*ch_iblink;	/* Link into timeout list				*/
		short		ch_itimer;
		bit8		ch_idone;		/* For data stream escape processing	*/
		bit8		ch_inesc;		/* For data stream escape processing	*/
		bit8		ch_ibuf[8];		/* For data stream escape processing	*/
		char	    ch_ilbuf[EDIT_BSIZE+1];	/* Input line buffer			*/
		char	    *ch_ilptr;		/* Input line pinter					*/
		short		ch_iecount;		/* Number of characters in edit buffer	*/
		bit16	 	ch_wtflag;		/* Number of Wait Marks in Edit Bfr		*/
		bit16		ch_pendwait;	/* flag that pending waito in progress  */
		long		ch_oflags;		/* Output state flags					*/
		A_IOCB   	*ch_oiocb;		/* Waiting WRITE IOCBs					*/
#if (HPS6830 || HPS6236)
		A_OUTBUF 	*ch_ohead;		/*  Head of output data buffer chain	*/
		A_OUTBUF 	*ch_otail;		/*  Tail of output data buffer chain	*/
		CHANNEL		*rch;		/* pointer to the "remote" channel data str*/
#else
		A_NETBUF 	*ch_ohead;		/* Head of output data buffer chain		*/
		A_NETBUF 	*ch_otail;		/* Tail of output data buffer chain		*/
#endif
		char     	*ch_optr;		/* Output character pointer				*/
		short		ch_ocount;		/* # of output characters buffered		*/
		short		ch_ospace;		/* Space remaining in remote			*/
		bit8		ch_omod;		/* ETX count 							*/
		bit8		ch_olcol;		/* "Logical" column count				*/
		bit8		ch_opcol;		/* "Physical" column count				*/
		bit8		ch_opline;		/* "Physical" line number				*/
		struct ch_ctrl	*ch_owaiting;/* Link into waiting list				*/
		short	ch_eflags;			/* Echo state flags			 			*/
#ifdef STEPUP
		struct ch_cntrl *ch_wrnext;  /* link list of pointers to channels
										waiting to write out their data
										to a station - st_wrchans will
										keep count of how many on this list
										for each station                    */
		bit16		ch_obufsz;		/* Size of cluster output buffer		*/
#endif
	}	CH;
#endif
#endif

/* Bits for ch_sflags: */
#define S_STATE		0x000F
#define S_OPEN		0x0001
#define S_WOPEN		0x0002
#define S_WCLOSE	0x0004
#define S_ONLINE	0x0010
#define S_RESET_REQ	0x0020
#define S_RX_ENABLE	0x0040
#define S_TX_ENABLE	0x0080

/* Bits for ch_iflags: */
#define I_WREAD		0x00001
#define I_HDAV		0x00002
#define I_TIME		0x00004
#define I_TIMER_ON	0x00008	/* TE_TIME timer running				*/
#define I_MIN		0x00010
#define I_DREQ		0x00020	/* DREQ posted to remote				*/
#define I_WSTOP		0x00040
#define I_STOPPED	0x00080
#define I_WSTART	0x00100
#define I_HPS_ESC	0x00200
#define I_ESC		0x00400
#define I_UC_ESC	0x00800
#define I_ESC_OFFS	0x07000	/* Offset to last encountered  escape	*/
#define I_UCSHIFT	0x10000
#define I_LPRDEL	0x20000
#define I_SI		0x40000	/* Extend SI: convert all 7 bit chars to*/
							/*   8 bits until a SO is encountered	*/

/* Bits for ch_oflags: */
#define O_WWRITE	0x0001
#define O_DREQ		0x0002	/* Data Request from Remote station		*/
#define O_MSG		0x0004	/* Message queued to Output task		*/
#define O_HIWATER	0x0008	/* Output buffer has passed high-water mark */
#define O_FLUSH		0x0010	/* Flush in progress					*/
#define O_WAITING	0x0020	/* Channel waiting to restart output	*/
#define O_SI		0x0040	/* Extend SI: convert all 8 bit chars to*/
							/*   7 bits until a SO is encountered   */


/* Thresholds for ch_?count: */
#if (HPS6830 || HPS6236)
#define INPUT_HOG		500
#else
/*
 *	WARNING: This value may need to be lowered due to buffer
 *	resources.  But lowering may decrease input rate.  See
 *	also INPUT_STARVED.
 */
#define INPUT_HOG		400
#endif
#define INPUT_STARVED	200



/* Control structure for Asynch's memory management queues: */

typedef struct
{
	short	m_pid;
	short	m_size;
	short	m_qid;
	short	m_qsize;
} MPC;

#ifdef STEPUP
/*
 *	Arguments for w_station().
 */
#define DONT_SEND	0
#define SET_TIMER	1
#define SEND_NOW	2
#endif

/*
 * MODIFICATION HISTORY:
 *
 * $Log:	hps.asynch.h,v $
 * Revision 1.1.2.1  92/06/24  13:53:17  marker
 * Branch RISCOS_5_01_2_FIXES off of trunk.
 * 
 * Revision 2.7  91/10/21  10:45:54  steve
 * Remove the defines used by the transmit completion task since this
 * task has gone away with the use of the new netman and REM4 changes.
 * 
 * Revision 2.6  91/10/11  18:30:21  steve
 * Added st_prfp to station structure ST and made it always aligned.
 * ENHANCEMENT
 * 
 * Revision 2.5  91/09/16  14:44:40  steve
 * Added NTX IOCTL commands so that they won't be used for HPS functions.
 * 
 * Revision 2.4  91/05/07  14:21:53  annette
 * Added AIOC_GETT, GETT_CLEAR, GET_NCLEAR, A_TALLY, ch_tally in channel
 * structure for tally feature.
 * 
 * Revision 2.3  91/02/25  13:11:22  don
 * Added definition for FL_ODCD flow control mode.  Note that this definition
 * re-uses the definition of FL_OETXACK which was never implemented.
 * SPR=672
 * 
 * Revision 2.2  91/01/10  20:41:18  dave
 * Update header.
 * COSMETIC
 * 
 */
