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