pmap.h revision 1.1 1 /* $NetBSD: pmap.h,v 1.1 1998/06/20 04:58:52 eeh Exp $ */
2
3 /*-
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #ifndef _MACHINE_PMAP_H_
35 #define _MACHINE_PMAP_H_
36
37 #ifndef _LOCORE
38 #include <machine/pte.h>
39 #include <sys/queue.h>
40 #endif
41
42 /*
43 * This scheme uses 2-level page tables.
44 *
45 * While we're still in 32-bit mode we do the following:
46 *
47 * offset: 13 bits
48 * 1st level: 1024 64-bit TTEs in an 8K page for 10 bits
49 * 2nd level: 512 32-bit pointers in the pmap for 9 bits
50 * -------
51 * total: 32 bits
52 *
53 * In 64-bit mode this should be changed as follows
54 *
55 * offset: 13 bits
56 * 1st level: 1024 64-bit TTEs in an 8K page for 10 bits
57 * 2nd level: 1024 64-bit pointers in an 8K page for 10 bits
58 * 3rd level: 128 64-bit pointers in the pmap for 7 bits
59 * -------
60 * total: 40 bits
61 */
62
63 #define PTSZ (NBPG/8)
64 #define STSZ (1<<9)
65
66 #define PTSHIFT (13)
67 #define STSHIFT (10+PTSHIFT)
68
69 #define PTMASK (PTSZ-1)
70 #define STMASK (STSZ-1)
71
72 #ifndef _LOCORE
73
74 /*
75 * Support for big page sizes. This maps the page size to the
76 * page bits.
77 */
78 struct page_size_map {
79 u_int64_t mask;
80 u_int64_t code;
81 #ifdef DEBUG
82 u_int64_t use;
83 #endif
84 };
85 extern struct page_size_map page_size_map[];
86
87 /*
88 * Pmap stuff
89 */
90
91 #define va_to_seg(v) (((v)>>STSHIFT)&STMASK)
92 #define va_to_pte(v) (((v)>>PTSHIFT)&PTMASK)
93
94 /* typedef union sun4u_data ptab[PTSZ]; */
95
96 struct pmap {
97 int pm_ctx; /* Current context */
98 int pm_refs; /* ref count */
99 vm_offset_t pm_physaddr; /* physical address of pm_segs */
100 union sun4u_data* pm_segs[STSZ];
101 };
102
103 /*
104 * This comes from the PROM and is used to map prom entries.
105 */
106 struct prom_map {
107 u_int64_t vstart;
108 u_int64_t vsize;
109 /* struct sun4u_data tte;*/
110 u_int64_t tte;
111 };
112
113 #define PMAP_NC 1 /* Set the E bit in the page */
114 /* If these bits are different in va's to the same PA then there is an aliasing in the d$ */
115 #define VA_ALIAS_MASK (1<<14)
116
117 typedef struct pmap *pmap_t;
118
119 /*
120 * Encode IO space for pmap_enter()
121 *
122 * Since sun4u machines don't have separate IO spaces, this is a noop.
123 */
124 #define PMAP_IOENC(io) 0
125
126 #ifdef _KERNEL
127 extern struct pmap kernel_pmap_;
128 #define pmap_kernel() (&kernel_pmap_)
129
130 void pmap_clear_modify __P((vm_offset_t pa));
131 void pmap_clear_reference __P((vm_offset_t pa));
132 int pmap_is_modified __P((vm_offset_t pa));
133 int pmap_is_referenced __P((vm_offset_t pa));
134 int pmap_count_res __P((pmap_t pmap));
135 /* int pmap_change_wiring __P((pmap_t pm, vm_offset_t va, boolean_t wired)); */
136 #define pmap_resident_count(pm) pmap_count_res((pm))
137 #define pmap_phys_address(x) (x)
138
139 void pmap_bootstrap __P((u_int kernelstart, u_int kernelend, u_int numctx));
140
141 /* This needs to be implemented when we get a kernel map */
142 void pmap_changeprot __P((pmap_t pmap, vm_offset_t start, vm_prot_t prot, int size));
143
144 /* SPARC specific? */
145 void pmap_redzone __P((void));
146 int pmap_dumpsize __P((void));
147 int pmap_dumpmmu __P((int (*)__P((dev_t, daddr_t, caddr_t, size_t)),
148 daddr_t));
149 int pmap_pa_exists __P((vm_offset_t));
150 struct user;
151 void switchexit __P((vm_map_t, struct user *, int));
152
153 /* SPARC64 specific */
154 int ctx_alloc __P((struct pmap*));
155 void ctx_free __P((struct pmap*));
156 void pmap_enter_phys __P((pmap_t, vm_offset_t, u_int64_t, u_int64_t, vm_prot_t, boolean_t));
157
158
159 #endif /* _KERNEL */
160 #endif /* _LOCORE */
161 #endif /* _MACHINE_PMAP_H_ */
162