mm_md.c revision 1.3 1 1.3 tsutsui /* $NetBSD: mm_md.c,v 1.3 2011/06/14 15:51:35 tsutsui Exp $ */
2 1.2 rmind
3 1.2 rmind /*
4 1.2 rmind * Copyright (c) 1982, 1986, 1990, 1993
5 1.2 rmind * The Regents of the University of California. All rights reserved.
6 1.2 rmind *
7 1.2 rmind * This code is derived from software contributed to Berkeley by
8 1.2 rmind * the Systems Programming Group of the University of Utah Computer
9 1.2 rmind * Science Department.
10 1.2 rmind *
11 1.2 rmind * Redistribution and use in source and binary forms, with or without
12 1.2 rmind * modification, are permitted provided that the following conditions
13 1.2 rmind * are met:
14 1.2 rmind * 1. Redistributions of source code must retain the above copyright
15 1.2 rmind * notice, this list of conditions and the following disclaimer.
16 1.2 rmind * 2. Redistributions in binary form must reproduce the above copyright
17 1.2 rmind * notice, this list of conditions and the following disclaimer in the
18 1.2 rmind * documentation and/or other materials provided with the distribution.
19 1.2 rmind * 3. Neither the name of the University nor the names of its contributors
20 1.2 rmind * may be used to endorse or promote products derived from this software
21 1.2 rmind * without specific prior written permission.
22 1.2 rmind *
23 1.2 rmind * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.2 rmind * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.2 rmind * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.2 rmind * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.2 rmind * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.2 rmind * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.2 rmind * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.2 rmind * SUCH DAMAGE.
34 1.2 rmind *
35 1.2 rmind * from: @(#)mem.c 8.3 (Berkeley) 1/12/94
36 1.2 rmind */
37 1.2 rmind
38 1.2 rmind /*
39 1.2 rmind * Copyright (c) 1994, 1995 Gordon W. Ross
40 1.2 rmind * Copyright (c) 1993 Adam Glass
41 1.2 rmind * Copyright (c) 1988 University of Utah.
42 1.2 rmind *
43 1.2 rmind * This code is derived from software contributed to Berkeley by
44 1.2 rmind * the Systems Programming Group of the University of Utah Computer
45 1.2 rmind * Science Department.
46 1.2 rmind *
47 1.2 rmind * Redistribution and use in source and binary forms, with or without
48 1.2 rmind * modification, are permitted provided that the following conditions
49 1.2 rmind * are met:
50 1.2 rmind * 1. Redistributions of source code must retain the above copyright
51 1.2 rmind * notice, this list of conditions and the following disclaimer.
52 1.2 rmind * 2. Redistributions in binary form must reproduce the above copyright
53 1.2 rmind * notice, this list of conditions and the following disclaimer in the
54 1.2 rmind * documentation and/or other materials provided with the distribution.
55 1.2 rmind * 3. All advertising materials mentioning features or use of this software
56 1.2 rmind * must display the following acknowledgement:
57 1.2 rmind * This product includes software developed by the University of
58 1.2 rmind * California, Berkeley and its contributors.
59 1.2 rmind * 4. Neither the name of the University nor the names of its contributors
60 1.2 rmind * may be used to endorse or promote products derived from this software
61 1.2 rmind * without specific prior written permission.
62 1.2 rmind *
63 1.2 rmind * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
64 1.2 rmind * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
65 1.2 rmind * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
66 1.2 rmind * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
67 1.2 rmind * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
68 1.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
69 1.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
70 1.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
71 1.2 rmind * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
72 1.2 rmind * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
73 1.2 rmind * SUCH DAMAGE.
74 1.2 rmind *
75 1.2 rmind * from: @(#)mem.c 8.3 (Berkeley) 1/12/94
76 1.2 rmind */
77 1.2 rmind
78 1.2 rmind #include <sys/cdefs.h>
79 1.3 tsutsui __KERNEL_RCSID(0, "$NetBSD: mm_md.c,v 1.3 2011/06/14 15:51:35 tsutsui Exp $");
80 1.2 rmind
81 1.2 rmind #include <sys/param.h>
82 1.2 rmind #include <sys/errno.h>
83 1.2 rmind #include <uvm/uvm_extern.h>
84 1.2 rmind #include <machine/leds.h>
85 1.2 rmind #include <machine/pmap.h>
86 1.2 rmind #include <dev/mm.h>
87 1.2 rmind
88 1.2 rmind #define DEV_VME16D16 5 /* minor device 5 is /dev/vme16d16 */
89 1.2 rmind #define DEV_VME24D16 6 /* minor device 6 is /dev/vme24d16 */
90 1.2 rmind #define DEV_EEPROM 11 /* minor device 11 is eeprom */
91 1.2 rmind #define DEV_LEDS 13 /* minor device 13 is leds */
92 1.2 rmind
93 1.2 rmind int
94 1.2 rmind mm_md_readwrite(dev_t dev, struct uio *uio)
95 1.2 rmind {
96 1.2 rmind
97 1.2 rmind switch (minor(dev)) {
98 1.2 rmind case DEV_LEDS:
99 1.2 rmind return leds_uio(uio);
100 1.2 rmind default:
101 1.2 rmind return ENXIO;
102 1.2 rmind }
103 1.2 rmind }
104 1.2 rmind
105 1.2 rmind paddr_t
106 1.2 rmind mm_md_mmap(dev_t dev, off_t off, int prot)
107 1.2 rmind {
108 1.2 rmind
109 1.2 rmind switch (minor(dev)) {
110 1.2 rmind case DEV_VME16D16:
111 1.2 rmind if (off & 0xffff0000)
112 1.2 rmind return -1;
113 1.2 rmind off |= 0xff0000;
114 1.2 rmind /* fall through */
115 1.2 rmind case DEV_VME24D16:
116 1.2 rmind if (off & 0xff000000)
117 1.2 rmind return -1;
118 1.2 rmind return (off | (off & 0x800000 ? PMAP_VME8: PMAP_VME0));
119 1.2 rmind default:
120 1.2 rmind return (-1);
121 1.2 rmind }
122 1.2 rmind }
123