/*
 * @DEC_COPYRIGHT@
 */
/*
 * HISTORY
 * $Log:	conf.c,v $
 * Revision 1.1.3.30  92/05/21  11:17:07  William_Burns
 * 	Added dti stub routines (from scc.c) to avoid multiple defines.
 * 	[92/05/20  08:16:00  William_Burns]
 * 
 * Revision 1.1.3.29  92/05/18  08:52:16  Donald_Dutile
 * 	Cleaned up NTC == 0 definitions.
 * 	Removed MIPSCO devsw entries.
 * 	Cleaned up comments after #else and #endif's.
 * 	[92/05/13  12:01:14  Donald_Dutile]
 * 
 * Revision 1.1.3.28  92/05/07  13:24:34  Thomas_Tierney
 * 	Merge with AG.
 * 	[92/05/07  12:44:24  Thomas_Tierney]
 * 
 * 	Check in for next ag.latest merge.
 * 	[92/04/30  10:12:54  Thomas_Tierney]
 * 
 * 	Check-in for remerge
 * 	[92/04/30  09:37:41  Thomas_Tierney]
 * 
 * 	Merge
 * 	[92/04/23  10:35:50  Thomas_Tierney]
 * 
 * 	Merged Maria Vella's CAM dev_t expansion work.
 * 	[92/04/21  16:24:33  Thomas_Tierney]
 * 
 * Revision 1.1.3.27  92/05/06  09:58:38  Philip_Vitale
 * 	check-in of bmerge
 * 	[92/05/06  09:57:08  Philip_Vitale]
 * 
 * 	Fixed typo of lat_config().
 * 	[92/05/06  09:54:23  Philip_Vitale]
 * 
 * Revision 1.1.3.26  92/05/05  12:46:51  Peter_Keilty
 * 	merged with ag.latest
 * 	[92/05/04  17:02:08  Peter_Keilty]
 * 
 * 	Merge with pre.bl6
 * 	Added dsaisr_init.
 * 	[92/04/04  10:23:10  Peter_Keilty]
 * 
 * 	Added dsa_physical_bg,dsa_physical_end,ci_first_port,nNUQ
 * 	[92/03/26  15:05:38  Peter_Keilty]
 * 
 * Revision 1.1.3.25  92/05/04  14:50:51  Philip_Vitale
 * 	merged with ag.latest
 * 	[92/05/04  14:30:10  Philip_Vitale]
 * 
 * 	Added code to make lat_config() null if LAT was
 * 	not configured in config file.
 * 	[92/05/03  18:05:43  Philip_Vitale]
 * 
 * 	Made changes to LAT cdevsw entry (major #5).
 * 	[92/04/30  21:57:47  Philip_Vitale]
 * 
 * Revision 1.1.3.24  92/03/27  01:21:02  Barbara_Corriero
 * 	Bmerge with AG.
 * 	[92/03/27  01:17:56  Barbara_Corriero]
 * 
 * 	Added support for console mmap routine (cnmmap()) used by workstation
 * 	driver.
 * 	[92/03/19  19:09:14  Barbara_Corriero]
 * 
 * Revision 1.1.3.23  92/03/26  22:18:04  Joel_Gringorten
 * 	Added ws_num_controllers and ws_graphics_name_proc
 * 	for sizer support of graphics modules.
 * 	[92/03/26  22:14:04  Joel_Gringorten]
 * 
 * Revision 1.1.3.22  92/03/25  13:18:19  Mary_Walker
 * 	bmerge
 * 	[92/03/25  13:07:59  Mary_Walker]
 * 
 * 	bmerge
 * 	[92/03/23  09:54:21  Mary_Walker]
 * 
 * 	took out comment restricting the last N slots of cdevsw to be reserved
 * 	for STREAMS
 * 	[92/03/19  12:18:08  Mary_Walker]
 * 
 * Revision 1.1.3.21  92/03/24  15:59:36  Paul_Shaughnessy
 * 	Merge in bug fix from Chet
 * 	[92/03/24  09:52:19  Paul_Shaughnessy]
 * 
 * 	Merge to AG
 * 	[92/03/23  13:01:26  Paul_Shaughnessy]
 * 
 * 	Merged bug fixes from Chet.
 * 	[92/03/23  11:42:27  Paul_Shaughnessy]
 * 
 * Revision 1.1.3.20  92/03/13  13:37:23  Debra_Haeck
 * 	- allow for a minimum value for the MAX_BDEVSW and * MAX_CDEVSW
 * 	  defines.
 * 	- verify that cookies are at start and end of cdevsw and bdevsw
 * 	  tables.
 * 	[92/03/13  13:34:22  Debra_Haeck]
 * 
 * Revision 1.1.3.19  92/03/12  13:56:44  Timothy_Burke
 * 	Changed MAX_BDEVSW to 70 and MAX_CDEVSW to 125 to accomodate
 * 	loadable drivers.
 * 	[92/03/04  14:37:38  Timothy_Burke]
 * 
 * 	Changed bdevsw[] and cdevsw[] to always include the funnel field.
 * 	Allow size of devsw's to be changed via config file.
 * 	[92/03/04  10:30:11  Timothy_Burke]
 * 
 * Revision 1.1.3.18  92/03/11  09:57:47  cam_proj_Janet_Schank
 * 	"bsubmitted from shared SB"
 * 
 * Revision 1.1.3.17  92/02/28  22:36:03  Sec_Proj_Michael_Fairbrother
 * 	Fixed late night blues.
 * 	[92/02/28  22:33:42  Michael_Fairbrother]
 * 
 * Revision 1.1.3.16  92/02/28  21:25:18  Sec_Proj_Michael_Fairbrother
 * 	Security
 * 
 * Revision 1.1.33.2  92/03/06  14:50:40  William_Dallas
 * 	Added KZQSA support
 * 	[92/03/06  14:33:16  William_Dallas]
 * 
 * Revision 1.1.26.3  92/02/27  11:10:36  cam_proj_Janet_Schank
 * 	Added support for the CAM user agent driver.
 * 
 * Revision 4.2.3.3  91/10/25  14:48:14  William_Burns
 * 	Merge from ODE/TIN: revision 3.11.9.3
 * 	date: 91/10/22 19:49:11;  author: devrcs;  state: Exp;  lines added/del: 2/1
 * 	sccs rev: 3.13;  orig date: 91/10/07 15:12:36;  orig author: burns
 * 	Added presto variable.
 * 	[91/10/25  09:10:01  William_Burns]
 * 
 * Revision 4.2.3.2  91/10/23  15:04:18  William_Burns
 * 	Merge from ODE/TIN: revision 3.11.9.2
 * 	date: 91/10/17 21:15:09;  author: devrcs;  state: Exp;  lines added/del: 2/2
 * 	sccs rev: 3.12;  orig date: 91/10/02 16:28:40;  orig author: fred
 * 	Fred Canter - comments.
 * 	[91/10/23  12:12:08  William_Burns]
 * 
 * Revision 4.2  91/09/19  23:10:10  devbld
 * 	Adding ODE Headers
 * 
 * $EndLog$
 */
#ifndef lint
static char	*sccsid = "@(#)$RCSfile: conf.c,v $ $Revision: 1.1.3.30 $ (DEC) $Date: 92/05/21 11:17:07 $";
#endif 
/*
 */
/*
 * (c) Copyright 1990, OPEN SOFTWARE FOUNDATION, INC.
 * ALL RIGHTS RESERVED
 */
/*
 * Mach Operating System
 * Copyright (c) 1989 Carnegie-Mellon University
 * All rights reserved.  The CMU software License Agreement specifies
 * the terms and conditions for use and redistribution.
 */
/*
 * OSF/1 Release 1.0
 */
/* 
 * derived from conf.c	2.1 16:11:28 4/20/90 SecureWare 
 */
/*
 * Modification History:
 *
 *  04-Nov-91	Tom Tierney
 *	Modified LVM strategy return type to be int like all others (one
 *	day all driver entrypoints that return no value will be "void").
 * 
 *  3-Nov-91	Fred Canter
 *	Fixed configuration of memory driver (NMD -> NMEMD).
 *
 */

/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 *
 *	@(#)conf.c	7.1 (Berkeley) 6/5/86
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/buf.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/conf.h>
#include <sys/presto.h>

#include <io/dec/uba/ubavar.h>
#include <io/common/devdriver.h>
#include <io/dec/scs/sca.h>

#define DEV_FUNNEL_NULL  NULL

int	nulldev();
int	nodev();

int	timeopen();
int	timeclose();
int	timemap();

/*
 * /etc/config notes: etc/config will produce a .h for each controller
 * in the system named "(two char controller name).h".  Each of these
 * .h's will contain two defines, "(two char controller name)C" which
 * indicates the number of controllers of this type, and
 * "(two char controller name)S" which indicates the number of slaves
 * possibly attached to this set of controllers.
 */

/*
 * Definitions for bdevsw
 */


/* SAS/RAM disk device */			/* Pmax devices */
#include <memd.h>
#if NMEMD > 0
int	mdopen(), mdstrategy(), md_size(), mdioctl();
#else
#define mdopen		nodev
#define mdstrategy	nodev
#define md_size 	nodev
#define mdioctl 	nodev
#endif

#ifdef __mips__
#include "vba.h"
#if NVBA == 0
xviaconf() {}	/* make tc_option_data.c happy */
#endif
#endif /* __mips__ */

/* lance network driver */
#include "ln.h"
#if NLN > 0
#else
netnuke() {}
#endif

/* LAT driver */
#include "lat.h"
#if LAT > 0
#else
lat_config() {}
#endif

/* Logical Volume Manager pseudo-device */
#include <lv.h>
#include <presto.h>
int lv_nlv = NLV;
#if NLV > 0
#include <lvm/lvmd.h>
int	lv_open(), lv_close();
int	lv_strategy();
int	lv_read(), lv_ioctl(), lv_write();
struct volgrp lv_volgrp[NLV];
#endif

#if NLV > 0
#if NPRESTO > 0
/* declare Prestoserve NVRAM psuedo-driver interface routines and structs */
int lv_open0(), lv_close0();
int lv_strategy0();
int lv_read0(), lv_write0();
#define lv_ioctl0	lv_ioctl
#define	lv_volgrp0	((struct tty *)&lv_volgrp[0])
#else
#define	lv_open0	lv_open
#define	lv_close0	lv_close
#define	lv_strategy0	(int (*)())lv_strategy
#define	lv_read0	lv_read
#define	lv_write0	lv_write
#define	lv_ioctl0	lv_ioctl
#define	lv_volgrp0	((struct tty *)&lv_volgrp[0])
#endif /* NPRESTO > 0 */

#else
#define	lv_open0	nodev
#define	lv_close0	nodev
#define	lv_strategy0	nodev
#define	lv_read0	nodev
#define	lv_write0	nodev
#define	lv_ioctl0	nodev
#define lv_volgrp0	0
#endif

#if NLV > 1
#if NPRESTO > 0
/* declare Prestoserve NVRAM psuedo-driver interface routines and structs */
int lv_open1(), lv_close1();
int lv_strategy1();
int lv_read1(), lv_write1();
#define lv_ioctl1	lv_ioctl
#define	lv_volgrp1	((struct tty *)&lv_volgrp[1])
#else
#define	lv_open1	lv_open
#define	lv_close1	lv_close
#define	lv_strategy1	(int (*)())lv_strategy
#define	lv_read1	lv_read
#define	lv_write1	lv_write
#define	lv_ioctl1	lv_ioctl
#define	lv_volgrp1	((struct tty *)&lv_volgrp[1])
#endif /* NPRESTO > 0 */

#else
#define	lv_open1	nodev
#define	lv_close1	nodev
#define	lv_strategy1	nodev
#define	lv_read1	nodev
#define	lv_write1	nodev
#define	lv_ioctl1	nodev
#define lv_volgrp1	0
#endif

#if NLV > 2
#if NPRESTO > 0
/* declare Prestoserve NVRAM psuedo-driver interface routines and structs */
int lv_open2(), lv_close2();
int lv_strategy2();
int lv_read2(), lv_write2();
#define lv_ioctl2	lv_ioctl
#define	lv_volgrp2	((struct tty *)&lv_volgrp[2])
#else
#define	lv_open2	lv_open
#define	lv_close2	lv_close
#define	lv_strategy2	(int (*)())lv_strategy
#define	lv_read2	lv_read
#define	lv_write2	lv_write
#define	lv_ioctl2	lv_ioctl
#define	lv_volgrp2	((struct tty *)&lv_volgrp[2])
#endif /* NPRESTO > 0 */

#else
#define	lv_open2	nodev
#define	lv_close2	nodev
#define	lv_strategy2	nodev
#define	lv_read2	nodev
#define	lv_write2	nodev
#define	lv_ioctl2	nodev
#define lv_volgrp2	0
#endif

#if NLV > 3
#error Need to add more declarations to conf.c to configure this many LVMs.
#endif

#include <asc.h>
#include <sii.h>
#include <kzq.h>

#if NSII == 0
siireset() {}
sii_intr() {}
sii_probe() {}
sii_reset() {}
sii_dumpregs() {}
#endif

#include <tc.h>
#if NTC == 0
struct	tc_slot		*tc_slot;
struct	tc_slotaddr	*tc_slotaddr;
struct	tc_sw		*tc_sw;
u_int			*tc_romoffset;
tc_init()	{}
tc_where_option()	{}
tc_disable_option()	{}
tc_enable_option()	{}
tc_isolate_memerr()	{}
tc_addr_to_name()	{}
#endif /* NTC TURBO Channel routines */

#if NASC == 0
asc_reset() {}
asc_dumpregs() {}
#endif

#if NSII > 0 || NASC || NKZQ > 0
int     cdisk_open(), cdisk_close(), cdisk_strategy(), cdisk_read();
int	cdisk_write(), cdisk_dump(), cdisk_ioctl(), cdisk_size();
int     ctape_open(), ctape_close(), ctape_strategy(); 
int	ctape_read(), ctape_write(), ctape_ioctl(), ctape_size();
int	uagtopen(), uagtclose(), uagtioctl();
int	asyncsel();
#if NPRESTO > 0
/* declare presto NVRAM pseudo-driver interface routines and structs */
int   	RZbopen(), RZbclose(), RZstrategy();
int   	RZread(), RZwrite();
#else
#define	RZbopen		cdisk_open
#define	RZbclose	cdisk_close
#define	RZstrategy	cdisk_strategy
#define	RZread		cdisk_read
#define	RZwrite		cdisk_write
#endif /* NPRESTO > 0 */
#else
#define	cdisk_open	nodev
#define	cdisk_close 	nodev
#define	cdisk_strategy	nodev
#define	cdisk_read	nodev
#define	cdisk_write	nodev
#define cdisk_dump	nodev
#define	cdisk_ioctl	nodev
#define	cdisk_size	0
#define	ctape_open	nodev
#define	ctape_close	nodev
#define	ctape_strategy	nodev
#define	ctape_read	nodev
#define	ctape_write	nodev
#define	ctape_ioctl	nodev
#define	ctape_size	0
#define uagtopen	nodev
#define uagtclose	nodev
#define uagtioctl	nodev
#define asyncsel	nodev
/* declare other CAM related stubs */
void scsiisr_init() {}
char *szinfo() {}
/* declare stubs for presto interface routines */
#define	RZbopen		nodev
#define	RZbclose	nodev
#define	RZstrategy	nodev
#define	RZread		nodev
#define	RZwrite		nodev
#endif /* NSII > 0 || NASC || NKZQ > 0 */

/* 
 *	DSA IO conf setups 
 */
#include "uba.h"
/*
#include "kdb.h"
#include "klesib.h"
#include "kdm.h"
 */
#include "msi.h"
#include "ci.h"
#include "uq.h"
#include "mscp.h"
#include "hsc.h"
#include "dssc.h"
/*
#include "msdup.h"
 */

/*
#if NUBA==0 && NKDB==0 && NKDM==0 && NKLESIB==0
 */
#if NUQ == 0
struct uba_hd uba_hd[1];
ubaerror () {}
ubainitmaps () {}
uballoc () {}
ubarelse () {}
ubareset () {}
#endif

#if NUQ > 0
extern struct driver uqdriver;
int uq_reset();
#else
#define uq_reset        nulldev
int nNUQ = 0;
#endif
 
#if NMSI == 0
int msi_probe() {};
void msi_isr() {};
int (*msiint0[])() = { 0 };
int nNMSI = 0;
#endif
 
#if NHSC == 0
hscdriver() {}
#endif

#if NDSSC == 0
dsscdriver() {}
#endif

#if NCI == 0
CIISR ci_isr;
void tcciconf() {};
int (*ciint0[])() = { 0 };
int nNCI = 0;
u_short ci_first_port = 0;
#endif

#if NCI == 0 &&  NUQ == 0 && NMSI == 0
void dsaisr_init() { /* make init_main.c happy */ }
scs_start_sysaps () { /* make startup.c happy */ }
mscp_poll_wait () { /* make startup.c happy */ }
mscp_info() { return(0); /* cmu_syscalls.c happy */ }
int do_mscp_poll_wait; /* make init_main.c happy */
int dsa_physical_bg = 0; /* make mips_init.c happy */
int dsa_physical_end = 0; /* make mips_init.c happy */
#endif
 
#if NCI > 0 || NUQ > 0 || NMSI > 0
int     mscp_bopen(), mscp_copen(), mscp_bclose();
int     mscp_cclose(), mscp_strategy(), mscp_read();
int     mscp_write(), mscp_dump(), mscp_ioctl(), mscp_size();
#if NPRESTO > 0
/* declare presto NVRAM pseudo-driver interface routines and structs */
int     MSCP_bopen(), MSCP_bclose(), MSCP_strategy();
int     MSCP_read(), MSCP_write();
#else
#define MSCP_bopen      mscp_bopen
#define MSCP_bclose     mscp_bclose
#define MSCP_strategy   mscp_strategy
#define MSCP_read       mscp_read
#define MSCP_write      mscp_write
#endif /* NPRESTO > 0 */
#else
#define mscp_bopen      nodev
#define mscp_copen      nodev
#define mscp_bclose     nodev
#define mscp_cclose     nodev
#define mscp_strategy   nodev
#define mscp_read       nodev
#define mscp_write      nodev
#define mscp_ioctl      nodev
#define mscp_size       0
#define mscp_dump	nodev
/* declare stubs for presto interface routines and structs */
#define MSCP_bopen      nodev
#define MSCP_bclose     nodev
#define MSCP_strategy   nodev
#define MSCP_read       nodev
#define MSCP_write      nodev
#endif /* NCI>0 || NUQ >0 || NMSI > 0 */

#if NCI>0 || NUQ >0 || NMSI > 0
int     tmscpopen(), tmscpclose(), tmscpstrategy(), tmscpread(),
        tmscpwrite(), tmscpioctl(), tmscpsize();
#else
#define tmscpopen       nodev
#define tmscpclose      nodev
#define tmscpstrategy   nodev
#define tmscpread       nodev
#define tmscpwrite      nodev
#define tmscpioctl      nodev
#define tmscpdump       nodev
#endif 

#if NMSCP == 0
int nulldev();
struct driver mscpdriver; int (*mscpint0[])() = { nulldev, 0 };  /* no mscpdriver */
#endif /* NMSCP */

/*
 * On a workstation, these variables identify
 * the type of graphics display device and
 * which units are present. This info is filled
 * in by the graphics device drivers (qd qv sm sg).
 */
int   ws_display_type = 0;    /* Major device number of display device */
int   ws_display_units = 0;   /* Bit field of units (bit0 = unit 0, etc) */
int   ws_num_controllers = 0;    /* number of graphics options */
char *(*ws_graphics_name_proc)(); /* routine to return graphics option nam


/* Monochrome bitmap always here */
int 	(*v_consputc)()  = 0;
int 	(*v_consgetc)()  = 0;
int 	(*vs_gdopen)()   = 0;
int 	(*vs_gdclose)()  = 0;
int 	(*vs_gdread)()   = 0;
int 	(*vs_gdwrite)()  = 0;
int 	(*vs_gdselect)() = 0;
int 	(*vs_gdkint)()   = 0;
int     (*vs_gdmmap)()   = 0;
int 	(*vs_gdioctl)()  = 0;
int 	(*vs_gdstop)()   = 0;

/*
 * NOTE: this must match conf/devices
 */

/*
 *      Block Device Switch static declaration and initialization
 */

/*
 * The user may specify a different bcdevsw size in the config file.
 * MAX_BDEVSW will have a default of 70 and a minimum of 50.
 */
#ifdef	MAX_BDEVSW
#if	MAX_BDEVSW < 50
#define	MAX_BDEVSW	50
#endif	/* MAX_BDEVSW < 50 */
#else	/* MAX_BDEVSW needs defining */
#define	MAX_BDEVSW	70
#endif	/* MAX_BDEVSW */

dswlock_t       bdevlock[MAX_BDEVSW];           /* bdevsw lock structure */


/*
%%% BEGIN BDEVSW TABLE (first 3 chars of this line must be %%%
*/
struct bdevsw   bdevsw[MAX_BDEVSW] =
{
	{ nodev,	nodev,		nodev,		nodev,		/*0*/
	  nodev,	0,		nodev,		DEV_FUNNEL_NULL },
	/* SAS/RAM disk device */
	{ mdopen,	nulldev,	mdstrategy,	nodev,		/*1*/
	  md_size,	0,		nodev		,DEV_FUNNEL_NULL },
	/* swap, defunct */
	{ nodev,	nodev,		nodev,		nodev,		/*2*/
	  0,		0,		nodev		,DEV_FUNNEL_NULL },
	/* sable, defunct */
	{ nodev,	nodev,		nodev,		nodev,		/*3*/
	  nodev,	0,		nodev		,DEV_FUNNEL_NULL },

	/* Unused entry (4) */
	{ nodev,	nodev,		nodev,		nodev,		/*4*/
	  nodev,	0,		nodev,		DEV_FUNNEL_NULL },

	/* Unused entry (5) */
	{ nodev,	nodev,		nodev,		nodev,		/*5*/
	  nodev,	0,		nodev,		DEV_FUNNEL_NULL },

	/* Unused entry (6) */
	{ nodev,	nodev,		nodev,		nodev,		/*6*/
	  0,		0,		nodev		,DEV_FUNNEL_NULL },

	/* Unused entry (7) */
	{ nodev,	nodev,		nodev,		nodev,		/*7*/
	  0,		0,		nodev		,DEV_FUNNEL_NULL },

	/* PMAX SCSI disk devices */
	/*
	 * Insert presto NVRAM pseudo-driver interface routines (RZ...).
	 * Warning: If these device major numbers change, then
	 *          data/presto_data.c must be modified.
	 */
	{ RZbopen,      RZbclose,       RZstrategy,     cdisk_dump,     /*8*/
	  cdisk_size,	0,		cdisk_ioctl	,DEV_FUNNEL_NULL },

	/* PMAX SCSI tape devices */
	{ ctape_open,	ctape_close,	ctape_strategy,	nodev,		/*9*/
	  0,		B_TAPE,		nodev		,DEV_FUNNEL_NULL },

	/* Unused entry (10) */
	{ nodev,	nodev,		nodev,		nodev,		/*10*/
	  0,		0,		nodev		,DEV_FUNNEL_NULL },

	/* Unused entry (11) */
	{ nodev,	nodev,		nodev,		nodev,		/*11*/
	  0,		0,		nodev		,DEV_FUNNEL_NULL },

	/* Unused entry (12) */
	{ nodev,	nodev,		nodev,		nodev,		/*12*/
	  0,		0,		nodev		,DEV_FUNNEL_NULL },

	/* Unused entry (13) */
	{ nodev,	nodev,		nodev,		nodev,		/*13*/
	  0,		0,		nodev		,DEV_FUNNEL_NULL },

	/* Unused entry (14) */
	{ nodev,	nodev,		nodev,		nodev,		/*14*/
	  0,		0,		nodev		,DEV_FUNNEL_NULL },

	/* DSA tmscp tape devices */
	{ tmscpopen,	tmscpclose,	tmscpstrategy,	nodev,		/*15*/
	  0,		B_TAPE,		nodev,		DEV_FUNNEL_NULL },

	/* Logical Volume Manager - cmajor and bmajor must match */
	{ lv_open0,	lv_close0,	lv_strategy0,	nodev,		/*16*/
	  0,		0,		lv_ioctl0	,DEV_FUNNEL_NULL },

	/* Unused entry (17) */
	{ nodev,	nodev,		nodev,		nodev,		/*17*/
	  0,		0,		nodev		,DEV_FUNNEL_NULL },

	/* Unused entry (18) */
	{ nodev,	nodev,		nodev,		nodev,		/*18*/
	  0,		0,		nodev		,DEV_FUNNEL_NULL },

	/* Logical Volume Manager - cmajor and bmajor must match */
	{ lv_open1,	lv_close1,	lv_strategy1,	nodev,		/*19*/
	  0,		0,		lv_ioctl1	,DEV_FUNNEL_NULL },

	/* Logical Volume Manager - cmajor and bmajor must match */
	{ lv_open2,	lv_close2,	lv_strategy2,	nodev,		/*20*/
	  0,		0,		lv_ioctl2	,DEV_FUNNEL_NULL },

	/* Unused entry (21) */
	{ nodev,	nodev,		nodev,		nodev,		/*21*/
	  0,		0,		nodev		,DEV_FUNNEL_NULL },
 
	/* Unused entry (22) */
	{ nodev,	nodev,		nodev,		nodev,		/*22*/
	  0,		0,		nodev		,DEV_FUNNEL_NULL },
 
        /* DSA mscp disk devices */
        /*
         * Insert presto NVRAM pseudo-driver interface routines (MSCP_...).
         * Warning: If these device major numbers changes, then
         *          data/presto_data.c must be modified.
         */
        { MSCP_bopen,   MSCP_bclose,    MSCP_strategy,  mscp_dump,	/*23*/
          mscp_size,    0,      	mscp_ioctl ,    DEV_FUNNEL_NULL },
};
/*
%%% END BDEVSW TABLE (first 3 chars of this line must be %%%
*/
int	nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]);

/*
 * Definitions for cdevsw
 */

int	cnopen(),cnclose(),cnread(),cnwrite(),cnioctl(),cnselect(),cnmmap();

int	ncons;
#define	cnntty	(&ncons)

int	syopen(),syread(),sywrite(),syioctl(),syselect();

int 	mmread(),mmwrite(),mmmap();

#include <pty.h>
#if NPTY > 0
int	ptsopen(),ptsclose(),ptsread(),ptswrite(),ptsstop();
int	ptcopen(),ptcclose(),ptcread(),ptcwrite(),ptcselect();
int	ptsselect(), ptyioctl();

int	npty;
#define	ptsntty	(&npty)

#else
#define ptsopen		nodev
#define ptsclose	nodev
#define ptsread		nodev
#define ptswrite	nodev
#define ptcopen		nodev
#define ptcclose	nodev
#define ptcread		nodev
#define ptcwrite	nodev
#define	ptsselect	nodev
#define ptyioctl	nodev
#define	ptcselect	nodev
#define	ptsstop		nulldev
#define	ptsntty		0
#endif

/* binary event logger */
int    binlog_open(),binlog_close(),binlog_read(),binlog_write();
int    binlog_ioctl(), binlog_select();

/*  syslog  */
int	logopen(),logclose(),logread(),logioctl(),logselect();

int	ttselect(), seltrue();


#ifdef mips
#include <dc.h>
#else
#define NDC 0
#endif

#if NDC == 0
#define dcopen 	nodev
#define dcclose	nodev
#define dcread 	nodev
#define dcwrite	nodev
#define dcioctl	nodev
#define dcstop 	nodev
#define dcselect nodev
#define dc_tty	0
struct tty cons[1];
#else /* NDC */
int	dcopen(),dcclose(),dcread(),dcwrite(),dcioctl(),dcstop(), dcselect();
extern struct	tty dc_tty[];
extern struct tty cons[];
#endif /* NDC */

#ifdef mips
#include <dhu.h>
#else
#define NDHU 0
#endif

#if NDHU == 0
#define dhuopen nodev
#define dhuclose nodev
#define dhuread nodev
#define dhuwrite        nodev
#define dhuioctl        nodev
#define dhustop         nodev
#define dhu11   0
#else /* NDHU */
int     dhuopen(),dhuclose(),dhuread(),dhuwrite(),dhuioctl(),dhustop();
extern struct   tty dhu11[];
#endif /* NDHU */

#ifdef mips
#include <scc.h>
#else
#define NSCC 0
#endif

#if NSCC == 0
#define sccopen         nodev
#define sccclose        nodev
#define sccread         nodev
#define sccwrite        nodev
#define sccioctl        nodev
#define sccstop         nodev
#define sccselect       nodev
#define scc_tty 0
#else
int     sccopen(),sccclose(),sccread(),sccwrite(),sccioctl(),sccstop(), sccselect();
extern struct   tty scc_tty[];
#endif

#ifdef mips
#include <dti.h>
#else
#define NDTI 0
#endif

#if NDTI == 0
#define dtiopen 	nodev
#define dticlose	nodev
#define dtiread 	nodev
#define dtiwrite	nodev
#define dtiioctl	nodev
#define dtistop 	nodev
#define dtireset	nulldev
#define dtiselect	nodev
#define dti_tty	0
/*
 * DTi dummy routines.  These routines always return a one
 * to fake out the ws driver into thinking the mouse and
 * keyboard are ok.  In actuality we'll use the DTi (Desktop
 * BusInterconnect) keyboard and mouse via the X-extension.
 */
dti_mouse_init()
{
  return(1);
}
dti_mouse_putc(c)
int c;
{
  return(1);
}
dti_mouse_getc()
{
  return(1);
}
dti_kbd_init()
{
  return(1);
}
dti_kbd_putc(c)
int c;
{
  return(1);
}
dti_kbd_getc()
{
  return(1);
}
#else	/* NDTI */
int	dtiopen(),dticlose(),dtiread(),dtiwrite(),dtiioctl(),dtistop();
int	dtireset(), dtiselect();
#endif	/* (NDTI == 0) */

#ifdef mips
#include <xcons.h>
#endif

#if NXCONS > 0
int     xconsopen(), xconsclose(), xconsread(), xconswrite();
int     xconsioctl(), xconsstop();
extern struct tty xcons_tty[];
#else
#define xconsopen          nodev
#define xconsclose         nodev
#define xconsread          nodev
#define xconswrite         nodev
#define xconsioctl         nodev
#define xconsstop          nodev
/*#define xcons_tty 0*/
/* TODO: HACK, ws_device.c references this */
struct tty xcons_tty[1];
#endif


#include <audit.h>
#if	AUDIT > 0
int	audopen(),audclose(),audread(),audwrite(),audioctl();
#else
#define audopen		nodev
#define audclose	nodev
#define audread		nodev
#define audwrite	nodev
#define audioctl	nodev
#endif

#include <spd.h>
#if	NSPD > 0
int	spdopen(),spdclose(),spdread(),spdwrite(),spdioctl();
#else
#define spdopen		nodev
#define spdclose	nodev
#define spdread		nodev
#define spdwrite	nodev
#define spdioctl	nodev
#endif

/*
 * Define presto NVRAM pseudo-driver device control routines
 */
/* Defined for LVM -- change if the presto cdevsw position changes */
int     pr_maj_devnum = 22;
#if NPRESTO > 0
int	propen(), prioctl();
#else
#define propen		nodev
#define prioctl		nodev
int presto_init() { /* dummy */ }
int presto_reboot() { /* dummy */ }
int prbounceio()  { /* dummy */ }
int prunbounceio()  { /* dummy */ }
int prdirectio()  { /* dummy */ }
int prenabled()  { /* dummy */ }
struct presto_interface presto_interface0; /* dummy */
struct nvram_battery_info nvram_batteries0; /* dummy */
int prattached = 0; /* dummy */
int prsize = 0; /* dummy */
#endif /* NPRESTO > 0 */

#include "streams.h"
#if	STREAMS
int	clone_open();
#else
#define clone_open	nodev
#endif

/*
 *      Character Device Switch static declaration and initialization
 */
/*
 * The user may specify a different cdevsw size in the config file.
 * MAX_CDEVSW will have a default of 125 and a minimum of 75.
 */
#ifdef	MAX_CDEVSW
#if	MAX_CDEVSW < 75
#define	MAX_CDEVSW	75
#endif	/* MAX_CDEVSW < 75 */
#else	/* MAX_CDEVSW needs defining */
#define	MAX_CDEVSW	125
#endif	/* MAX_CDEVSW */

dswlock_t       cdevlock[MAX_CDEVSW];           /* cdevsw lock structure */
/*
%%% BEGIN CDEVSW TABLE (first 3 chars of this line must be %%%
*/
struct cdevsw   cdevsw[MAX_CDEVSW] =
{
	cnopen,		cnclose,	cnread,		cnwrite,	/*0*/
	cnioctl,	nulldev,	nulldev,	cons,
	cnselect,	cnmmap		,DEV_FUNNEL_NULL,

	syopen,		nulldev,	syread,		sywrite,	/*1*/
	syioctl,	nulldev,	nulldev,	0,
	syselect,	nodev		,DEV_FUNNEL_NULL,

	/* this must agree with mem_no! */
	nulldev,	nulldev,	mmread,		mmwrite,	/*2*/
	nodev,		nulldev,	nulldev,	0,
	seltrue,	mmmap		,DEV_FUNNEL_NULL,

	/* Error log device on Ultrix */
	logopen,	logclose,	logread,	nodev,		/*3*/
	logioctl,	nodev,		nulldev,	0,
	logselect,	nodev		,DEV_FUNNEL_NULL,

	/* this is /dev/drum */
	nulldev,	nulldev,	nodev,		nodev,		/*4*/
	nodev,		nodev,		nulldev,	0,
	nodev,		nodev		,DEV_FUNNEL_NULL,

	/* conflict: LAT devices on Ultrix */
	nodev,		nodev,		nodev,		nodev,		/*5*/
	nodev,		nodev,		nodev,		0,
	nodev,		nodev		,DEV_FUNNEL_NULL,

	ptsopen,	ptsclose,	ptsread,	ptswrite,	/*6*/
	ptyioctl,	ptsstop,	nodev,		0,
	ptsselect,	nodev		,DEV_FUNNEL_NULL,

	ptcopen,	ptcclose,	ptcread,	ptcwrite,	/*7*/
	ptyioctl,	nulldev,	nodev,		0,
	ptcselect,	nodev		,DEV_FUNNEL_NULL,

	/* SCSI disk devices */
	/*
	 * Insert presto NVRAM pseudo-driver interface routines (RZ...).
	 * Warning: If these device major numbers change, then
	 *          data/presto_data.c must be modified.
	 */
        cdisk_open,     cdisk_close,   	RZread,         RZwrite,        /*8*/
	cdisk_ioctl,	nodev,		nulldev,	0,
	asyncsel,	nodev		,DEV_FUNNEL_NULL,

	/* SCSI tape devices */
	ctape_open,	ctape_close,	ctape_read,	ctape_write,	/*9*/
	ctape_ioctl,	nodev,		nulldev,	0,
	asyncsel,	nodev		,DEV_FUNNEL_NULL,

	nulldev,	nulldev,	nodev,		nodev,		/*10*/
	nodev,		nodev,		nulldev,	0,
	nodev,		nodev		,DEV_FUNNEL_NULL,

	/* This is the "trace" device on Pmax */
	nulldev,	nulldev,	nodev,		nodev,		/*11*/
	nodev,		nodev,		nulldev,	0,
	nodev,		nodev		,DEV_FUNNEL_NULL,

	/* This was the vice fs device */
	nulldev,	nulldev,	nodev,		nodev,		/*12*/
	nodev,		nodev,		nulldev,	0,
	nodev,		nodev		,DEV_FUNNEL_NULL,

	/* This was cmupty */
	nulldev,	nulldev,	nodev,		nodev,		/*13*/
	nodev,		nodev,		nulldev,	0,
	nodev,		nodev		,DEV_FUNNEL_NULL,

	/* This was cmupty */
	nulldev,	nulldev,	nodev,		nodev,		/*14*/
	nodev,		nodev,		nulldev,	0,
	nodev,		nodev		,DEV_FUNNEL_NULL,

	timeopen,	timeclose,	nodev,		nodev,		/*15*/
	nodev,		nodev,		nulldev,	0,
	nodev,		timemap		,DEV_FUNNEL_NULL,

	/* Logical Volume Manager device - cmajor and bmajor must match */
	lv_open0,	lv_close0,	lv_read0,	lv_write0,	/*16*/
	lv_ioctl0,	nodev,		nulldev,	lv_volgrp0,
	nodev,		nodev		,DEV_FUNNEL_NULL,

	/* Security audit device */
	audopen,	audclose,	audread,	audwrite,	/*17*/
	audioctl,	nodev,		nulldev,	0,
	nodev,		nodev		,DEV_FUNNEL_NULL,

	/* Security policy message passing device */
	spdopen,	spdclose,	spdread,	spdwrite,	/*18*/
	spdioctl,	nodev,		nulldev,	0,
	nodev,		nodev		,DEV_FUNNEL_NULL,

	/* Logical Volume Manager device - cmajor and bmajor must match */
	lv_open1,	lv_close1,	lv_read1,	lv_write1,	/*19*/
	lv_ioctl1,	nodev,		nulldev,	lv_volgrp1,
	nodev,		nodev		,DEV_FUNNEL_NULL,

	/* Logical Volume Manager device - cmajor and bmajor must match */
	lv_open2,	lv_close2,	lv_read2,	lv_write2,	/*20*/
	lv_ioctl2,	nodev,		nulldev,	lv_volgrp2,
	nodev,		nodev		,DEV_FUNNEL_NULL,

	/* dc7085 serial line driver */
        dcopen,		dcclose,	dcread,		dcwrite,	/*21*/
	dcioctl,	dcstop,		nulldev,	dc_tty,
	dcselect,	nodev		,DEV_FUNNEL_NULL,

	/* presto NVRAM pseudo-driver control "device" */
        propen,         nulldev,        nulldev,	nulldev,        /*22*/
        prioctl,        nulldev,        nulldev,        0,
        nodev,          nodev		,DEV_FUNNEL_NULL,

        /* xcons driver */
        xconsopen,      xconsclose,     xconsread,      xconswrite, 	/*23*/
        xconsioctl,     xconsstop,      nodev,          xcons_tty,
        ttselect,       nodev           ,DEV_FUNNEL_NULL,

	/* scc serial line driver */
        sccopen,        sccclose,       sccread,        sccwrite, 	/*24*/
        sccioctl,       sccstop,        nulldev,        scc_tty,
        sccselect,      nodev           ,DEV_FUNNEL_NULL,          

        /* dti - desk top interface driver */
	dtiopen, 	dticlose,	dtiread, 	dtiwrite,	/*25*/
	dtiioctl,	dtistop, 	dtireset,	0,
	dtiselect,	nodev		,DEV_FUNNEL_NULL,

	/* This was cmupty */
	nulldev,	nulldev,	nodev,		nodev,		/*26*/
	nodev,		nodev,		nulldev,	0,
	nodev,		nodev		,DEV_FUNNEL_NULL,

        /* DSA tmscp tape devices */
        { tmscpopen,     tmscpclose,     tmscpread,      tmscpwrite,    /*27*/
          tmscpioctl,    nodev,          uq_reset,       0,
          asyncsel,      nodev,          DEV_FUNNEL_NULL },

        /* DSA mscp disk devices */
        /*
         * Insert presto NVRAM pseudo-driver interface routines (MSCP_...).
         * Warning: If these device major numbers change, then
         *          data/presto_data.c must be modified.
         */
        { mscp_copen,     mscp_cclose,    MSCP_read,      MSCP_write,   /*28*/
          mscp_ioctl,     nodev,          nulldev,                0,
          asyncsel,       nodev,          DEV_FUNNEL_NULL },

 	/* dhu serial line driver */
        dhuopen,        dhuclose,       dhuread,        dhuwrite,       /*29*/
        dhuioctl,       dhustop,        nulldev,        dhu11,
        nodev,          nodev           ,DEV_FUNNEL_NULL,

	/*
	 * The CAM User Agent Driver.
	 */
	uagtopen,	uagtclose,	nodev,		nodev,		/*30*/
	uagtioctl,	nodev,		nodev,		0,
	nodev,		nodev		,DEV_FUNNEL_NULL,

        /* binary event logger */
	binlog_open,    binlog_close,   binlog_read,    binlog_write,  /*31*/
	binlog_ioctl,   nodev,          nulldev,          0,
	binlog_select,  nodev           ,DEV_FUNNEL_NULL,

	/* STREAMS clone device */
	{clone_open,    nodev,          nodev,          nodev,          /*32*/
	nodev,          nodev,          nodev,          0,
	nodev,          nodev,		DEV_FUNNEL_NULL },

};
/*
%%% END CDEVSW TABLE (first 3 chars of this line must be %%%
*/
int	nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);

dev_t	sydev = makedev(1, 0);	/* device number for indirect tty */

int	mem_no = 2; 	/* major device number of memory special file */


Assign_table	*assign_ptr = NULL;
