/*	Copyright (c) 1984, 1986, 1987, 1988 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident	"@(#)head.sys:asy.h	1.10"

/*
 * Defines for PC AT asynchronous port driver.
 */

/* 
 * Async adapter addresses
 */

#define NUM_ASY		2
#define P_ASY0		0x03F8
#define P_ASY1		0x02F8
#define ASYVECT0	0x04
#define ASYVECT1	0x03

/*
 * Definitions for INS8250 / 16550  chips
 */

	/* defined as offsets from the data register */
#define DAT     0   /* receive/transmit data */
#define ICR     1   /* interrupt control register */
#define ISR     2   /* interrupt status register */
#define LCR     3   /* line control register */
#define MCR     4   /* modem control register */
#define LSR     5   /* line status register */
#define MSR     6   /* modem status register */
#define DLL     0   /* divisor latch (lsb) */
#define DLH     1   /* divisor latch (msb) */


/* ICR */

#define RIEN    0x01    /* enable receiver interrupt */
#define TIEN    0x02    /* enable transmitter interrupt */
#define SIEN    0x04    /* enable receiver line status interrupt */
#define MIEN    0x08    /* enable modem status interrupt */


/* ISR */

#define FFTMOUT 0x0c	/* fifo rcvr timeout */
#define RSTATUS 0x06    /* change in receiver line status */
#define RxRDY   0x04    /* receiver data available */
#define TxRDY   0x02    /* transmitter holding register empty */
#define MSTATUS 0x00    /* change in modem status */


/* LCR 3 */

#define RXLEN   0x03    /* # of data bits per received/xmitted character */
#define STOP1   0x00
#define STOP2   0x04
#define PAREN   0x08
#define PAREVN  0x10
#define PARMARK 0x20
#define SNDBRK  0x40
#define DLAB    0x80

/* baud rate definitions */
#define ASY9600	12

/* Definitions for character length (data bits), in RXLEN field */
#define BITS5   0x00
#define BITS6   0x01
#define BITS7   0x02
#define BITS8   0x03


/* MCR */

#define DTR     0x01    /* bring up DTR */
#define RTS     0x02    /* bring up RTS */
#define OUT1    0x04
#define OUT2    0x08
#define LOOP    0x10    /* put chip into loopback state */


/* LSR */

#define RCA     0x01    /* receive char available */
#define OVRRUN  0x02    /* receive overrun */
#define PARERR  0x04    /* parity error */
#define FRMERR  0x08    /* framing/CRC error */
#define BRKDET  0x10    /* break detected (null ch + frmerr) */
#define XHRE    0x20    /* xmit holding register empty */
#define XSRE    0x40    /* xmit shift register empty */


/* MSR */

#define DCTS    0x01    /* CTS has changed state */
#define DDSR    0x02    /* DSR has changed state */
#define DRI     0x04    /* RI has changed state */
#define DDCD    0x08    /* DCD has changed state */
#define CTS     0x10    /* state of CTS */
#define DSR     0x20    /* state of DSR */
#define RI      0x40    /* state of RI */
#define DCD     0x80    /* state of DCD */
#define DELTAS(x) 	((x)&(DCTS|DDSR|DRI|DDCD))
#define STATES(x) 	((x)(CTS|DSR|RI|DCD))

#define asychan(dev)    (dev&0x0f)
#define asymajor(dev)   ((dev>>8)&0x7f)
#define FIFOEN	0x8f	/* fifo enabled, w/ 8 byte trigger */

/* asy_flags definitions */
#define XBRK	0x01            /* xmitting break in progress */
#define XFLUSH	0x02            /* must flush clist when finished */
#define	ASYHERE	0x80		/* adapter is present */
#define BRKTIME	HZ/4

/*
 * asy information structure
 */
struct asy
{
        int		asy_flags;	/* flags */
	unsigned	asy_dat;	/* xmit/rcv data register port addr. */
	unsigned	asy_icr;	/* interrupt cntrl. reg. port addr. */
	unsigned	asy_isr;	/* interrupt status reg. port addr. */
	unsigned 	asy_lcr;	/* line control reg. port addr. */
	unsigned	asy_mcr;	/* modem control reg. port addr. */
	unsigned	asy_lsr;	/* line status reg. port addr. */
	unsigned	asy_msr;	/* modem status reg. port addr. */
	int		asy_vect;	/* interrupt vector (mach. dependent) */
	dev_t		asy_dev;	/* minor device number of port */
	struct tty	*asy_tty;	/* pointer to tty struct */
#ifdef MERGE386 
	struct vpistruct *asy_vpi_act;	/* pointer to merge vpi structure */
	struct kbdstate	asy_kbdstate;	/* pointer to Merge characteristics */
					/* of tty structure (scancode, ascii) */
#endif /* MERGE386 */
};

/*
 * size of ring buffer for input characters.
 */
#define	RINGSIZ	  256

/*
 * Defines for ioctl calls (VP/ix)
 */

#define AIOC			('A'<<8)
#define AIOCINTTYPE		(AIOC|60)	/* set interrupt type */
#define AIOCDOSMODE		(AIOC|61)	/* set DOS mode */
#define AIOCNONDOSMODE		(AIOC|62)	/* reset DOS mode */
#define AIOCSERIALOUT		(AIOC|63)	/* serial device data write */
#define AIOCSERIALIN		(AIOC|64)	/* serial device data read */
#define AIOCSETSS		(AIOC|65)	/* set start/stop chars */
#define AIOCINFO		(AIOC|66)	/* tell usr what device we are */

/* Ioctl alternate names used by VP/ix */
#define VPC_SERIAL_DOS		AIOCDOSMODE	
#define VPC_SERIAL_NONDOS	AIOCNONDOSMODE
#define VPC_SERIAL_INFO		AIOCINFO
#define VPC_SERIAL_OUT		AIOCSERIALOUT
#define VPC_SERIAL_IN		AIOCSERIALIN

/* Serial in/out requests */
#define SO_DIVLLSB		1
#define SO_DIVLMSB		2
#define SO_LCR			3
#define SO_MCR			4
#define SI_MSR			1
#define SIO_MASK(elem)		(1<<((elem)-1))
