/* $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

#ident "$Header: co.h 1.18 90/05/04 $"

#ifndef	_SYS_CO_H_

/*
 * co.h
 *	Symbols and structures for the SCED console driver.
 */

/* $Log:	co.h,v $
 */

/* Size of input buffer */
#define CORXSIZE   128
#define COMAXOUT    60

struct co_bin_config {
	gate_t	cobc_gate;
};

/*
 * Console state.
 * There is one such structure for each tty device (minor device) on
 * each SCSI/Ether controller.
 *
 * The local and remote console devices are always minor devices 0
 * and 1, regardless of where they appear on the bus.  This is
 * guaranteed at config time.
 * 
 * Mutex notes:
 * 	We could lock the input and output sides separately.  
 *	But, this would probably not be a big win.  So, use one
 * 	lock for all state information.
 */

/*
 * throw together a structure containing the size of the program queu
 * and it's state.
 */

struct sec_pq {
	struct sec_progq	*sq_progq;
	ushort			sq_size;
};

struct co_state {
	unchar	ss_alive;
	unchar	ss_initted;
						/* input state */
	int	is_status;
	struct	sec_dev	*is_sd;
	struct	sec_pq	is_reqq;
	struct	sec_pq	is_doneq;
	ulong	is_ovc;			/* count number of overflow errors */
	ulong	is_parc;		/* count number of parity errors */
	char	is_buffer[CORXSIZE];
	unchar	is_restart_read;	/* restart read flag		 */
	unchar	is_initted;
	int	os_status;
	struct	sec_dev *os_sd;
	struct	sec_pq	os_reqq;
	struct	sec_pq	os_doneq;
	struct	sec_smode	os_smode;
	sema_t	rawqwait;
	unchar	os_busy_flag;
	sema_t	os_busy_wait;
	unchar	os_initted;
	queue_t *qptr;			/* Pointer to local qinit (WR) */
	mblk_t *msg;			/* Pointer to current message */
	lock_t lock;			/* Local lock */
	ushort cflags;			/* Configuration flags */
	ushort flags;			/* Driver status flags */
	int state;			/* Driver state */
	int breakid;			/* Break timeout id */
	int delayid;			/* Delay timeout id */
	int drainid;			/* Output drain timeout id */
	int lasttxsize;			/* Previous output buffer size */
	uint bufcallid;			/* Bufcall id */
	int bfc_count;			/* Bufcall input count */
	dev_t	co_dev;			/* Port's full device number */
	unchar co_lobuf[COMAXOUT];	/* Intermediate buf for strbuf > 4M */
};
/*
 * State bits for state field of co_state.
 */
#define CO_ISOPEN	0x004
#define CO_WOPEN	0x002
#define CO_CARR_ON	0x010
#define CO_BUSY		0x020
#define CO_WCLOSE  	0x040
#define CO_TXDELAY 	0x080
#define CO_WFLUSH  	0x100
#define CO_HUPCLS	0x200
#define CO_SUSPOUT	0x400
#define CO_TXBREAK	0x800

/*
 * Flag bits for flags field of co_state.
 */
#define DRAINTIME	0x002

#define CO_AVGCNT 5		/* Guessed avg number of bytes per msg */
#define CO_VEC_SHIFT	1
#define	CM_BAUD		sm_un.sm_cons.cm_baud
#define CM_FLAGS	sm_un.sm_cons.cm_flags
#define STDPUTBACK	1
#define PRIPUTBACK	2

/*
 * binary config table for the console driver.  There is one entry in
 * the co_bin_config[] table for each controller in the system.
 */
#ifdef	INKERNEL
extern struct 	co_bin_config co_bin_config[];
extern int	co_bin_config_count;
#endif	/* INKERNEL */

#ifdef DEBUG
extern int co_debug;
#endif /* DEBUG */

#define	_SYS_CO_H_
#endif	/* _SYS_CO_H_ */
