Home | History | Annotate | Line # | Download | only in include
dvma3.h revision 1.3
      1  1.3  gwr /*	$NetBSD: dvma3.h,v 1.3 1996/02/20 22:06:28 gwr Exp $	*/
      2  1.1  gwr 
      3  1.1  gwr /*
      4  1.1  gwr  * Copyright (c) 1995 Gordon W. Ross
      5  1.1  gwr  * All rights reserved.
      6  1.1  gwr  *
      7  1.1  gwr  * Redistribution and use in source and binary forms, with or without
      8  1.1  gwr  * modification, are permitted provided that the following conditions
      9  1.1  gwr  * are met:
     10  1.1  gwr  * 1. Redistributions of source code must retain the above copyright
     11  1.1  gwr  *    notice, this list of conditions and the following disclaimer.
     12  1.1  gwr  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  gwr  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  gwr  *    documentation and/or other materials provided with the distribution.
     15  1.1  gwr  * 3. The name of the author may not be used to endorse or promote products
     16  1.1  gwr  *    derived from this software without specific prior written permission.
     17  1.1  gwr  * 4. All advertising materials mentioning features or use of this software
     18  1.1  gwr  *    must display the following acknowledgement:
     19  1.1  gwr  *      This product includes software developed by Gordon W. Ross
     20  1.1  gwr  *
     21  1.1  gwr  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1  gwr  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1  gwr  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1  gwr  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1  gwr  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1  gwr  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1  gwr  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1  gwr  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1  gwr  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1  gwr  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.1  gwr  */
     32  1.1  gwr 
     33  1.1  gwr /*
     34  1.1  gwr  * DVMA (Direct Virtual Memory Access - like DMA)
     35  1.1  gwr  *
     36  1.1  gwr  * The Sun3 MMU is presented to secondary masters using DVMA.
     37  1.1  gwr  * Before such devices can access kernel memory, that memory
     38  1.1  gwr  * must be mapped into the kernel DVMA space.  All DVMA space
     39  1.1  gwr  * is presented as slave-accessible memory for VME and OBIO
     40  1.1  gwr  * devices, though not at the same address seen by the CPU.
     41  1.1  gwr  *
     42  1.1  gwr  * Relevant parts of virtual memory map are:
     43  1.1  gwr  *
     44  1.1  gwr  * 0FE0.0000  monitor map (devices)
     45  1.1  gwr  * 0FF0.0000  DVMA space
     46  1.1  gwr  * 0FFE.0000  monitor RAM seg.
     47  1.1  gwr  * 0FFF.E000  monitor RAM page
     48  1.1  gwr  *
     49  1.1  gwr  * Note that while the DVMA harware makes the last 1MB visible
     50  1.1  gwr  * for secondary masters, the PROM "owns" the last page of it.
     51  1.1  gwr  * Also note that OBIO devices can actually see the last 16MB
     52  1.1  gwr  * of kernel virtual space.  That can be mostly ignored, except
     53  1.1  gwr  * when calculating the alias address for slave access.
     54  1.1  gwr  */
     55  1.1  gwr 
     56  1.1  gwr /*
     57  1.1  gwr  * To convert an address in DVMA space to a slave address,
     58  1.1  gwr  * just use a logical AND with one of the following masks.
     59  1.3  gwr  * To convert back, just logical OR with the base address.
     60  1.1  gwr  */
     61  1.1  gwr #define DVMA_OBIO_SLAVE_BASE 0x0F000000
     62  1.1  gwr #define DVMA_OBIO_SLAVE_MASK 0x00FFffff	/* 16MB */
     63  1.1  gwr 
     64  1.1  gwr #define DVMA_VME_SLAVE_BASE  0x0FF00000	/*  1MB */
     65  1.1  gwr #define DVMA_VME_SLAVE_MASK  0x000Fffff	/*  1MB */
     66  1.1  gwr 
     67  1.1  gwr 
     68  1.3  gwr /* DVMA is the last 1MB, but the PROM gets the last page. */
     69  1.3  gwr #define	DVMA_SPACE_START	0x0FF00000
     70  1.3  gwr #define DVMA_SPACE_END  	0x0FFFE000
     71  1.1  gwr 
     72  1.3  gwr /* Allocate/free actual pages of DVMA space. */
     73  1.1  gwr caddr_t dvma_malloc(size_t bytes);
     74  1.1  gwr void dvma_free(caddr_t addr, size_t bytes);
     75  1.1  gwr 
     76  1.3  gwr /* Remap/unmap kernel memory in DVMA space. */
     77  1.1  gwr caddr_t dvma_mapin(char *kva, int len);
     78  1.1  gwr void dvma_mapout(caddr_t dvma_addr, int len);
     79  1.1  gwr 
     80  1.3  gwr /* Convert a kernel DVMA pointer to a slave address. */
     81  1.1  gwr long dvma_kvtopa(long kva, int bus);
     82  1.1  gwr 
     83