]>
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_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>
47 #include <machine/cons.h>
50 struct bdevsw bdevsw
[] =
53 * For block devices, every other block of 8 slots is
54 * reserved to NeXT. The other slots are available for
55 * the user. This way we can both add new entries without
56 * running into each other. Be sure to fill in NeXT's
57 * 8 reserved slots when you jump over us -- we'll do the
61 /* 0 - 7 are reserved to NeXT */
72 /* 8 - 15 are reserved to the user */
82 /* 16 - 23 are reserved to NeXT */
93 int nblkdev
= sizeof (bdevsw
) / sizeof (bdevsw
[0]);
95 extern struct tty
*km_tty
[];
97 dev_t
chrtoblk(dev_t dev
);
98 int chrtoblk_set(int cdev
, int bdev
);
99 int iskmemdev(dev_t dev
);
102 /* XXX No support for linker sets, so must declare here */
103 int cttyopen(dev_t dev
, int flag
, int mode
, struct proc
*p
);
104 int cttyread(dev_t dev
, struct uio
*uio
, int flag
);
105 int cttywrite(dev_t dev
, struct uio
*uio
, int flag
);
106 int cttyioctl(dev_t dev
, u_long cmd
, caddr_t addr
, int flag
, struct proc
*p
);
107 int cttyselect(dev_t dev
, int flag
, void* wql
, struct proc
*p
);
109 /* XXX bsd/dev/ppc/mem.c */
110 int mmread(dev_t dev
, struct uio
*uio
, int flag
);
111 int mmioctl(dev_t dev
, u_long cmd
, caddr_t data
, int flag
, struct proc
*p
);
112 int mmwrite(dev_t dev
, struct uio
*uio
, int flag
);
114 #define mmselect (select_fcn_t *)seltrue
125 extern struct tty
*pt_tty
[];
126 extern d_open_t ptsopen
;
127 extern d_close_t ptsclose
;
128 extern d_read_t ptsread
;
129 extern d_write_t ptswrite
;
130 extern d_stop_t ptsstop
;
131 extern d_open_t ptcopen
;
132 extern d_close_t ptcclose
;
133 extern d_read_t ptcread
;
134 extern d_write_t ptcwrite
;
135 extern d_select_t ptcselect
;
136 extern d_ioctl_t ptyioctl
;
138 #define ptsopen eno_opcl
139 #define ptsclose eno_opcl
140 #define ptsread eno_rdwrt
141 #define ptswrite eno_rdwrt
142 #define ptsstop nulldev
144 #define ptcopen eno_opcl
145 #define ptcclose eno_opcl
146 #define ptcread eno_rdwrt
147 #define ptcwrite eno_rdwrt
148 #define ptcselect eno_select
149 #define ptyioctl eno_ioctl
152 extern d_open_t logopen
;
153 extern d_close_t logclose
;
154 extern d_read_t logread
;
155 extern d_ioctl_t logioctl
;
156 extern d_select_t logselect
;
158 struct cdevsw cdevsw
[] =
161 * For character devices, every other block of 16 slots is
162 * reserved to NeXT. The other slots are available for
163 * the user. This way we can both add new entries without
164 * running into each other. Be sure to fill in NeXT's
165 * 16 reserved slots when you jump over us -- we'll do the
169 /* 0 - 15 are reserved to NeXT */
172 consopen
, consclose
, consread
, conswrite
, /* 0*/
173 consioctl
, ((stop_fcn_t
*)&nulldev
),
174 ((reset_fcn_t
*)&nulldev
),
176 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
180 cttyopen
, ((open_close_fcn_t
*)&nulldev
),
181 cttyread
, cttywrite
, /* 2*/
182 cttyioctl
, ((stop_fcn_t
*)&nulldev
),
183 ((reset_fcn_t
*)&nulldev
),
185 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
188 ((open_close_fcn_t
*)&nulldev
),
189 ((open_close_fcn_t
*)&nulldev
),
190 mmread
, mmwrite
, /* 3*/
191 mmioctl
, ((stop_fcn_t
*)&nulldev
),
192 ((reset_fcn_t
*)&nulldev
),
194 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_DISK
197 ptsopen
, ptsclose
, ptsread
, ptswrite
, /* 4*/
198 ptyioctl
, ptsstop
, ((reset_fcn_t
*)&nulldev
),
200 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
203 ptcopen
, ptcclose
, ptcread
, ptcwrite
, /* 5*/
204 ptyioctl
, ((stop_fcn_t
*)&nulldev
),
205 ((reset_fcn_t
*)&nulldev
),
207 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
210 logopen
, logclose
, logread
, eno_rdwrt
, /* 6*/
211 logioctl
, eno_stop
, ((reset_fcn_t
*)&nulldev
),
213 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
221 kmopen
, kmclose
, kmread
, kmwrite
, /*12*/
222 kmioctl
, ((stop_fcn_t
*)&nulldev
),
223 ((reset_fcn_t
*)&nulldev
),
225 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
231 /* 16 - 31 are reserved to the user */
249 /* 32 - 47 are reserved to NeXT */
255 /* 37 used to be for nvram */
260 /* 41 used to be for fd */
264 int nchrdev
= sizeof (cdevsw
) / sizeof (cdevsw
[0]);
267 #include <sys/vnode.h> /* for VCHR and VBLK */
269 * return true if a disk
272 isdisk(dev_t dev
, int type
)
274 dev_t maj
= major(dev
);
284 if (bdevsw
[maj
].d_type
== D_DISK
) {
292 static int chrtoblktab
[] = {
293 /* CHR*/ /* BLK*/ /* CHR*/ /* BLK*/
294 /* 0 */ NODEV
, /* 1 */ NODEV
,
295 /* 2 */ NODEV
, /* 3 */ NODEV
,
296 /* 4 */ NODEV
, /* 5 */ NODEV
,
297 /* 6 */ NODEV
, /* 7 */ NODEV
,
298 /* 8 */ NODEV
, /* 9 */ NODEV
,
299 /* 10 */ NODEV
, /* 11 */ NODEV
,
300 /* 12 */ NODEV
, /* 13 */ NODEV
,
301 /* 14 */ 6, /* 15 */ NODEV
,
302 /* 16 */ NODEV
, /* 17 */ NODEV
,
303 /* 18 */ NODEV
, /* 19 */ NODEV
,
304 /* 20 */ NODEV
, /* 21 */ NODEV
,
305 /* 22 */ NODEV
, /* 23 */ NODEV
,
306 /* 24 */ NODEV
, /* 25 */ NODEV
,
307 /* 26 */ NODEV
, /* 27 */ NODEV
,
308 /* 28 */ NODEV
, /* 29 */ NODEV
,
309 /* 30 */ NODEV
, /* 31 */ NODEV
,
310 /* 32 */ NODEV
, /* 33 */ NODEV
,
311 /* 34 */ NODEV
, /* 35 */ NODEV
,
312 /* 36 */ NODEV
, /* 37 */ NODEV
,
313 /* 38 */ NODEV
, /* 39 */ NODEV
,
314 /* 40 */ NODEV
, /* 41 */ 1,
315 /* 42 */ NODEV
, /* 43 */ NODEV
,
320 * convert chr dev to blk dev
327 if (major(dev
) >= nchrdev
)
329 blkmaj
= chrtoblktab
[major(dev
)];
332 return(makedev(blkmaj
, minor(dev
)));
336 chrtoblk_set(int cdev
, int bdev
)
340 if (bdev
!= NODEV
&& bdev
>= nblkdev
)
342 chrtoblktab
[cdev
] = bdev
;
347 * Returns true if dev is /dev/mem or /dev/kmem.
353 return (major(dev
) == 3 && minor(dev
) < 2);