]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/ppc/conf.c
f1ee4a1292acc366aa1e01798eff0dd32fb598c7
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 * Copyright (c) 1997 by Apple Computer, Inc., all rights reserved
32 * Copyright (c) 1993 NeXT Computer, Inc.
34 * UNIX Device switch tables.
38 * 30 July 1997 Umesh Vaishampayan (umeshv@apple.com)
39 * enabled file descriptor pseudo-device.
40 * 18 June 1993 ? at NeXT
41 * Cleaned up a lot of stuff in this file.
44 #include <sys/param.h>
45 #include <sys/systm.h>
46 #include <sys/ioctl.h>
53 struct bdevsw bdevsw
[] =
56 * For block devices, every other block of 8 slots is
57 * reserved to NeXT. The other slots are available for
58 * the user. This way we can both add new entries without
59 * running into each other. Be sure to fill in NeXT's
60 * 8 reserved slots when you jump over us -- we'll do the
64 /* 0 - 7 are reserved to NeXT */
75 /* 8 - 15 are reserved to the user */
85 /* 16 - 23 are reserved to NeXT */
96 int nblkdev
= sizeof (bdevsw
) / sizeof (bdevsw
[0]);
98 extern struct tty
*km_tty
[];
99 extern int consopen(), consclose(), consread(), conswrite(), consioctl(),
100 consselect(), cons_getc(), cons_putc();
101 extern int kmopen(),kmclose(),kmread(),kmwrite(),kmioctl(),
102 kmgetc(), kmputc(dev_t dev
, char c
);
104 extern int cttyopen(), cttyread(), cttywrite(), cttyioctl(), cttyselect();
106 extern int mmread(),mmwrite(),mmioctl();
107 #define mmselect seltrue
118 extern struct tty
*pt_tty
[];
119 extern int ptsopen(),ptsclose(),ptsread(),ptswrite(),ptsstop(),ptsputc();
120 extern int ptcopen(),ptcclose(),ptcread(),ptcwrite(),ptcselect(),
123 #define ptsopen eno_opcl
124 #define ptsclose eno_opcl
125 #define ptsread eno_rdwrt
126 #define ptswrite eno_rdwrt
127 #define ptsstop nulldev
128 #define ptsputc nulldev
130 #define ptcopen eno_opcl
131 #define ptcclose eno_opcl
132 #define ptcread eno_rdwrt
133 #define ptcwrite eno_rdwrt
134 #define ptcselect eno_select
135 #define ptyioctl eno_ioctl
138 extern int logopen(),logclose(),logread(),logioctl(),logselect();
139 extern int seltrue();
141 struct cdevsw cdevsw
[] =
144 * For character devices, every other block of 16 slots is
145 * reserved to NeXT. The other slots are available for
146 * the user. This way we can both add new entries without
147 * running into each other. Be sure to fill in NeXT's
148 * 16 reserved slots when you jump over us -- we'll do the
152 /* 0 - 15 are reserved to NeXT */
155 consopen
, consclose
, consread
, conswrite
, /* 0*/
156 consioctl
, nulldev
, nulldev
, 0, consselect
,
157 eno_mmap
, eno_strat
, (getc_fcn_t
*)cons_getc
, (putc_fcn_t
*)cons_putc
, D_TTY
161 cttyopen
, nulldev
, cttyread
, cttywrite
, /* 2*/
162 cttyioctl
, nulldev
, nulldev
, 0, cttyselect
,
163 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
166 nulldev
, nulldev
, mmread
, mmwrite
, /* 3*/
167 mmioctl
, nulldev
, nulldev
, 0, (select_fcn_t
*)mmselect
,
168 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_DISK
171 ptsopen
, ptsclose
, ptsread
, ptswrite
, /* 4*/
172 ptyioctl
, ptsstop
, nulldev
, pt_tty
, ttselect
,
173 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
176 ptcopen
, ptcclose
, ptcread
, ptcwrite
, /* 5*/
177 ptyioctl
, nulldev
, nulldev
, 0, ptcselect
,
178 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
181 logopen
, logclose
, logread
, eno_rdwrt
, /* 6*/
182 logioctl
, eno_stop
, nulldev
, 0, logselect
,
183 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
191 kmopen
, kmclose
, kmread
, kmwrite
, /*12*/
192 kmioctl
, nulldev
, nulldev
, km_tty
, ttselect
,
193 eno_mmap
, eno_strat
, kmgetc
, kmputc
, 0
199 /* 16 - 31 are reserved to the user */
217 /* 32 - 47 are reserved to NeXT */
223 /* 37 used to be for nvram */
228 /* 41 used to be for fd */
232 int nchrdev
= sizeof (cdevsw
) / sizeof (cdevsw
[0]);
235 #include <sys/vnode.h> /* for VCHR and VBLK */
237 * return true if a disk
244 dev_t maj
= major(dev
);
254 if (bdevsw
[maj
].d_type
== D_DISK
) {
262 static int chrtoblktab
[] = {
263 /* CHR*/ /* BLK*/ /* CHR*/ /* BLK*/
264 /* 0 */ NODEV
, /* 1 */ NODEV
,
265 /* 2 */ NODEV
, /* 3 */ NODEV
,
266 /* 4 */ NODEV
, /* 5 */ NODEV
,
267 /* 6 */ NODEV
, /* 7 */ NODEV
,
268 /* 8 */ NODEV
, /* 9 */ NODEV
,
269 /* 10 */ NODEV
, /* 11 */ NODEV
,
270 /* 12 */ NODEV
, /* 13 */ NODEV
,
271 /* 14 */ 6, /* 15 */ NODEV
,
272 /* 16 */ NODEV
, /* 17 */ NODEV
,
273 /* 18 */ NODEV
, /* 19 */ NODEV
,
274 /* 20 */ NODEV
, /* 21 */ NODEV
,
275 /* 22 */ NODEV
, /* 23 */ NODEV
,
276 /* 24 */ NODEV
, /* 25 */ NODEV
,
277 /* 26 */ NODEV
, /* 27 */ NODEV
,
278 /* 28 */ NODEV
, /* 29 */ NODEV
,
279 /* 30 */ NODEV
, /* 31 */ NODEV
,
280 /* 32 */ NODEV
, /* 33 */ NODEV
,
281 /* 34 */ NODEV
, /* 35 */ NODEV
,
282 /* 36 */ NODEV
, /* 37 */ NODEV
,
283 /* 38 */ NODEV
, /* 39 */ NODEV
,
284 /* 40 */ NODEV
, /* 41 */ 1,
285 /* 42 */ NODEV
, /* 43 */ NODEV
,
290 * convert chr dev to blk dev
298 if (major(dev
) >= nchrdev
)
300 blkmaj
= chrtoblktab
[major(dev
)];
303 return(makedev(blkmaj
, minor(dev
)));
307 chrtoblk_set(int cdev
, int bdev
)
311 if (bdev
!= NODEV
&& bdev
>= nblkdev
)
313 chrtoblktab
[cdev
] = bdev
;
318 * Returns true if dev is /dev/mem or /dev/kmem.
324 return (major(dev
) == 3 && minor(dev
) < 2);