]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/i386/conf.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1997 by Apple Computer, Inc., all rights reserved
24 * Copyright (c) 1993 NeXT Computer, Inc.
26 * UNIX Device switch tables.
30 * 30 July 1997 Umesh Vaishampayan (umeshv@apple.com)
31 * enabled file descriptor pseudo-device.
32 * 18 June 1993 ? at NeXT
33 * Cleaned up a lot of stuff in this file.
36 #include <sys/param.h>
37 #include <sys/systm.h>
39 #include <sys/ioctl.h>
46 struct bdevsw bdevsw
[] =
49 * For block devices, every other block of 8 slots is
50 * reserved to NeXT. The other slots are available for
51 * the user. This way we can both add new entries without
52 * running into each other. Be sure to fill in NeXT's
53 * 8 reserved slots when you jump over us -- we'll do the
57 /* 0 - 7 are reserved to NeXT */
68 /* 8 - 15 are reserved to the user */
78 /* 16 - 23 are reserved to NeXT */
89 int nblkdev
= sizeof (bdevsw
) / sizeof (bdevsw
[0]);
91 extern struct tty
*km_tty
[];
92 extern int cnopen(),cnclose(),cnread(),cnwrite(),cnioctl(),
93 cnselect(),cngetc(), cnputc(dev_t dev
, char c
);
94 extern int kmopen(),kmclose(),kmread(),kmwrite(),kmioctl(),
95 kmgetc(), kmputc(dev_t dev
, char c
);
96 extern int sgopen(),sgclose(), sgioctl();
99 extern int volopen(),volclose(),volioctl();
101 #define volopen eno_opcl
102 #define volclose eno_opcl
103 #define volioctl eno_ioctl
106 extern int cttyopen(), cttyread(), cttywrite(), cttyioctl(), cttyselect();
108 extern int mmread(),mmwrite();
109 #define mmselect seltrue
110 #define mmmmap eno_mmap
114 extern struct tty
*pt_tty
[];
115 extern int ptsopen(),ptsclose(),ptsread(),ptswrite(),ptsstop(),ptsputc();
116 extern int ptcopen(),ptcclose(),ptcread(),ptcwrite(),ptcselect(),
119 #define ptsopen eno_opcl
120 #define ptsclose eno_opcl
121 #define ptsread eno_rdwrt
122 #define ptswrite eno_rdwrt
123 #define ptsstop nulldev
124 #define ptsputc nulldev
126 #define ptcopen eno_opcl
127 #define ptcclose eno_opcl
128 #define ptcread eno_rdwrt
129 #define ptcwrite eno_rdwrt
130 #define ptcselect eno_select
131 #define ptyioctl eno_ioctl
134 extern int logopen(),logclose(),logread(),logioctl(),logselect();
135 extern int fdesc_open(), fdesc_read(), fdesc_write(),
136 fdesc_ioctl(), fdesc_select();
138 extern int seltrue();
140 struct cdevsw cdevsw
[] =
143 * For character devices, every other block of 16 slots is
144 * reserved to NeXT. The other slots are available for
145 * the user. This way we can both add new entries without
146 * running into each other. Be sure to fill in NeXT's
147 * 16 reserved slots when you jump over us -- we'll do the
151 /* 0 - 15 are reserved to NeXT */
154 cnopen
, cnclose
, cnread
, cnwrite
, /* 0*/
155 cnioctl
, nulldev
, nulldev
, 0, cnselect
,
156 eno_mmap
, eno_strat
, cngetc
, cnputc
, D_TTY
160 cttyopen
, nulldev
, cttyread
, cttywrite
, /* 2*/
161 cttyioctl
, nulldev
, nulldev
, 0, cttyselect
,
162 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
165 nulldev
, nulldev
, mmread
, mmwrite
, /* 3*/
166 eno_ioctl
, nulldev
, nulldev
, 0, mmselect
,
167 mmmmap
, eno_strat
, eno_getc
, eno_putc
, 0
170 ptsopen
, ptsclose
, ptsread
, ptswrite
, /* 4*/
171 ptyioctl
, ptsstop
, nulldev
, pt_tty
, ttselect
,
172 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
175 ptcopen
, ptcclose
, ptcread
, ptcwrite
, /* 5*/
176 ptyioctl
, nulldev
, nulldev
, 0, ptcselect
,
177 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
180 logopen
, logclose
, logread
, eno_rdwrt
, /* 6*/
181 logioctl
, eno_stop
, nulldev
, 0, logselect
,
182 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
190 kmopen
, kmclose
, kmread
, kmwrite
, /*12*/
191 kmioctl
, nulldev
, nulldev
, km_tty
, ttselect
,
192 eno_mmap
, eno_strat
, kmgetc
, kmputc
, 0
198 /* 16 - 31 are reserved to the user */
216 /* 32 - 47 are reserved to NeXT */
218 fdesc_open
, eno_opcl
, fdesc_read
, fdesc_write
, /*32*/
219 fdesc_ioctl
, eno_stop
, eno_reset
, 0, fdesc_select
,
220 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
226 sgopen
, sgclose
, eno_rdwrt
, eno_rdwrt
, /*33*/
227 sgioctl
, eno_stop
, eno_reset
, 0, eno_select
,
228 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TAPE
240 volopen
, volclose
, eno_rdwrt
, eno_rdwrt
, /*42*/
241 volioctl
, eno_stop
, eno_reset
, 0, seltrue
,
242 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
245 int nchrdev
= sizeof (cdevsw
) / sizeof (cdevsw
[0]);
248 #include <sys/vnode.h> /* for VCHR and VBLK */
250 * return true if a disk
257 switch (major(dev
)) {
258 case 1: /* fd: floppy */
259 case 6: /* sd: scsi disk */
264 case 14: /* sd: scsi disk */
265 case 41: /* fd: floppy */
273 static int chrtoblktab
[] = {
274 /* CHR*/ /* BLK*/ /* CHR*/ /* BLK*/
275 /* 0 */ NODEV
, /* 1 */ NODEV
,
276 /* 2 */ NODEV
, /* 3 */ NODEV
,
277 /* 4 */ NODEV
, /* 5 */ NODEV
,
278 /* 6 */ NODEV
, /* 7 */ NODEV
,
279 /* 8 */ NODEV
, /* 9 */ NODEV
,
280 /* 10 */ NODEV
, /* 11 */ NODEV
,
281 /* 12 */ NODEV
, /* 13 */ NODEV
,
282 /* 14 */ 6, /* 15 */ NODEV
,
283 /* 16 */ NODEV
, /* 17 */ NODEV
,
284 /* 18 */ NODEV
, /* 19 */ NODEV
,
285 /* 20 */ NODEV
, /* 21 */ NODEV
,
286 /* 22 */ NODEV
, /* 23 */ NODEV
,
287 /* 24 */ NODEV
, /* 25 */ NODEV
,
288 /* 26 */ NODEV
, /* 27 */ NODEV
,
289 /* 28 */ NODEV
, /* 29 */ NODEV
,
290 /* 30 */ NODEV
, /* 31 */ NODEV
,
291 /* 32 */ NODEV
, /* 33 */ NODEV
,
292 /* 34 */ NODEV
, /* 35 */ NODEV
,
293 /* 36 */ NODEV
, /* 37 */ NODEV
,
294 /* 38 */ NODEV
, /* 39 */ NODEV
,
295 /* 40 */ NODEV
, /* 41 */ 1,
296 /* 42 */ NODEV
, /* 43 */ NODEV
,
301 * convert chr dev to blk dev
309 if (major(dev
) >= nchrdev
)
311 blkmaj
= chrtoblktab
[major(dev
)];
314 return(makedev(blkmaj
, minor(dev
)));
318 * Returns true if dev is /dev/mem or /dev/kmem.
324 return (major(dev
) == 3 && minor(dev
) < 2);