]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/ppc/conf.c
399325e9baf972012ba6ee337c5ffb413bc7ce40
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1997 by Apple Computer, Inc., all rights reserved
30 * Copyright (c) 1993 NeXT Computer, Inc.
32 * UNIX Device switch tables.
36 * 30 July 1997 Umesh Vaishampayan (umeshv@apple.com)
37 * enabled file descriptor pseudo-device.
38 * 18 June 1993 ? at NeXT
39 * Cleaned up a lot of stuff in this file.
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/ioctl.h>
51 struct bdevsw bdevsw
[] =
54 * For block devices, every other block of 8 slots is
55 * reserved to NeXT. The other slots are available for
56 * the user. This way we can both add new entries without
57 * running into each other. Be sure to fill in NeXT's
58 * 8 reserved slots when you jump over us -- we'll do the
62 /* 0 - 7 are reserved to NeXT */
73 /* 8 - 15 are reserved to the user */
83 /* 16 - 23 are reserved to NeXT */
94 int nblkdev
= sizeof (bdevsw
) / sizeof (bdevsw
[0]);
96 extern struct tty
*km_tty
[];
97 extern int consopen(), consclose(), consread(), conswrite(), consioctl(),
98 consselect(), cons_getc(), cons_putc();
99 extern int kmopen(),kmclose(),kmread(),kmwrite(),kmioctl(),
100 kmgetc(), kmputc(dev_t dev
, char c
);
102 extern int cttyopen(), cttyread(), cttywrite(), cttyioctl(), cttyselect();
104 extern int mmread(),mmwrite(),mmioctl();
105 #define mmselect seltrue
116 extern struct tty
*pt_tty
[];
117 extern int ptsopen(),ptsclose(),ptsread(),ptswrite(),ptsstop(),ptsputc();
118 extern int ptcopen(),ptcclose(),ptcread(),ptcwrite(),ptcselect(),
121 #define ptsopen eno_opcl
122 #define ptsclose eno_opcl
123 #define ptsread eno_rdwrt
124 #define ptswrite eno_rdwrt
125 #define ptsstop nulldev
126 #define ptsputc nulldev
128 #define ptcopen eno_opcl
129 #define ptcclose eno_opcl
130 #define ptcread eno_rdwrt
131 #define ptcwrite eno_rdwrt
132 #define ptcselect eno_select
133 #define ptyioctl eno_ioctl
136 extern int logopen(),logclose(),logread(),logioctl(),logselect();
137 extern int seltrue();
139 struct cdevsw cdevsw
[] =
142 * For character devices, every other block of 16 slots is
143 * reserved to NeXT. The other slots are available for
144 * the user. This way we can both add new entries without
145 * running into each other. Be sure to fill in NeXT's
146 * 16 reserved slots when you jump over us -- we'll do the
150 /* 0 - 15 are reserved to NeXT */
153 consopen
, consclose
, consread
, conswrite
, /* 0*/
154 consioctl
, nulldev
, nulldev
, 0, consselect
,
155 eno_mmap
, eno_strat
, (getc_fcn_t
*)cons_getc
, (putc_fcn_t
*)cons_putc
, D_TTY
159 cttyopen
, nulldev
, cttyread
, cttywrite
, /* 2*/
160 cttyioctl
, nulldev
, nulldev
, 0, cttyselect
,
161 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
164 nulldev
, nulldev
, mmread
, mmwrite
, /* 3*/
165 mmioctl
, nulldev
, nulldev
, 0, (select_fcn_t
*)mmselect
,
166 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_DISK
169 ptsopen
, ptsclose
, ptsread
, ptswrite
, /* 4*/
170 ptyioctl
, ptsstop
, nulldev
, pt_tty
, ttselect
,
171 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
174 ptcopen
, ptcclose
, ptcread
, ptcwrite
, /* 5*/
175 ptyioctl
, nulldev
, nulldev
, 0, ptcselect
,
176 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
179 logopen
, logclose
, logread
, eno_rdwrt
, /* 6*/
180 logioctl
, eno_stop
, nulldev
, 0, logselect
,
181 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
189 kmopen
, kmclose
, kmread
, kmwrite
, /*12*/
190 kmioctl
, nulldev
, nulldev
, km_tty
, ttselect
,
191 eno_mmap
, eno_strat
, kmgetc
, kmputc
, 0
197 /* 16 - 31 are reserved to the user */
215 /* 32 - 47 are reserved to NeXT */
221 /* 37 used to be for nvram */
226 /* 41 used to be for fd */
230 int nchrdev
= sizeof (cdevsw
) / sizeof (cdevsw
[0]);
233 #include <sys/vnode.h> /* for VCHR and VBLK */
235 * return true if a disk
242 dev_t maj
= major(dev
);
252 if (bdevsw
[maj
].d_type
== D_DISK
) {
260 static int chrtoblktab
[] = {
261 /* CHR*/ /* BLK*/ /* CHR*/ /* BLK*/
262 /* 0 */ NODEV
, /* 1 */ NODEV
,
263 /* 2 */ NODEV
, /* 3 */ NODEV
,
264 /* 4 */ NODEV
, /* 5 */ NODEV
,
265 /* 6 */ NODEV
, /* 7 */ NODEV
,
266 /* 8 */ NODEV
, /* 9 */ NODEV
,
267 /* 10 */ NODEV
, /* 11 */ NODEV
,
268 /* 12 */ NODEV
, /* 13 */ NODEV
,
269 /* 14 */ 6, /* 15 */ NODEV
,
270 /* 16 */ NODEV
, /* 17 */ NODEV
,
271 /* 18 */ NODEV
, /* 19 */ NODEV
,
272 /* 20 */ NODEV
, /* 21 */ NODEV
,
273 /* 22 */ NODEV
, /* 23 */ NODEV
,
274 /* 24 */ NODEV
, /* 25 */ NODEV
,
275 /* 26 */ NODEV
, /* 27 */ NODEV
,
276 /* 28 */ NODEV
, /* 29 */ NODEV
,
277 /* 30 */ NODEV
, /* 31 */ NODEV
,
278 /* 32 */ NODEV
, /* 33 */ NODEV
,
279 /* 34 */ NODEV
, /* 35 */ NODEV
,
280 /* 36 */ NODEV
, /* 37 */ NODEV
,
281 /* 38 */ NODEV
, /* 39 */ NODEV
,
282 /* 40 */ NODEV
, /* 41 */ 1,
283 /* 42 */ NODEV
, /* 43 */ NODEV
,
288 * convert chr dev to blk dev
296 if (major(dev
) >= nchrdev
)
298 blkmaj
= chrtoblktab
[major(dev
)];
301 return(makedev(blkmaj
, minor(dev
)));
305 chrtoblk_set(int cdev
, int bdev
)
309 if (bdev
!= NODEV
&& bdev
>= nblkdev
)
311 chrtoblktab
[cdev
] = bdev
;
316 * Returns true if dev is /dev/mem or /dev/kmem.
322 return (major(dev
) == 3 && minor(dev
) < 2);