New device support patch, if_ed, sio, tw, codrv
[unix-history] / usr / src / sys.386bsd / i386 / i386 / conf.c
CommitLineData
e7e4c6ee
WJ
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)conf.c 5.8 (Berkeley) 5/12/91
db303f77
CD
37 *
38 * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
39 * -------------------- ----- ----------------------
76ee8424 40 * CURRENT PATCH LEVEL: 5 00160
db303f77
CD
41 * -------------------- ----- ----------------------
42 *
43 * 10 Feb 93 Jordan K. Hubbard Added select entry for com driver
fb92ec4c
JE
44 * 10 Feb 93 Julian Elischer Add empty table entries
45 * so we can allocate numbers
42049003
JH
46 * 15 Feb 93 Julian Elischer Add basic SCSI device entries
47 * 16 Feb 93 Julian Elischer add entries for scsi media changer
48 * 01 Mar 93 Jordan K. Hubbard Reserve major numbers for codrv, fd, bpf
49 * 10 Mar 83 Rodney W. Grimes General clean up of the above patches
b526fba4
RG
50 * 06 Apr 93 Rodney W. Grimes Fixed NLPT for LPA driver case, added
51 * spkr, dcfclock
76ee8424
HV
52 * 23 Apr 93 Holger Veit added codrv
53 * 25 May 93 Bruce Evans New fast interrupt serial driver (sio)
54 * Gene Stark Xten power controller info added (tw)
55 * Rick Macklem Bus mouse driver (mse)
56 *
e7e4c6ee
WJ
57 */
58static char rcsid[] = "$Header: /usr/src/sys.386bsd/i386/i386/RCS/conf.c,v 1.2 92/01/21 14:21:57 william Exp Locker: toor $";
59
60#include "param.h"
61#include "systm.h"
62#include "buf.h"
63#include "ioctl.h"
64#include "tty.h"
65#include "conf.h"
66
67int nullop(), enxio(), enodev(), rawread(), rawwrite(), swstrategy();
68int rawread(), rawwrite(), swstrategy();
69
70#include "wd.h"
71#if NWD > 0
72int wdopen(),wdclose(),wdstrategy(),wdioctl();
73int wddump(),wdsize();
74#else
75#define wdopen enxio
76#define wdclose enxio
77#define wdstrategy enxio
78#define wdioctl enxio
79#define wddump enxio
80#define wdsize NULL
81#endif
82
83#include "as.h"
84#if NAS > 0
85int asopen(),asclose(),asstrategy(),asioctl();
86int /*asdump(),*/assize();
87#define asdump enxio
88#else
89#define asopen enxio
90#define asclose enxio
91#define asstrategy enxio
92#define asioctl enxio
93#define asdump enxio
94#define assize NULL
95#endif
96
42049003
JH
97#include "sd.h"
98#if NSD > 0
99int sdopen(),sdclose(),sdstrategy(),sdioctl();
100int /*sddump(),*/sdsize();
101#define sddump enxio
102#else
103#define sdopen enxio
104#define sdclose enxio
105#define sdstrategy enxio
106#define sdioctl enxio
107#define sddump enxio
108#define sdsize NULL
109#endif
110
111#include "st.h"
112#if NST > 0
113int stopen(),stclose(),ststrategy(),stioctl();
114/*int stdump(),stsize();*/
115#define stdump enxio
116#define stsize NULL
117#else
118#define stopen enxio
119#define stclose enxio
120#define ststrategy enxio
121#define stioctl enxio
122#define stdump enxio
123#define stsize NULL
124#endif
125
126#include "cd.h"
127#if NCD > 0
128int cdopen(),cdclose(),cdstrategy(),cdioctl();
129int /*cddump(),*/cdsize();
130#define cddump enxio
131#else
132#define cdopen enxio
133#define cdclose enxio
134#define cdstrategy enxio
135#define cdioctl enxio
136#define cddump enxio
137#define cdsize NULL
138#endif
139
140#include "ch.h"
141#if NCH > 0
142int chopen(),chclose(),chioctl();
143#else
144#define chopen enxio
145#define chclose enxio
146#define chioctl enxio
147#endif
148
e7e4c6ee
WJ
149#include "wt.h"
150#if NWT > 0
151int wtopen(),wtclose(),wtstrategy(),wtioctl();
152int wtdump(),wtsize();
153#else
154#define wtopen enxio
155#define wtclose enxio
156#define wtstrategy enxio
157#define wtioctl enxio
158#define wtdump enxio
159#define wtsize NULL
160#endif
161
162#include "fd.h"
163#if NFD > 0
164int Fdopen(),fdclose(),fdstrategy();
165#define fdioctl enxio
166#define fddump enxio
167#define fdsize NULL
168#else
169#define Fdopen enxio
170#define fdclose enxio
171#define fdstrategy enxio
172#define fdioctl enxio
173#define fddump enxio
174#define fdsize NULL
175#endif
176
177int swstrategy(),swread(),swwrite();
178
179struct bdevsw bdevsw[] =
180{
181 { wdopen, wdclose, wdstrategy, wdioctl, /*0*/
182 wddump, wdsize, NULL },
183 { enodev, enodev, swstrategy, enodev, /*1*/
184 enodev, enodev, NULL },
185 { Fdopen, fdclose, fdstrategy, fdioctl, /*2*/
186 fddump, fdsize, NULL },
187 { wtopen, wtclose, wtstrategy, wtioctl, /*3*/
188 wtdump, wtsize, B_TAPE },
42049003
JH
189#if NSD > 0
190 { sdopen, sdclose, sdstrategy, sdioctl, /*4*/
191 sddump, sdsize, NULL },
192#else NSD > 0
e7e4c6ee
WJ
193 { asopen, asclose, asstrategy, asioctl, /*4*/
194 asdump, assize, NULL },
42049003
JH
195#endif NSD > 0
196 { stopen, stclose, ststrategy, stioctl, /*5*/
197 stdump, stsize, NULL },
198 { cdopen, cdclose, cdstrategy, cdioctl, /*6*/
199 cddump, cdsize, NULL },
200/*
201 * If you need a bdev major number, please contact the 386bsd patchkit
b526fba4 202 * coordinator by sending mail to "patches@cs.montana.edu".
42049003
JH
203 * If you assign one yourself it may conflict with someone else.
204 */
e7e4c6ee
WJ
205};
206int nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]);
207
208int cnopen(),cnclose(),cnread(),cnwrite(),cnioctl(),cnselect();
209
210int pcopen(),pcclose(),pcread(),pcwrite(),pcioctl(),pcmmap();
211extern struct tty pccons;
212
213int cttyopen(), cttyread(), cttywrite(), cttyioctl(), cttyselect();
214
215int mmrw();
216#define mmselect seltrue
217
218#include "pty.h"
219#if NPTY > 0
220int ptsopen(),ptsclose(),ptsread(),ptswrite(),ptsstop();
221int ptcopen(),ptcclose(),ptcread(),ptcwrite(),ptcselect();
222int ptyioctl();
223struct tty pt_tty[];
224#else
225#define ptsopen enxio
226#define ptsclose enxio
227#define ptsread enxio
228#define ptswrite enxio
229#define ptcopen enxio
230#define ptcclose enxio
231#define ptcread enxio
232#define ptcwrite enxio
233#define ptyioctl enxio
234#define pt_tty NULL
235#define ptcselect enxio
236#define ptsstop nullop
237#endif
238
239#include "com.h"
240#if NCOM > 0
db303f77 241int comopen(),comclose(),comread(),comwrite(),comioctl(),comselect();
e7e4c6ee
WJ
242#define comreset enxio
243extern struct tty com_tty[];
244#else
245#define comopen enxio
246#define comclose enxio
247#define comread enxio
248#define comwrite enxio
249#define comioctl enxio
250#define comreset enxio
db303f77 251#define comselect enxio
e7e4c6ee
WJ
252#define com_tty NULL
253#endif
254
255int logopen(),logclose(),logread(),logioctl(),logselect();
256
257int ttselect(), seltrue();
258
42049003
JH
259#include "lpt.h"
260#if NLPT > 0
261int lptopen(),lptclose(),lptwrite(),lptioctl();
262#else
263#define lptopen enxio
264#define lptclose enxio
265#define lptwrite enxio
266#define lptioctl enxio
267#endif
268
76ee8424
HV
269#include "co.h"
270#if NCO > 0
271int coopen(),coclose(),coread(),coioctl(),coselect(),comap();
272#define pcmmap comap
273#else
274#define coopen enxio
275#define coclose enxio
276#define coread enxio
277#define coioctl enxio
278#define coselect enxio
279#define comap enxio
280#endif
281
282#include "tw.h"
283#if NTW > 0
284int twopen(),twclose(),twread(),twwrite(),twselect();
285#else
286#define twopen enxio
287#define twclose enxio
288#define twread enxio
289#define twwrite enxio
290#define twselect enxio
291#endif
292
42049003
JH
293int fdopen();
294
295#include "bpfilter.h"
296#if NBPFILTER > 0
297int bpfopen(),bpfclose(),bpfread(),bpfwrite(),bpfselect(),bpfioctl();
298#else
299#define bpfopen enxio
300#define bpfclose enxio
301#define bpfread enxio
302#define bpfwrite enxio
303#define bpfselect enxio
304#define bpfioctl enxio
305#endif
306
b526fba4
RG
307#include "dcfclk.h"
308#if NDCFCLK > 0
309int dcfclkopen(),dcfclkclose(),dcfclkread(),dcfclkioctl(),dcfclkselect();
310#else
311#define dcfclkopen enxio
312#define dcfclkclose enxio
313#define dcfclkread enxio
314#define dcfclkioctl enxio
315#define dcfclkselect enxio
316#endif
317
42049003 318#include "lpa.h"
b526fba4 319#if NLPA > 0
42049003
JH
320int lpaopen(),lpaclose(),lpawrite(),lpaioctl();
321#else
322#define lpaopen enxio
323#define lpaclose enxio
324#define lpawrite enxio
325#define lpaioctl enxio
326#endif
327
b526fba4
RG
328#include "speaker.h"
329#if NSPEAKER > 0
330int spkropen(),spkrclose(),spkrwrite(),spkrioctl();
331#else
76ee8424
HV
332#define spkropen enxio
333#define spkrclose enxio
334#define spkrwrite enxio
335#define spkrioctl enxio
336#endif
337
338#include "mse.h"
339#if NMSE > 0
340int mseopen(),mseclose(),mseread(),mseselect();
341#else
342#define mseopen enxio
343#define mseclose enxio
344#define mseread enxio
345#define mseselect enxio
346#endif
347
348#include "sio.h"
349#if NSIO > 0
350int sioopen(),sioclose(),sioread(),siowrite(),sioioctl(),sioselect(),
351 siostop();
352#define sioreset enxio
353extern struct tty sio_tty[];
354#else
355#define sioopen enxio
356#define sioclose enxio
357#define sioread enxio
358#define siowrite enxio
359#define sioioctl enxio
360#define siostop enxio
361#define sioreset enxio
362#define sioselect enxio
363#define sio_tty NULL
b526fba4 364#endif
e7e4c6ee
WJ
365
366struct cdevsw cdevsw[] =
367{
368 { cnopen, cnclose, cnread, cnwrite, /*0*/
b526fba4 369 cnioctl, nullop, nullop, NULL, /* console */
e7e4c6ee
WJ
370 cnselect, enodev, NULL },
371 { cttyopen, nullop, cttyread, cttywrite, /*1*/
b526fba4 372 cttyioctl, nullop, nullop, NULL, /* tty */
e7e4c6ee
WJ
373 cttyselect, enodev, NULL },
374 { nullop, nullop, mmrw, mmrw, /*2*/
b526fba4 375 enodev, nullop, nullop, NULL, /* memory */
e7e4c6ee
WJ
376 mmselect, enodev, NULL },
377 { wdopen, wdclose, rawread, rawwrite, /*3*/
b526fba4 378 wdioctl, enodev, nullop, NULL, /* wd */
e7e4c6ee
WJ
379 seltrue, enodev, wdstrategy },
380 { nullop, nullop, rawread, rawwrite, /*4*/
b526fba4 381 enodev, enodev, nullop, NULL, /* swap */
e7e4c6ee
WJ
382 enodev, enodev, swstrategy },
383 { ptsopen, ptsclose, ptsread, ptswrite, /*5*/
b526fba4 384 ptyioctl, ptsstop, nullop, pt_tty, /* ttyp */
e7e4c6ee
WJ
385 ttselect, enodev, NULL },
386 { ptcopen, ptcclose, ptcread, ptcwrite, /*6*/
b526fba4 387 ptyioctl, nullop, nullop, pt_tty, /* ptyp */
e7e4c6ee
WJ
388 ptcselect, enodev, NULL },
389 { logopen, logclose, logread, enodev, /*7*/
b526fba4 390 logioctl, enodev, nullop, NULL, /* klog */
e7e4c6ee
WJ
391 logselect, enodev, NULL },
392 { comopen, comclose, comread, comwrite, /*8*/
b526fba4 393 comioctl, enodev, comreset, com_tty, /* com */
db303f77 394 comselect, enodev, NULL },
e7e4c6ee 395 { Fdopen, fdclose, rawread, rawwrite, /*9*/
42049003 396 fdioctl, enodev, nullop, NULL, /* Fd (!=fd) */
e7e4c6ee 397 seltrue, enodev, fdstrategy },
42049003 398 { wtopen, wtclose, rawread, rawwrite, /*10*/
b526fba4 399 wtioctl, enodev, nullop, NULL, /* wt */
e7e4c6ee 400 seltrue, enodev, wtstrategy },
42049003 401 { enodev, enodev, enodev, enodev, /*11*/
e7e4c6ee
WJ
402 enodev, enodev, nullop, NULL,
403 seltrue, enodev, enodev },
42049003 404 { pcopen, pcclose, pcread, pcwrite, /*12*/
76ee8424 405 pcioctl, nullop, nullop, &pccons, /* pc */
e7e4c6ee 406 ttselect, pcmmap, NULL },
42049003
JH
407#if NSD > 0
408 { sdopen, sdclose, rawread, rawwrite, /*13*/
b526fba4 409 sdioctl, enodev, nullop, NULL, /* sd */
42049003
JH
410 seltrue, enodev, sdstrategy },
411#else NSD > 0
412 { asopen, asclose, rawread, rawwrite, /*13*/
b526fba4 413 asioctl, enodev, nullop, NULL, /* as */
e7e4c6ee 414 seltrue, enodev, asstrategy },
42049003
JH
415#endif NSD > 0
416 { stopen, stclose, rawread, rawwrite, /*14*/
b526fba4 417 stioctl, enodev, nullop, NULL, /* st */
42049003
JH
418 seltrue, enodev, ststrategy },
419 { cdopen, cdclose, rawread, enodev, /*15*/
b526fba4 420 cdioctl, enodev, nullop, NULL, /* cd */
42049003
JH
421 seltrue, enodev, cdstrategy },
422 { lptopen, lptclose, nullop, lptwrite, /*16*/
423 lptioctl, nullop, nullop, NULL, /* lpt */
424 seltrue, enodev, enodev},
425 { chopen, chclose, enxio, enxio, /*17*/
b526fba4 426 chioctl, enxio, enxio, NULL, /* ch */
fb92ec4c 427 enxio, enxio, enxio },
42049003 428 { enxio, enxio, enxio, enxio, /*18*/
fb92ec4c
JE
429 enxio, enxio, enxio, NULL, /* scsi generic */
430 enxio, enxio, enxio },
76ee8424
HV
431 { twopen, twclose, twread, twwrite, /*19*/
432 enodev, nullop, nullop, NULL, /* tw */
433 twselect, enodev, enodev },
42049003 434 { enxio, enxio, enxio, enxio, /*20*/
fb92ec4c
JE
435 enxio, enxio, enxio, NULL, /* soundblaster?*/
436 enxio, enxio, enxio },
76ee8424
HV
437 { coopen, coclose, coread, enxio, /*21*/
438 coioctl, nullop, nullop, NULL, /* co */
439 coselect, comap, NULL },
42049003
JH
440 { fdopen, enxio, enxio, enxio, /*22*/
441 enxio, enxio, enxio, NULL, /* fd (!=Fd) */
fb92ec4c 442 enxio, enxio, enxio },
42049003
JH
443 { bpfopen, bpfclose, bpfread, bpfwrite, /*23*/
444 bpfioctl, enodev, nullop, NULL, /* bpf */
445 bpfselect, enodev, NULL },
b526fba4
RG
446 { dcfclkopen, dcfclkclose, dcfclkread, enodev, /*24*/
447 dcfclkioctl, enodev, nullop, NULL, /* dcfclk */
448 dcfclkselect, enodev, NULL },
42049003
JH
449 { lpaopen, lpaclose, nullop, lpawrite, /*25*/
450 lpaioctl, nullop, nullop, NULL, /* lpa */
451 seltrue, enodev, enodev},
b526fba4
RG
452 { spkropen, spkrclose, enxio, spkrwrite, /*26*/
453 spkrioctl, enxio, enxio, NULL, /* spkr */
454 enxio, enxio, enxio },
76ee8424
HV
455 { mseopen, mseclose, mseread, nullop, /*27*/
456 nullop, enodev, nullop, NULL, /* mse */
457 mseselect, enodev, NULL },
458 { sioopen, sioclose, sioread, siowrite, /*28*/
459 sioioctl, siostop, sioreset, sio_tty, /* sio */
460 sioselect, enodev, NULL },
42049003
JH
461/*
462 * If you need a cdev major number, please contact the 386bsd patchkit
b526fba4 463 * coordinator by sending mail to "patches@cs.montana.edu".
42049003
JH
464 * If you assign one yourself it may then conflict with someone else.
465 */
e7e4c6ee
WJ
466};
467int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
468
469int mem_no = 2; /* major device number of memory special file */
470
471/*
472 * Swapdev is a fake device implemented
473 * in sw.c used only internally to get to swstrategy.
474 * It cannot be provided to the users, because the
475 * swstrategy routine munches the b_dev and b_blkno entries
476 * before calling the appropriate driver. This would horribly
477 * confuse, e.g. the hashing routines. Instead, /dev/drum is
478 * provided as a character (raw) device.
479 */
480dev_t swapdev = makedev(1, 0);