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