xref: /original-bsd/sys/tahoe/tahoe/conf.c (revision 4fb4d9e8)
1 /*
2  * Copyright (c) 1988 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)conf.c	7.9 (Berkeley) 05/08/91
8  */
9 
10 #include "sys/param.h"
11 #include "sys/systm.h"
12 #include "sys/buf.h"
13 #include "sys/ioctl.h"
14 #include "sys/tty.h"
15 #include "sys/conf.h"
16 
17 int nullop(), enxio(), enodev(), rawread(), rawwrite(), swstrategy();
18 
19 #include "dk.h"
20 #if NVD > 0
21 int	vdopen(),vdclose(),vdstrategy(),vdioctl();
22 int	vddump(),vdsize();
23 #else
24 #define	vdopen		enxio
25 #define	vdclose		enxio
26 #define	vdstrategy	enxio
27 #define	vdioctl		enxio
28 #define	vddump		enxio
29 #define	vdsize		0
30 #endif
31 
32 #include "hd.h"
33 #if NHD > 0
34 int	hdopen(),hdclose(),hdstrategy(),hdioctl();
35 int	hddump(),hdsize();
36 #else
37 #define	hdopen		enxio
38 #define	hdclose		enxio
39 #define	hdstrategy	enxio
40 #define	hdioctl		enxio
41 #define	hddump		enxio
42 #define	hdsize		0
43 #endif
44 
45 #include "yc.h"
46 #if NCY > 0
47 int	cyopen(),cyclose(),cystrategy(),cydump();
48 int	cyioctl(),cyreset();
49 #else
50 #define	cyopen		enxio
51 #define	cyclose		enxio
52 #define	cystrategy	enxio
53 #define	cydump		enxio
54 #define	cyioctl		enxio
55 #define	cyreset		nullop
56 #endif
57 
58 struct bdevsw	bdevsw[] =
59 {
60 	{ enodev,	nullop,		enodev,		enodev,		/*0*/
61 	  enodev,	0,		0 },
62 	{ vdopen,	vdclose,	vdstrategy,	vdioctl,	/*1*/
63 	  vddump,	vdsize,		0 },
64 	{ hdopen,	hdclose,	hdstrategy,	hdioctl,	/*2*/
65 	  hddump,	hdsize,		0 },
66 	{ cyopen,	cyclose,	cystrategy,	cyioctl,	/*3*/
67 	  cydump,	0,		B_TAPE },
68 	{ enodev,	enodev,		swstrategy,	enodev,		/*4*/
69 	  enodev,	0,		0 },
70 };
71 int	nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]);
72 
73 int	cnopen(),cnclose(),cnread(),cnwrite(),cnioctl();
74 extern	struct tty cons;
75 
76 #include "vx.h"
77 #if NVX == 0
78 #define	vxopen	enxio
79 #define	vxclose	enxio
80 #define	vxread	enxio
81 #define	vxwrite	enxio
82 #define	vxioctl	enxio
83 #define	vxstop	enxio
84 #define	vxreset	nullop
85 #define	vx_tty	0
86 #else
87 int	vxopen(),vxclose(),vxread(),vxwrite(),vxioctl(),vxstop(),vxreset();
88 struct	tty vx_tty[];
89 #endif
90 
91 int	cttyopen(),cttyread(),cttywrite(),cttyioctl(),cttyselect();
92 
93 int 	mmrw();
94 #define	mmselect	seltrue
95 
96 #include "pty.h"
97 #if NPTY > 0
98 int	ptsopen(),ptsclose(),ptsread(),ptswrite(),ptsstop();
99 int	ptcopen(),ptcclose(),ptcread(),ptcwrite(),ptcselect();
100 int	ptyioctl();
101 struct	tty pt_tty[];
102 #else
103 #define ptsopen		enxio
104 #define ptsclose	enxio
105 #define ptsread		enxio
106 #define ptswrite	enxio
107 #define ptcopen		enxio
108 #define ptcclose	enxio
109 #define ptcread		enxio
110 #define ptcwrite	enxio
111 #define ptyioctl	enxio
112 #define	pt_tty		0
113 #define	ptcselect	enxio
114 #define	ptsstop		nullop
115 #endif
116 
117 #include "mp.h"
118 #if NMP > 0
119 int	mpopen(), mpclose(), mpread(), mpwrite(), mpioctl(), mpstop();
120 int	mpdlopen(), mpdlclose(), mpdlwrite(), mpdlioctl();
121 extern	struct tty mp_tty[];
122 #else
123 #define	mpopen		enxio
124 #define	mpclose		enxio
125 #define	mpread		enxio
126 #define	mpwrite		enxio
127 #define	mpioctl		enxio
128 #define	mpstop		enxio
129 #define	mpdlopen	enxio
130 #define	mpdlclose	enxio
131 #define	mpdlwrite	enxio
132 #define	mpdlioctl	enxio
133 #define	mp_tty		0
134 #endif
135 
136 #if NII > 0
137 int	iiioctl(), iiclose(), iiopen();
138 #else
139 #define	iiopen	enxio
140 #define	iiclose	enxio
141 #define	iiioctl	enxio
142 #endif
143 
144 #include "enp.h"
145 #if NENP > 0
146 int	enpr_open(), enpr_close(), enpr_read(), enpr_write(), enpr_ioctl();
147 #else
148 #define enpr_open	enxio
149 #define enpr_close	enxio
150 #define enpr_read	enxio
151 #define enpr_write	enxio
152 #define enpr_ioctl	enxio
153 #endif
154 
155 #include "dr.h"
156 #if NDR > 0
157 int     dropen(),drclose(),drread(),drwrite(),drioctl(),drreset();
158 #else
159 #define dropen enxio
160 #define drclose enxio
161 #define drread enxio
162 #define drwrite enxio
163 #define drioctl enxio
164 #define drreset enxio
165 #endif
166 
167 #include "ik.h"
168 #if NIK > 0
169 int     ikopen(),ikclose(),ikread(),ikwrite(),ikioctl();
170 #else
171 #define ikopen enxio
172 #define ikclose enxio
173 #define ikread enxio
174 #define ikwrite enxio
175 #define ikioctl enxio
176 #endif
177 
178 int	logopen(),logclose(),logread(),logioctl(),logselect();
179 
180 int	fdopen();
181 
182 int	ttselect(), seltrue();
183 
184 struct cdevsw	cdevsw[] =
185 {
186 	{ cnopen,	cnclose,	cnread,		cnwrite,	/*0*/
187 	  cnioctl,	nullop,		nullop,		&cons,
188 	  ttselect,	enodev,		NULL },
189 	{ vxopen,	vxclose,	vxread,		vxwrite,	/*1*/
190 	  vxioctl,	vxstop,		vxreset,	vx_tty,
191 	  ttselect,	enodev,		NULL },
192 	{ cttyopen,	nullop,		cttyread,	cttywrite,	/*2*/
193 	  cttyioctl,	nullop,		nullop,		NULL,
194 	  cttyselect,	enodev,		NULL },
195 	{ nullop,	nullop,		mmrw,		mmrw,		/*3*/
196 	  enodev,	nullop,		nullop,		NULL,
197 	  mmselect,	enodev,		NULL },
198 	{ enodev,	nullop,		enodev,		enodev,		/*4*/
199 	  enodev,	enodev,		nullop,		NULL,
200 	  seltrue,	enodev,		NULL },
201 	{ vdopen,	vdclose,	rawread,	rawwrite,	/*5*/
202 	  vdioctl,	enodev,		nullop,		NULL,
203 	  seltrue,	enodev,		vdstrategy },
204 	{ hdopen,	hdclose,	rawread,	rawwrite,	/*6*/
205 	  hdioctl,	enodev,		nullop,		NULL,
206 	  seltrue,	enodev,		hdstrategy },
207 	{ cyopen,	cyclose,	rawread,	rawwrite,	/*7*/
208 	  cyioctl,	enodev,		cyreset,	NULL,
209 	  seltrue,	enodev,		cystrategy },
210 	{ nullop,	nullop,		rawread,	rawwrite,	/*8*/
211 	  enodev,	enodev,		nullop,		NULL,
212 	  enodev,	enodev,		swstrategy },
213 	{ ptsopen,	ptsclose,	ptsread,	ptswrite,	/*9*/
214 	  ptyioctl,	ptsstop,	enodev,		pt_tty,
215 	  ttselect,	enodev,		NULL },
216 	{ ptcopen,	ptcclose,	ptcread,	ptcwrite,	/*10*/
217 	  ptyioctl,	nullop,		enodev,		pt_tty,
218 	  ptcselect,	enodev,		NULL },
219 	{ mpdlopen,	mpdlclose,	enodev,		mpdlwrite,	/*11*/
220 	  mpdlioctl,	enodev,		nullop,		NULL,
221 	  seltrue,	enodev,		NULL },
222 	{ mpopen,	mpclose,	mpread,		mpwrite,	/*12*/
223 	  mpioctl,	mpstop,		nullop,		mp_tty,
224 	  ttselect,	enodev,		NULL },
225 	{ enodev,	enodev,		enodev,		enodev,		/*13*/
226 	  enodev,	enodev,		nullop,		NULL,
227 	  enodev,	enodev,		NULL },
228 	{ iiopen,	iiclose,	nullop,		nullop,		/*14*/
229 	  iiioctl,	nullop,		nullop,		NULL,
230 	  seltrue,	enodev,		NULL },
231 	{ logopen,	logclose,	logread,	enodev,		/*15*/
232 	  logioctl,	enodev,		nullop,		NULL,
233 	  logselect,	enodev,		NULL },
234 	{ enpr_open,	enpr_close,	enpr_read,	enpr_write,	/*16*/
235 	  enpr_ioctl,	enodev,		nullop,		NULL,
236 	  enodev,	enodev,		NULL },
237 	{ enodev,	enodev,		enodev,		enodev,		/*17*/
238 	  enodev,	enodev,		nullop,		NULL,
239 	  enodev,	enodev,		NULL },
240 	{ dropen,	drclose,	drread,		drwrite,	/*18*/
241 	  drioctl,	enodev,		drreset,	NULL,
242 	  enodev,	enodev,		NULL },
243 	{ fdopen,	enodev,		enodev,		enodev,		/*19*/
244 	  enodev,	enodev,		enodev,		NULL,
245 	  enodev,	enodev,		NULL },
246 /* 20-30 are reserved for local use */
247 	{ ikopen,	ikclose,	ikread,		ikwrite,	/*20*/
248 	  ikioctl,	enodev,		nullop,		NULL,
249 	  enodev,	enodev,		NULL },
250 	{ fdopen,	enodev,		enodev,		enodev,		/*21*/
251 	  enodev,	enodev,		enodev,		NULL,
252 	  enodev,	enodev,		NULL },
253 };
254 int	nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
255 
256 int	mem_no = 3; 	/* major device number of memory special file */
257 
258 /*
259  * Swapdev is a fake device implemented
260  * in sw.c used only internally to get to swstrategy.
261  * It cannot be provided to the users, because the
262  * swstrategy routine munches the b_dev and b_blkno entries
263  * before calling the appropriate driver.  This would horribly
264  * confuse, e.g. the hashing routines. Instead, /dev/drum is
265  * provided as a character (raw) device.
266  */
267 dev_t	swapdev = makedev(4, 0);
268