Mon Jul 6 09:10:02 2020 UTC ()
LKM was gone.


(rin)
diff -r1.30 -r1.31 src/sys/arch/powerpc/include/oea/pmap.h

cvs diff -r1.30 -r1.31 src/sys/arch/powerpc/include/oea/pmap.h (switch to unified diff)

--- src/sys/arch/powerpc/include/oea/pmap.h 2020/03/14 14:05:43 1.30
+++ src/sys/arch/powerpc/include/oea/pmap.h 2020/07/06 09:10:02 1.31
@@ -1,254 +1,254 @@ @@ -1,254 +1,254 @@
1/* $NetBSD: pmap.h,v 1.30 2020/03/14 14:05:43 ad Exp $ */ 1/* $NetBSD: pmap.h,v 1.31 2020/07/06 09:10:02 rin Exp $ */
2 2
3/*- 3/*-
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank. 4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH. 5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution. 15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software 16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement: 17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH. 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 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. 20 * derived from this software without specific prior written permission.
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 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 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 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, 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, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 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, 28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 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 30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#ifndef _POWERPC_OEA_PMAP_H_ 34#ifndef _POWERPC_OEA_PMAP_H_
35#define _POWERPC_OEA_PMAP_H_ 35#define _POWERPC_OEA_PMAP_H_
36 36
37#ifdef _LOCORE  37#ifdef _LOCORE
38#error use assym.h instead 38#error use assym.h instead
39#endif 39#endif
40 40
41#if defined(_LKM) || defined(_MODULE) 41#ifdef _MODULE
42#error this file should not be included by loadable kernel modules 42#error this file should not be included by loadable kernel modules
43#endif 43#endif
44 44
45#ifdef _KERNEL_OPT 45#ifdef _KERNEL_OPT
46#include "opt_ppcarch.h" 46#include "opt_ppcarch.h"
47#endif 47#endif
48#include <powerpc/oea/pte.h> 48#include <powerpc/oea/pte.h>
49 49
50/* 50/*
51 * Pmap stuff 51 * Pmap stuff
52 */ 52 */
53struct pmap { 53struct pmap {
54#ifdef PPC_OEA64 54#ifdef PPC_OEA64
55 struct steg *pm_steg_table; /* segment table pointer */ 55 struct steg *pm_steg_table; /* segment table pointer */
56 /* XXX need way to track exec pages */ 56 /* XXX need way to track exec pages */
57#endif 57#endif
58 58
59#if defined(PPC_OEA) || defined (PPC_OEA64_BRIDGE) 59#if defined(PPC_OEA) || defined (PPC_OEA64_BRIDGE)
60 register_t pm_sr[16]; /* segments used in this pmap */ 60 register_t pm_sr[16]; /* segments used in this pmap */
61 int pm_exec[16]; /* counts of exec mappings */ 61 int pm_exec[16]; /* counts of exec mappings */
62#endif 62#endif
63 register_t pm_vsid; /* VSID bits */ 63 register_t pm_vsid; /* VSID bits */
64 int pm_refs; /* ref count */ 64 int pm_refs; /* ref count */
65 struct pmap_statistics pm_stats; /* pmap statistics */ 65 struct pmap_statistics pm_stats; /* pmap statistics */
66 unsigned int pm_evictions; /* pvo's not in page table */ 66 unsigned int pm_evictions; /* pvo's not in page table */
67 67
68#ifdef PPC_OEA64 68#ifdef PPC_OEA64
69 unsigned int pm_ste_evictions; 69 unsigned int pm_ste_evictions;
70#endif 70#endif
71}; 71};
72 72
73struct pmap_ops { 73struct pmap_ops {
74 int (*pmapop_pte_spill)(struct pmap *, vaddr_t, bool); 74 int (*pmapop_pte_spill)(struct pmap *, vaddr_t, bool);
75 void (*pmapop_real_memory)(paddr_t *, psize_t *); 75 void (*pmapop_real_memory)(paddr_t *, psize_t *);
76 void (*pmapop_init)(void); 76 void (*pmapop_init)(void);
77 void (*pmapop_virtual_space)(vaddr_t *, vaddr_t *); 77 void (*pmapop_virtual_space)(vaddr_t *, vaddr_t *);
78 pmap_t (*pmapop_create)(void); 78 pmap_t (*pmapop_create)(void);
79 void (*pmapop_reference)(pmap_t); 79 void (*pmapop_reference)(pmap_t);
80 void (*pmapop_destroy)(pmap_t); 80 void (*pmapop_destroy)(pmap_t);
81 void (*pmapop_copy)(pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t); 81 void (*pmapop_copy)(pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t);
82 void (*pmapop_update)(pmap_t); 82 void (*pmapop_update)(pmap_t);
83 int (*pmapop_enter)(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int); 83 int (*pmapop_enter)(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int);
84 void (*pmapop_remove)(pmap_t, vaddr_t, vaddr_t); 84 void (*pmapop_remove)(pmap_t, vaddr_t, vaddr_t);
85 void (*pmapop_kenter_pa)(vaddr_t, paddr_t, vm_prot_t, u_int); 85 void (*pmapop_kenter_pa)(vaddr_t, paddr_t, vm_prot_t, u_int);
86 void (*pmapop_kremove)(vaddr_t, vsize_t); 86 void (*pmapop_kremove)(vaddr_t, vsize_t);
87 bool (*pmapop_extract)(pmap_t, vaddr_t, paddr_t *); 87 bool (*pmapop_extract)(pmap_t, vaddr_t, paddr_t *);
88 88
89 void (*pmapop_protect)(pmap_t, vaddr_t, vaddr_t, vm_prot_t); 89 void (*pmapop_protect)(pmap_t, vaddr_t, vaddr_t, vm_prot_t);
90 void (*pmapop_unwire)(pmap_t, vaddr_t); 90 void (*pmapop_unwire)(pmap_t, vaddr_t);
91 void (*pmapop_page_protect)(struct vm_page *, vm_prot_t); 91 void (*pmapop_page_protect)(struct vm_page *, vm_prot_t);
92 bool (*pmapop_query_bit)(struct vm_page *, int); 92 bool (*pmapop_query_bit)(struct vm_page *, int);
93 bool (*pmapop_clear_bit)(struct vm_page *, int); 93 bool (*pmapop_clear_bit)(struct vm_page *, int);
94 94
95 void (*pmapop_activate)(struct lwp *); 95 void (*pmapop_activate)(struct lwp *);
96 void (*pmapop_deactivate)(struct lwp *); 96 void (*pmapop_deactivate)(struct lwp *);
97 97
98 void (*pmapop_pinit)(pmap_t); 98 void (*pmapop_pinit)(pmap_t);
99 void (*pmapop_procwr)(struct proc *, vaddr_t, size_t); 99 void (*pmapop_procwr)(struct proc *, vaddr_t, size_t);
100 100
101 void (*pmapop_pte_print)(volatile struct pte *); 101 void (*pmapop_pte_print)(volatile struct pte *);
102 void (*pmapop_pteg_check)(void); 102 void (*pmapop_pteg_check)(void);
103 void (*pmapop_print_mmuregs)(void); 103 void (*pmapop_print_mmuregs)(void);
104 void (*pmapop_print_pte)(pmap_t, vaddr_t); 104 void (*pmapop_print_pte)(pmap_t, vaddr_t);
105 void (*pmapop_pteg_dist)(void); 105 void (*pmapop_pteg_dist)(void);
106 void (*pmapop_pvo_verify)(void); 106 void (*pmapop_pvo_verify)(void);
107 vaddr_t (*pmapop_steal_memory)(vsize_t, vaddr_t *, vaddr_t *); 107 vaddr_t (*pmapop_steal_memory)(vsize_t, vaddr_t *, vaddr_t *);
108 void (*pmapop_bootstrap)(paddr_t, paddr_t); 108 void (*pmapop_bootstrap)(paddr_t, paddr_t);
109}; 109};
110 110
111#ifdef _KERNEL 111#ifdef _KERNEL
112#include <sys/cdefs.h> 112#include <sys/cdefs.h>
113__BEGIN_DECLS 113__BEGIN_DECLS
114#include <sys/param.h> 114#include <sys/param.h>
115#include <sys/systm.h> 115#include <sys/systm.h>
116 116
117#if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE) 117#if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE)
118extern register_t iosrtable[]; 118extern register_t iosrtable[];
119#endif 119#endif
120extern int pmap_use_altivec; 120extern int pmap_use_altivec;
121 121
122#define pmap_clear_modify(pg) (pmap_clear_bit((pg), PTE_CHG)) 122#define pmap_clear_modify(pg) (pmap_clear_bit((pg), PTE_CHG))
123#define pmap_clear_reference(pg) (pmap_clear_bit((pg), PTE_REF)) 123#define pmap_clear_reference(pg) (pmap_clear_bit((pg), PTE_REF))
124#define pmap_is_modified(pg) (pmap_query_bit((pg), PTE_CHG)) 124#define pmap_is_modified(pg) (pmap_query_bit((pg), PTE_CHG))
125#define pmap_is_referenced(pg) (pmap_query_bit((pg), PTE_REF)) 125#define pmap_is_referenced(pg) (pmap_query_bit((pg), PTE_REF))
126 126
127#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 127#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
128#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) 128#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
129 129
130/* ARGSUSED */ 130/* ARGSUSED */
131static __inline bool 131static __inline bool
132pmap_remove_all(struct pmap *pmap) 132pmap_remove_all(struct pmap *pmap)
133{ 133{
134 /* Nothing. */ 134 /* Nothing. */
135 return false; 135 return false;
136} 136}
137 137
138#if (defined(PPC_OEA) + defined(PPC_OEA64) + defined(PPC_OEA64_BRIDGE)) != 1 138#if (defined(PPC_OEA) + defined(PPC_OEA64) + defined(PPC_OEA64_BRIDGE)) != 1
139#define PMAP_NEEDS_FIXUP 139#define PMAP_NEEDS_FIXUP
140#endif 140#endif
141 141
142extern volatile struct pteg *pmap_pteg_table; 142extern volatile struct pteg *pmap_pteg_table;
143extern unsigned int pmap_pteg_cnt; 143extern unsigned int pmap_pteg_cnt;
144extern unsigned int pmap_pteg_mask; 144extern unsigned int pmap_pteg_mask;
145 145
146void pmap_bootstrap(vaddr_t, vaddr_t); 146void pmap_bootstrap(vaddr_t, vaddr_t);
147bool pmap_extract(pmap_t, vaddr_t, paddr_t *); 147bool pmap_extract(pmap_t, vaddr_t, paddr_t *);
148bool pmap_query_bit(struct vm_page *, int); 148bool pmap_query_bit(struct vm_page *, int);
149bool pmap_clear_bit(struct vm_page *, int); 149bool pmap_clear_bit(struct vm_page *, int);
150void pmap_real_memory(paddr_t *, psize_t *); 150void pmap_real_memory(paddr_t *, psize_t *);
151void pmap_procwr(struct proc *, vaddr_t, size_t); 151void pmap_procwr(struct proc *, vaddr_t, size_t);
152int pmap_pte_spill(pmap_t, vaddr_t, bool); 152int pmap_pte_spill(pmap_t, vaddr_t, bool);
153int pmap_ste_spill(pmap_t, vaddr_t, bool); 153int pmap_ste_spill(pmap_t, vaddr_t, bool);
154void pmap_pinit(pmap_t); 154void pmap_pinit(pmap_t);
155 155
156u_int powerpc_mmap_flags(paddr_t); 156u_int powerpc_mmap_flags(paddr_t);
157#define POWERPC_MMAP_FLAG_MASK 0xf 157#define POWERPC_MMAP_FLAG_MASK 0xf
158#define POWERPC_MMAP_FLAG_PREFETCHABLE 0x1 158#define POWERPC_MMAP_FLAG_PREFETCHABLE 0x1
159#define POWERPC_MMAP_FLAG_CACHEABLE 0x2 159#define POWERPC_MMAP_FLAG_CACHEABLE 0x2
160 160
161#define pmap_phys_address(ppn) (ppn & ~POWERPC_MMAP_FLAG_MASK) 161#define pmap_phys_address(ppn) (ppn & ~POWERPC_MMAP_FLAG_MASK)
162#define pmap_mmap_flags(ppn) powerpc_mmap_flags(ppn) 162#define pmap_mmap_flags(ppn) powerpc_mmap_flags(ppn)
163 163
164static __inline paddr_t vtophys (vaddr_t); 164static __inline paddr_t vtophys (vaddr_t);
165 165
166/* 166/*
167 * Alternate mapping hooks for pool pages. Avoids thrashing the TLB. 167 * Alternate mapping hooks for pool pages. Avoids thrashing the TLB.
168 * 168 *
169 * Note: This won't work if we have more memory than can be direct-mapped 169 * Note: This won't work if we have more memory than can be direct-mapped
170 * VA==PA all at once. But pmap_copy_page() and pmap_zero_page() will have 170 * VA==PA all at once. But pmap_copy_page() and pmap_zero_page() will have
171 * this problem, too. 171 * this problem, too.
172 */ 172 */
173#if !defined(PPC_OEA64) && !defined (PPC_OEA64_BRIDGE) 173#if !defined(PPC_OEA64) && !defined (PPC_OEA64_BRIDGE)
174#define PMAP_MAP_POOLPAGE(pa) (pa) 174#define PMAP_MAP_POOLPAGE(pa) (pa)
175#define PMAP_UNMAP_POOLPAGE(pa) (pa) 175#define PMAP_UNMAP_POOLPAGE(pa) (pa)
176#define POOL_VTOPHYS(va) vtophys((vaddr_t) va) 176#define POOL_VTOPHYS(va) vtophys((vaddr_t) va)
177#endif 177#endif
178 178
179static __inline paddr_t 179static __inline paddr_t
180vtophys(vaddr_t va) 180vtophys(vaddr_t va)
181{ 181{
182 paddr_t pa; 182 paddr_t pa;
183 183
184 if (pmap_extract(pmap_kernel(), va, &pa)) 184 if (pmap_extract(pmap_kernel(), va, &pa))
185 return pa; 185 return pa;
186 KASSERTMSG(0, "vtophys: pmap_extract of %#"PRIxVADDR" failed", va); 186 KASSERTMSG(0, "vtophys: pmap_extract of %#"PRIxVADDR" failed", va);
187 return (paddr_t) -1; 187 return (paddr_t) -1;
188} 188}
189 189
190 190
191#ifdef PMAP_NEEDS_FIXUP 191#ifdef PMAP_NEEDS_FIXUP
192extern const struct pmap_ops *pmapops; 192extern const struct pmap_ops *pmapops;
193extern const struct pmap_ops pmap32_ops; 193extern const struct pmap_ops pmap32_ops;
194extern const struct pmap_ops pmap64_ops; 194extern const struct pmap_ops pmap64_ops;
195extern const struct pmap_ops pmap64bridge_ops; 195extern const struct pmap_ops pmap64bridge_ops;
196 196
197static __inline void 197static __inline void
198pmap_setup32(void) 198pmap_setup32(void)
199{ 199{
200 pmapops = &pmap32_ops; 200 pmapops = &pmap32_ops;
201} 201}
202 202
203static __inline void 203static __inline void
204pmap_setup64(void) 204pmap_setup64(void)
205{ 205{
206 pmapops = &pmap64_ops; 206 pmapops = &pmap64_ops;
207} 207}
208 208
209static __inline void 209static __inline void
210pmap_setup64bridge(void) 210pmap_setup64bridge(void)
211{ 211{
212 pmapops = &pmap64bridge_ops; 212 pmapops = &pmap64bridge_ops;
213} 213}
214#endif 214#endif
215 215
216bool pmap_pageidlezero (paddr_t); 216bool pmap_pageidlezero (paddr_t);
217void pmap_syncicache (paddr_t, psize_t); 217void pmap_syncicache (paddr_t, psize_t);
218#ifdef PPC_OEA64 218#ifdef PPC_OEA64
219vaddr_t pmap_setusr (vaddr_t); 219vaddr_t pmap_setusr (vaddr_t);
220vaddr_t pmap_unsetusr (void); 220vaddr_t pmap_unsetusr (void);
221#endif 221#endif
222 222
223#ifdef PPC_OEA64_BRIDGE 223#ifdef PPC_OEA64_BRIDGE
224int pmap_setup_segment0_map(int use_large_pages, ...); 224int pmap_setup_segment0_map(int use_large_pages, ...);
225#endif 225#endif
226 226
227#define PMAP_MD_PREFETCHABLE 0x2000000 227#define PMAP_MD_PREFETCHABLE 0x2000000
228#define PMAP_STEAL_MEMORY 228#define PMAP_STEAL_MEMORY
229#define PMAP_NEED_PROCWR 229#define PMAP_NEED_PROCWR
230 230
231void pmap_zero_page(paddr_t); 231void pmap_zero_page(paddr_t);
232void pmap_copy_page(paddr_t, paddr_t); 232void pmap_copy_page(paddr_t, paddr_t);
233 233
234LIST_HEAD(pvo_head, pvo_entry); 234LIST_HEAD(pvo_head, pvo_entry);
235 235
236#define __HAVE_VM_PAGE_MD 236#define __HAVE_VM_PAGE_MD
237 237
238struct vm_page_md { 238struct vm_page_md {
239 unsigned int mdpg_attrs;  239 unsigned int mdpg_attrs;
240 struct pvo_head mdpg_pvoh; 240 struct pvo_head mdpg_pvoh;
241#ifdef MODULAR 241#ifdef MODULAR
242 uintptr_t mdpg_dummy[3]; 242 uintptr_t mdpg_dummy[3];
243#endif 243#endif
244}; 244};
245 245
246#define VM_MDPAGE_INIT(pg) do { \ 246#define VM_MDPAGE_INIT(pg) do { \
247 (pg)->mdpage.mdpg_attrs = 0; \ 247 (pg)->mdpage.mdpg_attrs = 0; \
248 LIST_INIT(&(pg)->mdpage.mdpg_pvoh); \ 248 LIST_INIT(&(pg)->mdpage.mdpg_pvoh); \
249} while (/*CONSTCOND*/0) 249} while (/*CONSTCOND*/0)
250 250
251__END_DECLS 251__END_DECLS
252#endif /* _KERNEL */ 252#endif /* _KERNEL */
253 253
254#endif /* _POWERPC_OEA_PMAP_H_ */ 254#endif /* _POWERPC_OEA_PMAP_H_ */