]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/ppc/conf.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1997 by Apple Computer, Inc., all rights reserved
27 * Copyright (c) 1993 NeXT Computer, Inc.
29 * UNIX Device switch tables.
33 * 30 July 1997 Umesh Vaishampayan (umeshv@apple.com)
34 * enabled file descriptor pseudo-device.
35 * 18 June 1993 ? at NeXT
36 * Cleaned up a lot of stuff in this file.
39 #include <sys/param.h>
40 #include <sys/systm.h>
42 #include <sys/ioctl.h>
49 struct bdevsw bdevsw
[] =
52 * For block devices, every other block of 8 slots is
53 * reserved to NeXT. The other slots are available for
54 * the user. This way we can both add new entries without
55 * running into each other. Be sure to fill in NeXT's
56 * 8 reserved slots when you jump over us -- we'll do the
60 /* 0 - 7 are reserved to NeXT */
71 /* 8 - 15 are reserved to the user */
81 /* 16 - 23 are reserved to NeXT */
92 int nblkdev
= sizeof (bdevsw
) / sizeof (bdevsw
[0]);
94 extern struct tty
*km_tty
[];
95 extern int consopen(), consclose(), consread(), conswrite(), consioctl(),
96 consselect(), cons_getc(), cons_putc();
97 extern int kmopen(),kmclose(),kmread(),kmwrite(),kmioctl(),
98 kmgetc(), kmputc(dev_t dev
, char c
);
100 extern int cttyopen(), cttyread(), cttywrite(), cttyioctl(), cttyselect();
102 extern int mmread(),mmwrite();
103 #define mmselect seltrue
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 seltrue();
137 struct cdevsw cdevsw
[] =
140 * For character devices, every other block of 16 slots is
141 * reserved to NeXT. The other slots are available for
142 * the user. This way we can both add new entries without
143 * running into each other. Be sure to fill in NeXT's
144 * 16 reserved slots when you jump over us -- we'll do the
148 /* 0 - 15 are reserved to NeXT */
151 consopen
, consclose
, consread
, conswrite
, /* 0*/
152 consioctl
, nulldev
, nulldev
, 0, consselect
,
153 eno_mmap
, eno_strat
, (getc_fcn_t
*)cons_getc
, (putc_fcn_t
*)cons_putc
, D_TTY
157 cttyopen
, nulldev
, cttyread
, cttywrite
, /* 2*/
158 cttyioctl
, nulldev
, nulldev
, 0, cttyselect
,
159 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
162 nulldev
, nulldev
, mmread
, mmwrite
, /* 3*/
163 eno_ioctl
, nulldev
, nulldev
, 0, (select_fcn_t
*)mmselect
,
164 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
167 ptsopen
, ptsclose
, ptsread
, ptswrite
, /* 4*/
168 ptyioctl
, ptsstop
, nulldev
, pt_tty
, ttselect
,
169 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
172 ptcopen
, ptcclose
, ptcread
, ptcwrite
, /* 5*/
173 ptyioctl
, nulldev
, nulldev
, 0, ptcselect
,
174 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
177 logopen
, logclose
, logread
, eno_rdwrt
, /* 6*/
178 logioctl
, eno_stop
, nulldev
, 0, logselect
,
179 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
187 kmopen
, kmclose
, kmread
, kmwrite
, /*12*/
188 kmioctl
, nulldev
, nulldev
, km_tty
, ttselect
,
189 eno_mmap
, eno_strat
, kmgetc
, kmputc
, 0
195 /* 16 - 31 are reserved to the user */
213 /* 32 - 47 are reserved to NeXT */
219 /* 37 used to be for nvram */
224 /* 41 used to be for fd */
228 int nchrdev
= sizeof (cdevsw
) / sizeof (cdevsw
[0]);
231 #include <sys/vnode.h> /* for VCHR and VBLK */
233 * return true if a disk
240 dev_t maj
= major(dev
);
250 if (bdevsw
[maj
].d_type
== D_DISK
) {
258 static int chrtoblktab
[] = {
259 /* CHR*/ /* BLK*/ /* CHR*/ /* BLK*/
260 /* 0 */ NODEV
, /* 1 */ NODEV
,
261 /* 2 */ NODEV
, /* 3 */ NODEV
,
262 /* 4 */ NODEV
, /* 5 */ NODEV
,
263 /* 6 */ NODEV
, /* 7 */ NODEV
,
264 /* 8 */ NODEV
, /* 9 */ NODEV
,
265 /* 10 */ NODEV
, /* 11 */ NODEV
,
266 /* 12 */ NODEV
, /* 13 */ NODEV
,
267 /* 14 */ 6, /* 15 */ NODEV
,
268 /* 16 */ NODEV
, /* 17 */ NODEV
,
269 /* 18 */ NODEV
, /* 19 */ NODEV
,
270 /* 20 */ NODEV
, /* 21 */ NODEV
,
271 /* 22 */ NODEV
, /* 23 */ NODEV
,
272 /* 24 */ NODEV
, /* 25 */ NODEV
,
273 /* 26 */ NODEV
, /* 27 */ NODEV
,
274 /* 28 */ NODEV
, /* 29 */ NODEV
,
275 /* 30 */ NODEV
, /* 31 */ NODEV
,
276 /* 32 */ NODEV
, /* 33 */ NODEV
,
277 /* 34 */ NODEV
, /* 35 */ NODEV
,
278 /* 36 */ NODEV
, /* 37 */ NODEV
,
279 /* 38 */ NODEV
, /* 39 */ NODEV
,
280 /* 40 */ NODEV
, /* 41 */ 1,
281 /* 42 */ NODEV
, /* 43 */ NODEV
,
286 * convert chr dev to blk dev
294 if (major(dev
) >= nchrdev
)
296 blkmaj
= chrtoblktab
[major(dev
)];
299 return(makedev(blkmaj
, minor(dev
)));
303 chrtoblk_set(int cdev
, int bdev
)
307 if (bdev
!= NODEV
&& bdev
>= nblkdev
)
309 chrtoblktab
[cdev
] = bdev
;
314 * Returns true if dev is /dev/mem or /dev/kmem.
320 return (major(dev
) == 3 && minor(dev
) < 2);