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