dvma3.h revision 1.1 1 /* $NetBSD: dvma3.h,v 1.1 1995/09/26 04:02:08 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 * This range could be managed as whole MMU segments.
58 * The last segment is pre-allocated (see below)
59 */
60 #define DVMA_SEGMAP_BASE 0x0FF00000
61 #define DVMA_SEGMAP_SIZE 0x000E0000
62 #define DVMA_SEGMAP_END (DVMA_SEGMAP_BASE+DVMA_SEGMAP_SIZE)
63
64 /*
65 * This range is managed as individual pages.
66 * The last page is owned by the PROM monitor.
67 */
68 #define DVMA_PAGEMAP_BASE 0x0FFE0000
69 #define DVMA_PAGEMAP_SIZE 0x0001E000
70 #define DVMA_PAGEMAP_END (DVMA_PAGEMAP_BASE+DVMA_PAGEMAP_SIZE)
71
72 /*
73 * To convert an address in DVMA space to a slave address,
74 * just use a logical AND with one of the following masks.
75 * To convert back, use logical OR with DVMA_SEGMAP_BASE.
76 */
77 #define DVMA_OBIO_SLAVE_BASE 0x0F000000
78 #define DVMA_OBIO_SLAVE_MASK 0x00FFffff /* 16MB */
79
80 #define DVMA_VME_SLAVE_BASE 0x0FF00000 /* 1MB */
81 #define DVMA_VME_SLAVE_MASK 0x000Fffff /* 1MB */
82
83
84 #if 1 /* XXX - temporary */
85 /*
86 * XXX - For compatibility, until DVMA is re-worked.
87 * Total DVMA space covers SEGMAP + PAGEMAP
88 */
89 #define DVMA_SPACE_START DVMA_SEGMAP_BASE
90 #define DVMA_SPACE_END DVMA_PAGEMAP_END
91 #define DVMA_SPACE_SIZE (DVMA_SPACE_END - DVMA_SPACE_START)
92 #endif /* XXX */
93
94 /*
95 * XXX - These will change! (will be like the sparc)
96 */
97
98 caddr_t dvma_malloc(size_t bytes);
99 void dvma_free(caddr_t addr, size_t bytes);
100
101 caddr_t dvma_mapin(char *kva, int len);
102 void dvma_mapout(caddr_t dvma_addr, int len);
103
104 long dvma_kvtopa(long kva, int bus);
105
106