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