]>
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 <dev/ppc/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 isdisk(dev_t dev
, int type
);
100 int iskmemdev(dev_t dev
);
103 /* XXX No support for linker sets, so must declare here */
104 int cttyopen(dev_t dev
, int flag
, int mode
, struct proc
*p
);
105 int cttyread(dev_t dev
, struct uio
*uio
, int flag
);
106 int cttywrite(dev_t dev
, struct uio
*uio
, int flag
);
107 int cttyioctl(dev_t dev
, u_long cmd
, caddr_t addr
, int flag
, struct proc
*p
);
108 int cttyselect(dev_t dev
, int flag
, void* wql
, struct proc
*p
);
110 /* XXX bsd/dev/ppc/mem.c */
111 int mmread(dev_t dev
, struct uio
*uio
, int flag
);
112 int mmioctl(dev_t dev
, u_long cmd
, caddr_t data
, int flag
, struct proc
*p
);
113 int mmwrite(dev_t dev
, struct uio
*uio
, int flag
);
115 #define mmselect (select_fcn_t *)seltrue
126 extern struct tty
*pt_tty
[];
127 extern d_open_t ptsopen
;
128 extern d_close_t ptsclose
;
129 extern d_read_t ptsread
;
130 extern d_write_t ptswrite
;
131 extern d_stop_t ptsstop
;
132 extern d_putc_t ptsputc
;
133 extern d_open_t ptcopen
;
134 extern d_close_t ptcclose
;
135 extern d_read_t ptcread
;
136 extern d_write_t ptcwrite
;
137 extern d_select_t ptcselect
;
138 extern d_ioctl_t ptyioctl
;
140 #define ptsopen eno_opcl
141 #define ptsclose eno_opcl
142 #define ptsread eno_rdwrt
143 #define ptswrite eno_rdwrt
144 #define ptsstop nulldev
145 #define ptsputc nulldev
147 #define ptcopen eno_opcl
148 #define ptcclose eno_opcl
149 #define ptcread eno_rdwrt
150 #define ptcwrite eno_rdwrt
151 #define ptcselect eno_select
152 #define ptyioctl eno_ioctl
155 extern d_open_t logopen
;
156 extern d_close_t logclose
;
157 extern d_read_t logread
;
158 extern d_ioctl_t logioctl
;
159 extern d_select_t logselect
;
161 struct cdevsw cdevsw
[] =
164 * For character devices, every other block of 16 slots is
165 * reserved to NeXT. The other slots are available for
166 * the user. This way we can both add new entries without
167 * running into each other. Be sure to fill in NeXT's
168 * 16 reserved slots when you jump over us -- we'll do the
172 /* 0 - 15 are reserved to NeXT */
175 consopen
, consclose
, consread
, conswrite
, /* 0*/
176 consioctl
, ((stop_fcn_t
*)&nulldev
),
177 ((reset_fcn_t
*)&nulldev
),
179 eno_mmap
, eno_strat
, cons_getc
, cons_putc
, D_TTY
183 cttyopen
, ((open_close_fcn_t
*)&nulldev
),
184 cttyread
, cttywrite
, /* 2*/
185 cttyioctl
, ((stop_fcn_t
*)&nulldev
),
186 ((reset_fcn_t
*)&nulldev
),
188 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
191 ((open_close_fcn_t
*)&nulldev
),
192 ((open_close_fcn_t
*)&nulldev
),
193 mmread
, mmwrite
, /* 3*/
194 mmioctl
, ((stop_fcn_t
*)&nulldev
),
195 ((reset_fcn_t
*)&nulldev
),
197 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_DISK
200 ptsopen
, ptsclose
, ptsread
, ptswrite
, /* 4*/
201 ptyioctl
, ptsstop
, ((reset_fcn_t
*)&nulldev
),
203 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
206 ptcopen
, ptcclose
, ptcread
, ptcwrite
, /* 5*/
207 ptyioctl
, ((stop_fcn_t
*)&nulldev
),
208 ((reset_fcn_t
*)&nulldev
),
210 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, D_TTY
213 logopen
, logclose
, logread
, eno_rdwrt
, /* 6*/
214 logioctl
, eno_stop
, ((reset_fcn_t
*)&nulldev
),
216 eno_mmap
, eno_strat
, eno_getc
, eno_putc
, 0
224 kmopen
, kmclose
, kmread
, kmwrite
, /*12*/
225 kmioctl
, ((stop_fcn_t
*)&nulldev
),
226 ((reset_fcn_t
*)&nulldev
),
228 eno_mmap
, eno_strat
, kmgetc
, kmputc
, 0
234 /* 16 - 31 are reserved to the user */
252 /* 32 - 47 are reserved to NeXT */
258 /* 37 used to be for nvram */
263 /* 41 used to be for fd */
267 int nchrdev
= sizeof (cdevsw
) / sizeof (cdevsw
[0]);
270 #include <sys/vnode.h> /* for VCHR and VBLK */
272 * return true if a disk
275 isdisk(dev_t dev
, int type
)
277 dev_t maj
= major(dev
);
287 if (bdevsw
[maj
].d_type
== D_DISK
) {
295 static int chrtoblktab
[] = {
296 /* CHR*/ /* BLK*/ /* CHR*/ /* BLK*/
297 /* 0 */ NODEV
, /* 1 */ NODEV
,
298 /* 2 */ NODEV
, /* 3 */ NODEV
,
299 /* 4 */ NODEV
, /* 5 */ NODEV
,
300 /* 6 */ NODEV
, /* 7 */ NODEV
,
301 /* 8 */ NODEV
, /* 9 */ NODEV
,
302 /* 10 */ NODEV
, /* 11 */ NODEV
,
303 /* 12 */ NODEV
, /* 13 */ NODEV
,
304 /* 14 */ 6, /* 15 */ NODEV
,
305 /* 16 */ NODEV
, /* 17 */ NODEV
,
306 /* 18 */ NODEV
, /* 19 */ NODEV
,
307 /* 20 */ NODEV
, /* 21 */ NODEV
,
308 /* 22 */ NODEV
, /* 23 */ NODEV
,
309 /* 24 */ NODEV
, /* 25 */ NODEV
,
310 /* 26 */ NODEV
, /* 27 */ NODEV
,
311 /* 28 */ NODEV
, /* 29 */ NODEV
,
312 /* 30 */ NODEV
, /* 31 */ NODEV
,
313 /* 32 */ NODEV
, /* 33 */ NODEV
,
314 /* 34 */ NODEV
, /* 35 */ NODEV
,
315 /* 36 */ NODEV
, /* 37 */ NODEV
,
316 /* 38 */ NODEV
, /* 39 */ NODEV
,
317 /* 40 */ NODEV
, /* 41 */ 1,
318 /* 42 */ NODEV
, /* 43 */ NODEV
,
323 * convert chr dev to blk dev
330 if (major(dev
) >= nchrdev
)
332 blkmaj
= chrtoblktab
[major(dev
)];
335 return(makedev(blkmaj
, minor(dev
)));
339 chrtoblk_set(int cdev
, int bdev
)
343 if (bdev
!= NODEV
&& bdev
>= nblkdev
)
345 chrtoblktab
[cdev
] = bdev
;
350 * Returns true if dev is /dev/mem or /dev/kmem.
356 return (major(dev
) == 3 && minor(dev
) < 2);