]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/ppc/conf.c
ba13fc3ee874bfe3bbe8b1da8832b9530d3726f2
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
111 extern struct tty
*pt_tty
[];
112 extern int ptsopen(),ptsclose(),ptsread(),ptswrite(),ptsstop(),ptsputc();
113 extern int ptcopen(),ptcclose(),ptcread(),ptcwrite(),ptcselect(),
116 #define ptsopen eno_opcl
117 #define ptsclose eno_opcl
118 #define ptsread eno_rdwrt
119 #define ptswrite eno_rdwrt
120 #define ptsstop nulldev
121 #define ptsputc nulldev
123 #define ptcopen eno_opcl
124 #define ptcclose eno_opcl
125 #define ptcread eno_rdwrt
126 #define ptcwrite eno_rdwrt
127 #define ptcselect eno_select
128 #define ptyioctl eno_ioctl
131 extern int logopen(),logclose(),logread(),logioctl(),logselect();
132 extern int seltrue();
134 struct cdevsw cdevsw
[] =
137 * For character devices, every other block of 16 slots is
138 * reserved to NeXT. The other slots are available for
139 * the user. This way we can both add new entries without
140 * running into each other. Be sure to fill in NeXT's
141 * 16 reserved slots when you jump over us -- we'll do the
145 /* 0 - 15 are reserved to NeXT */
148 consopen
, consclose
, consread
, conswrite
, /* 0*/
149 consioctl
, nulldev
, nulldev
, 0, consselect
,
150 eno_mmap
, eno_strat
, cons_getc
, cons_putc
, D_TTY
154 cttyopen
, nulldev
, cttyread
, cttywrite
, /* 2*/
155 cttyioctl
, nulldev
, nulldev
, 0, cttyselect
,
156 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
159 nulldev
, nulldev
, mmread
, mmwrite
, /* 3*/
160 eno_ioctl
, nulldev
, nulldev
, 0, mmselect
,
161 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
164 ptsopen
, ptsclose
, ptsread
, ptswrite
, /* 4*/
165 ptyioctl
, ptsstop
, nulldev
, pt_tty
, ttselect
,
166 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
169 ptcopen
, ptcclose
, ptcread
, ptcwrite
, /* 5*/
170 ptyioctl
, nulldev
, nulldev
, 0, ptcselect
,
171 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
174 logopen
, logclose
, logread
, eno_rdwrt
, /* 6*/
175 logioctl
, eno_stop
, nulldev
, 0, logselect
,
176 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
184 kmopen
, kmclose
, kmread
, kmwrite
, /*12*/
185 kmioctl
, nulldev
, nulldev
, km_tty
, ttselect
,
186 eno_mmap
, eno_strat
, kmgetc
, kmputc
, 0
192 /* 16 - 31 are reserved to the user */
210 /* 32 - 47 are reserved to NeXT */
216 /* 37 used to be for nvram */
221 /* 41 used to be for fd */
225 int nchrdev
= sizeof (cdevsw
) / sizeof (cdevsw
[0]);
228 #include <sys/vnode.h> /* for VCHR and VBLK */
230 * return true if a disk
237 dev_t maj
= major(dev
);
247 if (bdevsw
[maj
].d_type
== D_DISK
) {
255 static int chrtoblktab
[] = {
256 /* CHR*/ /* BLK*/ /* CHR*/ /* BLK*/
257 /* 0 */ NODEV
, /* 1 */ NODEV
,
258 /* 2 */ NODEV
, /* 3 */ NODEV
,
259 /* 4 */ NODEV
, /* 5 */ NODEV
,
260 /* 6 */ NODEV
, /* 7 */ NODEV
,
261 /* 8 */ NODEV
, /* 9 */ NODEV
,
262 /* 10 */ NODEV
, /* 11 */ NODEV
,
263 /* 12 */ NODEV
, /* 13 */ NODEV
,
264 /* 14 */ 6, /* 15 */ NODEV
,
265 /* 16 */ NODEV
, /* 17 */ NODEV
,
266 /* 18 */ NODEV
, /* 19 */ NODEV
,
267 /* 20 */ NODEV
, /* 21 */ NODEV
,
268 /* 22 */ NODEV
, /* 23 */ NODEV
,
269 /* 24 */ NODEV
, /* 25 */ NODEV
,
270 /* 26 */ NODEV
, /* 27 */ NODEV
,
271 /* 28 */ NODEV
, /* 29 */ NODEV
,
272 /* 30 */ NODEV
, /* 31 */ NODEV
,
273 /* 32 */ NODEV
, /* 33 */ NODEV
,
274 /* 34 */ NODEV
, /* 35 */ NODEV
,
275 /* 36 */ NODEV
, /* 37 */ NODEV
,
276 /* 38 */ NODEV
, /* 39 */ NODEV
,
277 /* 40 */ NODEV
, /* 41 */ 1,
278 /* 42 */ NODEV
, /* 43 */ NODEV
,
283 * convert chr dev to blk dev
291 if (major(dev
) >= nchrdev
)
293 blkmaj
= chrtoblktab
[major(dev
)];
296 return(makedev(blkmaj
, minor(dev
)));
300 chrtoblk_set(int cdev
, int bdev
)
304 if (bdev
!= NODEV
&& bdev
>= nblkdev
)
306 chrtoblktab
[cdev
] = bdev
;
311 * Returns true if dev is /dev/mem or /dev/kmem.
317 return (major(dev
) == 3 && minor(dev
) < 2);