]>
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 * 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>
38 #include <sys/ioctl.h>
45 struct bdevsw bdevsw
[] =
48 * For block devices, every other block of 8 slots is
49 * reserved to NeXT. The other slots are available for
50 * the user. This way we can both add new entries without
51 * running into each other. Be sure to fill in NeXT's
52 * 8 reserved slots when you jump over us -- we'll do the
56 /* 0 - 7 are reserved to NeXT */
67 /* 8 - 15 are reserved to the user */
77 /* 16 - 23 are reserved to NeXT */
88 int nblkdev
= sizeof (bdevsw
) / sizeof (bdevsw
[0]);
90 extern struct tty
*km_tty
[];
91 extern int consopen(), consclose(), consread(), conswrite(), consioctl(),
92 consselect(), cons_getc(), cons_putc();
93 extern int kmopen(),kmclose(),kmread(),kmwrite(),kmioctl(),
94 kmgetc(), kmputc(dev_t dev
, char c
);
96 extern int cttyopen(), cttyread(), cttywrite(), cttyioctl(), cttyselect();
98 extern int mmread(),mmwrite(),mmioctl();
99 #define mmselect seltrue
110 extern struct tty
*pt_tty
[];
111 extern int ptsopen(),ptsclose(),ptsread(),ptswrite(),ptsstop(),ptsputc();
112 extern int ptcopen(),ptcclose(),ptcread(),ptcwrite(),ptcselect(),
115 #define ptsopen eno_opcl
116 #define ptsclose eno_opcl
117 #define ptsread eno_rdwrt
118 #define ptswrite eno_rdwrt
119 #define ptsstop nulldev
120 #define ptsputc nulldev
122 #define ptcopen eno_opcl
123 #define ptcclose eno_opcl
124 #define ptcread eno_rdwrt
125 #define ptcwrite eno_rdwrt
126 #define ptcselect eno_select
127 #define ptyioctl eno_ioctl
130 extern int logopen(),logclose(),logread(),logioctl(),logselect();
131 extern int seltrue();
133 struct cdevsw cdevsw
[] =
136 * For character devices, every other block of 16 slots is
137 * reserved to NeXT. The other slots are available for
138 * the user. This way we can both add new entries without
139 * running into each other. Be sure to fill in NeXT's
140 * 16 reserved slots when you jump over us -- we'll do the
144 /* 0 - 15 are reserved to NeXT */
147 consopen
, consclose
, consread
, conswrite
, /* 0*/
148 consioctl
, nulldev
, nulldev
, 0, consselect
,
149 eno_mmap
, eno_strat
, (getc_fcn_t
*)cons_getc
, (putc_fcn_t
*)cons_putc
, D_TTY
153 cttyopen
, nulldev
, cttyread
, cttywrite
, /* 2*/
154 cttyioctl
, nulldev
, nulldev
, 0, cttyselect
,
155 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
158 nulldev
, nulldev
, mmread
, mmwrite
, /* 3*/
159 mmioctl
, nulldev
, nulldev
, 0, (select_fcn_t
*)mmselect
,
160 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_DISK
163 ptsopen
, ptsclose
, ptsread
, ptswrite
, /* 4*/
164 ptyioctl
, ptsstop
, nulldev
, pt_tty
, ttselect
,
165 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
168 ptcopen
, ptcclose
, ptcread
, ptcwrite
, /* 5*/
169 ptyioctl
, nulldev
, nulldev
, 0, ptcselect
,
170 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
173 logopen
, logclose
, logread
, eno_rdwrt
, /* 6*/
174 logioctl
, eno_stop
, nulldev
, 0, logselect
,
175 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
183 kmopen
, kmclose
, kmread
, kmwrite
, /*12*/
184 kmioctl
, nulldev
, nulldev
, km_tty
, ttselect
,
185 eno_mmap
, eno_strat
, kmgetc
, kmputc
, 0
191 /* 16 - 31 are reserved to the user */
209 /* 32 - 47 are reserved to NeXT */
215 /* 37 used to be for nvram */
220 /* 41 used to be for fd */
224 int nchrdev
= sizeof (cdevsw
) / sizeof (cdevsw
[0]);
227 #include <sys/vnode.h> /* for VCHR and VBLK */
229 * return true if a disk
236 dev_t maj
= major(dev
);
246 if (bdevsw
[maj
].d_type
== D_DISK
) {
254 static int chrtoblktab
[] = {
255 /* CHR*/ /* BLK*/ /* CHR*/ /* BLK*/
256 /* 0 */ NODEV
, /* 1 */ NODEV
,
257 /* 2 */ NODEV
, /* 3 */ NODEV
,
258 /* 4 */ NODEV
, /* 5 */ NODEV
,
259 /* 6 */ NODEV
, /* 7 */ NODEV
,
260 /* 8 */ NODEV
, /* 9 */ NODEV
,
261 /* 10 */ NODEV
, /* 11 */ NODEV
,
262 /* 12 */ NODEV
, /* 13 */ NODEV
,
263 /* 14 */ 6, /* 15 */ NODEV
,
264 /* 16 */ NODEV
, /* 17 */ NODEV
,
265 /* 18 */ NODEV
, /* 19 */ NODEV
,
266 /* 20 */ NODEV
, /* 21 */ NODEV
,
267 /* 22 */ NODEV
, /* 23 */ NODEV
,
268 /* 24 */ NODEV
, /* 25 */ NODEV
,
269 /* 26 */ NODEV
, /* 27 */ NODEV
,
270 /* 28 */ NODEV
, /* 29 */ NODEV
,
271 /* 30 */ NODEV
, /* 31 */ NODEV
,
272 /* 32 */ NODEV
, /* 33 */ NODEV
,
273 /* 34 */ NODEV
, /* 35 */ NODEV
,
274 /* 36 */ NODEV
, /* 37 */ NODEV
,
275 /* 38 */ NODEV
, /* 39 */ NODEV
,
276 /* 40 */ NODEV
, /* 41 */ 1,
277 /* 42 */ NODEV
, /* 43 */ NODEV
,
282 * convert chr dev to blk dev
290 if (major(dev
) >= nchrdev
)
292 blkmaj
= chrtoblktab
[major(dev
)];
295 return(makedev(blkmaj
, minor(dev
)));
299 chrtoblk_set(int cdev
, int bdev
)
303 if (bdev
!= NODEV
&& bdev
>= nblkdev
)
305 chrtoblktab
[cdev
] = bdev
;
310 * Returns true if dev is /dev/mem or /dev/kmem.
316 return (major(dev
) == 3 && minor(dev
) < 2);