Thu Sep 28 06:19:19 2023 UTC ()
Trailing whitespace.


(skrll)
diff -r1.21 -r1.22 src/sys/arch/powerpc/include/ibm4xx/pmap.h
diff -r1.37 -r1.38 src/sys/arch/powerpc/include/oea/pmap.h

cvs diff -r1.21 -r1.22 src/sys/arch/powerpc/include/ibm4xx/pmap.h (switch to unified diff)

--- src/sys/arch/powerpc/include/ibm4xx/pmap.h 2020/03/14 14:05:43 1.21
+++ src/sys/arch/powerpc/include/ibm4xx/pmap.h 2023/09/28 06:19:19 1.22
@@ -1,212 +1,212 @@ @@ -1,212 +1,212 @@
1/* $NetBSD: pmap.h,v 1.21 2020/03/14 14:05:43 ad Exp $ */ 1/* $NetBSD: pmap.h,v 1.22 2023/09/28 06:19:19 skrll Exp $ */
2 2
3/* 3/*
4 * Copyright 2001 Wasabi Systems, Inc. 4 * Copyright 2001 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc. 7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution. 16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software 17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement: 18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by 19 * This product includes software developed for the NetBSD Project by
20 * Wasabi Systems, Inc. 20 * Wasabi Systems, Inc.
21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse 21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior 22 * or promote products derived from this software without specific prior
23 * written permission. 23 * written permission.
24 * 24 *
25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE. 35 * POSSIBILITY OF SUCH DAMAGE.
36 */ 36 */
37 37
38/*- 38/*-
39 * Copyright (C) 1995, 1996 Wolfgang Solfrank. 39 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
40 * Copyright (C) 1995, 1996 TooLs GmbH. 40 * Copyright (C) 1995, 1996 TooLs GmbH.
41 * All rights reserved. 41 * All rights reserved.
42 * 42 *
43 * Redistribution and use in source and binary forms, with or without 43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions 44 * modification, are permitted provided that the following conditions
45 * are met: 45 * are met:
46 * 1. Redistributions of source code must retain the above copyright 46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer. 47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright 48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the 49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution. 50 * documentation and/or other materials provided with the distribution.
51 * 3. All advertising materials mentioning features or use of this software 51 * 3. All advertising materials mentioning features or use of this software
52 * must display the following acknowledgement: 52 * must display the following acknowledgement:
53 * This product includes software developed by TooLs GmbH. 53 * This product includes software developed by TooLs GmbH.
54 * 4. The name of TooLs GmbH may not be used to endorse or promote products 54 * 4. The name of TooLs GmbH may not be used to endorse or promote products
55 * derived from this software without specific prior written permission. 55 * derived from this software without specific prior written permission.
56 * 56 *
57 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 57 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
58 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 58 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 59 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 60 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 61 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
62 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 62 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
63 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 63 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
64 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 64 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
65 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 65 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
66 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 66 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 */ 67 */
68 68
69#ifndef _IBM4XX_PMAP_H_ 69#ifndef _IBM4XX_PMAP_H_
70#define _IBM4XX_PMAP_H_ 70#define _IBM4XX_PMAP_H_
71 71
72#ifdef _LOCORE  72#ifdef _LOCORE
73#error use assym.h instead 73#error use assym.h instead
74#endif 74#endif
75 75
76#if defined(_MODULE) 76#if defined(_MODULE)
77#error this file should not be included by loadable kernel modules 77#error this file should not be included by loadable kernel modules
78#endif 78#endif
79 79
80#include <powerpc/ibm4xx/tlb.h> 80#include <powerpc/ibm4xx/tlb.h>
81 81
82#define KERNEL_PID 1 /* TLB PID to use for kernel translation */ 82#define KERNEL_PID 1 /* TLB PID to use for kernel translation */
83 83
84/* 84/*
85 * A TTE is a 16KB or greater TLB entry w/size and endianness bits 85 * A TTE is a 16KB or greater TLB entry w/size and endianness bits
86 * stuffed in the (unused) low bits of the PA. 86 * stuffed in the (unused) low bits of the PA.
87 */ 87 */
88#define TTE_PA_MASK 0xffffc000 88#define TTE_PA_MASK 0xffffc000
89#define TTE_RPN_MASK(sz) (~((1 << (10 + 2 * (sz))) - 1)) 89#define TTE_RPN_MASK(sz) (~((1 << (10 + 2 * (sz))) - 1))
90#define TTE_ENDIAN 0x00002000 90#define TTE_ENDIAN 0x00002000
91#define TTE_SZ_MASK 0x00001c00 91#define TTE_SZ_MASK 0x00001c00
92#define TTE_SZ_SHIFT 10 92#define TTE_SZ_SHIFT 10
93 93
94/* TTE_SZ_1K and TTE_SZ_4K are not allowed. */ 94/* TTE_SZ_1K and TTE_SZ_4K are not allowed. */
95#define TTE_SZ_16K (TLB_SIZE_16K << TTE_SZ_SHIFT) 95#define TTE_SZ_16K (TLB_SIZE_16K << TTE_SZ_SHIFT)
96#define TTE_SZ_64K (TLB_SIZE_64K << TTE_SZ_SHIFT) 96#define TTE_SZ_64K (TLB_SIZE_64K << TTE_SZ_SHIFT)
97#define TTE_SZ_256K (TLB_SIZE_256K << TTE_SZ_SHIFT) 97#define TTE_SZ_256K (TLB_SIZE_256K << TTE_SZ_SHIFT)
98#define TTE_SZ_1M (TLB_SIZE_1M << TTE_SZ_SHIFT) 98#define TTE_SZ_1M (TLB_SIZE_1M << TTE_SZ_SHIFT)
99#define TTE_SZ_4M (TLB_SIZE_4M << TTE_SZ_SHIFT) 99#define TTE_SZ_4M (TLB_SIZE_4M << TTE_SZ_SHIFT)
100#define TTE_SZ_16M (TLB_SIZE_16M << TTE_SZ_SHIFT) 100#define TTE_SZ_16M (TLB_SIZE_16M << TTE_SZ_SHIFT)
101 101
102#define TTE_EX TLB_EX 102#define TTE_EX TLB_EX
103#define TTE_WR TLB_WR 103#define TTE_WR TLB_WR
104#define TTE_ZSEL_MASK TLB_ZSEL_MASK 104#define TTE_ZSEL_MASK TLB_ZSEL_MASK
105#define TTE_ZSEL_SHFT TLB_ZSEL_SHFT 105#define TTE_ZSEL_SHFT TLB_ZSEL_SHFT
106#define TTE_W TLB_W 106#define TTE_W TLB_W
107#define TTE_I TLB_I 107#define TTE_I TLB_I
108#define TTE_M TLB_M 108#define TTE_M TLB_M
109#define TTE_G TLB_G 109#define TTE_G TLB_G
110 110
111#define ZONE_PRIV 0 111#define ZONE_PRIV 0
112#define ZONE_USER 1 112#define ZONE_USER 1
113 113
114#define TTE_PA(p) ((p)&TTE_PA_MASK) 114#define TTE_PA(p) ((p)&TTE_PA_MASK)
115#define TTE_ZONE(z) TLB_ZONE(z) 115#define TTE_ZONE(z) TLB_ZONE(z)
116 116
117/* 117/*
118 * Definitions for sizes of 1st and 2nd level page tables. 118 * Definitions for sizes of 1st and 2nd level page tables.
119 * 119 *
120 */ 120 */
121#define PTSZ (PAGE_SIZE / 4) 121#define PTSZ (PAGE_SIZE / 4)
122#define PTMAP (PTSZ * PAGE_SIZE) 122#define PTMAP (PTSZ * PAGE_SIZE)
123#define PTMSK ((PTMAP - 1) & ~(PGOFSET)) 123#define PTMSK ((PTMAP - 1) & ~(PGOFSET))
124 124
125#define PTIDX(v) (((v) & PTMSK) >> PGSHIFT) 125#define PTIDX(v) (((v) & PTMSK) >> PGSHIFT)
126 126
127/* 2nd level tables map in any bits not mapped by 1st level tables. */ 127/* 2nd level tables map in any bits not mapped by 1st level tables. */
128#define STSZ ((0xffffffffU / (PAGE_SIZE * PTSZ)) + 1) 128#define STSZ ((0xffffffffU / (PAGE_SIZE * PTSZ)) + 1)
129#define STMAP (0xffffffffU) 129#define STMAP (0xffffffffU)
130#define STMSK (~(PTMAP - 1)) 130#define STMSK (~(PTMAP - 1))
131 131
132#define STIDX(v) ((v) >> (PGSHIFT + 12)) 132#define STIDX(v) ((v) >> (PGSHIFT + 12))
133 133
134 134
135/*  135/*
136 * Extra flags to pass to pmap_enter() -- make sure they don't conflict 136 * Extra flags to pass to pmap_enter() -- make sure they don't conflict
137 * w/PMAP_CANFAIL or PMAP_WIRED 137 * w/PMAP_CANFAIL or PMAP_WIRED
138 */ 138 */
139#define PME_NOCACHE 0x1000000 139#define PME_NOCACHE 0x1000000
140#define PME_WRITETHROUG 0x2000000 140#define PME_WRITETHROUG 0x2000000
141 141
142/* 142/*
143 * Pmap stuff 143 * Pmap stuff
144 */ 144 */
145struct pmap { 145struct pmap {
146 volatile int pm_ctx; /* PID to identify PMAP's entries in TLB */ 146 volatile int pm_ctx; /* PID to identify PMAP's entries in TLB */
147 int pm_refs; /* ref count */ 147 int pm_refs; /* ref count */
148 struct pmap_statistics pm_stats; /* pmap statistics */ 148 struct pmap_statistics pm_stats; /* pmap statistics */
149 volatile u_int *pm_ptbl[STSZ]; /* Array of 64 pointers to page tables. */ 149 volatile u_int *pm_ptbl[STSZ]; /* Array of 64 pointers to page tables. */
150}; 150};
151 151
152#ifdef _KERNEL 152#ifdef _KERNEL
153#define PMAP_GROWKERNEL 153#define PMAP_GROWKERNEL
154 154
155#define PMAP_ATTR_REF 0x1 155#define PMAP_ATTR_REF 0x1
156#define PMAP_ATTR_CHG 0x2 156#define PMAP_ATTR_CHG 0x2
157 157
158#define pmap_clear_modify(pg) (pmap_check_attr((pg), PMAP_ATTR_CHG, 1)) 158#define pmap_clear_modify(pg) (pmap_check_attr((pg), PMAP_ATTR_CHG, 1))
159#define pmap_clear_reference(pg)(pmap_check_attr((pg), PMAP_ATTR_REF, 1)) 159#define pmap_clear_reference(pg)(pmap_check_attr((pg), PMAP_ATTR_REF, 1))
160#define pmap_is_modified(pg) (pmap_check_attr((pg), PMAP_ATTR_CHG, 0)) 160#define pmap_is_modified(pg) (pmap_check_attr((pg), PMAP_ATTR_CHG, 0))
161#define pmap_is_referenced(pg) (pmap_check_attr((pg), PMAP_ATTR_REF, 0)) 161#define pmap_is_referenced(pg) (pmap_check_attr((pg), PMAP_ATTR_REF, 0))
162 162
163#define pmap_phys_address(x) (x) 163#define pmap_phys_address(x) (x)
164 164
165#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 165#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
166#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) 166#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
167 167
168void pmap_unwire(struct pmap *pm, vaddr_t va); 168void pmap_unwire(struct pmap *pm, vaddr_t va);
169void pmap_bootstrap(u_int kernelstart, u_int kernelend); 169void pmap_bootstrap(u_int kernelstart, u_int kernelend);
170bool pmap_extract(struct pmap *, vaddr_t, paddr_t *); 170bool pmap_extract(struct pmap *, vaddr_t, paddr_t *);
171bool pmap_check_attr(struct vm_page *, u_int, int); 171bool pmap_check_attr(struct vm_page *, u_int, int);
172void pmap_real_memory(paddr_t *, psize_t *); 172void pmap_real_memory(paddr_t *, psize_t *);
173int pmap_tlbmiss(vaddr_t va, int ctx); 173int pmap_tlbmiss(vaddr_t va, int ctx);
174 174
175static __inline bool 175static __inline bool
176pmap_remove_all(struct pmap *pmap) 176pmap_remove_all(struct pmap *pmap)
177{ 177{
178 /* Nothing. */ 178 /* Nothing. */
179 return false; 179 return false;
180} 180}
181 181
182int ctx_alloc(struct pmap *); 182int ctx_alloc(struct pmap *);
183void ctx_free(struct pmap *); 183void ctx_free(struct pmap *);
184 184
185#define PMAP_NEED_PROCWR 185#define PMAP_NEED_PROCWR
186void pmap_procwr(struct proc *, vaddr_t, size_t); 186void pmap_procwr(struct proc *, vaddr_t, size_t);
187 187
188/* 188/*
189 * Alternate mapping hooks for pool pages. Avoids thrashing the TLB. 189 * Alternate mapping hooks for pool pages. Avoids thrashing the TLB.
190 * 190 *
191 * Note: This won't work if we have more memory than can be direct-mapped 191 * Note: This won't work if we have more memory than can be direct-mapped
192 * VA==PA all at once. But pmap_copy_page() and pmap_zero_page() will have 192 * VA==PA all at once. But pmap_copy_page() and pmap_zero_page() will have
193 * this problem, too. 193 * this problem, too.
194 */ 194 */
195#define PMAP_MAP_POOLPAGE(pa) (pa) 195#define PMAP_MAP_POOLPAGE(pa) (pa)
196#define PMAP_UNMAP_POOLPAGE(pa) (pa) 196#define PMAP_UNMAP_POOLPAGE(pa) (pa)
197 197
198static __inline paddr_t vtophys(vaddr_t); 198static __inline paddr_t vtophys(vaddr_t);
199 199
200static __inline paddr_t 200static __inline paddr_t
201vtophys(vaddr_t va) 201vtophys(vaddr_t va)
202{ 202{
203 paddr_t pa; 203 paddr_t pa;
204 204
205 /* XXX should check battable */ 205 /* XXX should check battable */
206 206
207 if (pmap_extract(pmap_kernel(), va, &pa)) 207 if (pmap_extract(pmap_kernel(), va, &pa))
208 return pa; 208 return pa;
209 return va; 209 return va;
210} 210}
211#endif /* _KERNEL */ 211#endif /* _KERNEL */
212#endif /* _IBM4XX_PMAP_H_ */ 212#endif /* _IBM4XX_PMAP_H_ */

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

--- src/sys/arch/powerpc/include/oea/pmap.h 2022/05/07 07:10:46 1.37
+++ src/sys/arch/powerpc/include/oea/pmap.h 2023/09/28 06:19:19 1.38
@@ -1,279 +1,279 @@ @@ -1,279 +1,279 @@
1/* $NetBSD: pmap.h,v 1.37 2022/05/07 07:10:46 rin Exp $ */ 1/* $NetBSD: pmap.h,v 1.38 2023/09/28 06:19:19 skrll 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#ifdef _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#include "opt_modular.h" 47#include "opt_modular.h"
48#endif 48#endif
49#include <powerpc/oea/pte.h> 49#include <powerpc/oea/pte.h>
50 50
51#define __HAVE_PMAP_PV_TRACK 51#define __HAVE_PMAP_PV_TRACK
52#include <uvm/pmap/pmap_pvt.h> 52#include <uvm/pmap/pmap_pvt.h>
53 53
54/* 54/*
55 * Pmap stuff 55 * Pmap stuff
56 */ 56 */
57struct pmap { 57struct pmap {
58#ifdef PPC_OEA64 58#ifdef PPC_OEA64
59 struct steg *pm_steg_table; /* segment table pointer */ 59 struct steg *pm_steg_table; /* segment table pointer */
60 /* XXX need way to track exec pages */ 60 /* XXX need way to track exec pages */
61#endif 61#endif
62 62
63#if defined(PPC_OEA) || defined (PPC_OEA64_BRIDGE) 63#if defined(PPC_OEA) || defined (PPC_OEA64_BRIDGE)
64 register_t pm_sr[16]; /* segments used in this pmap */ 64 register_t pm_sr[16]; /* segments used in this pmap */
65 int pm_exec[16]; /* counts of exec mappings */ 65 int pm_exec[16]; /* counts of exec mappings */
66#endif 66#endif
67 register_t pm_vsid; /* VSID bits */ 67 register_t pm_vsid; /* VSID bits */
68 int pm_refs; /* ref count */ 68 int pm_refs; /* ref count */
69 struct pmap_statistics pm_stats; /* pmap statistics */ 69 struct pmap_statistics pm_stats; /* pmap statistics */
70 unsigned int pm_evictions; /* pvo's not in page table */ 70 unsigned int pm_evictions; /* pvo's not in page table */
71 71
72#ifdef PPC_OEA64 72#ifdef PPC_OEA64
73 unsigned int pm_ste_evictions; 73 unsigned int pm_ste_evictions;
74#endif 74#endif
75}; 75};
76 76
77struct pmap_ops { 77struct pmap_ops {
78 int (*pmapop_pte_spill)(struct pmap *, vaddr_t, bool); 78 int (*pmapop_pte_spill)(struct pmap *, vaddr_t, bool);
79 void (*pmapop_real_memory)(paddr_t *, psize_t *); 79 void (*pmapop_real_memory)(paddr_t *, psize_t *);
80 void (*pmapop_init)(void); 80 void (*pmapop_init)(void);
81 void (*pmapop_virtual_space)(vaddr_t *, vaddr_t *); 81 void (*pmapop_virtual_space)(vaddr_t *, vaddr_t *);
82 pmap_t (*pmapop_create)(void); 82 pmap_t (*pmapop_create)(void);
83 void (*pmapop_reference)(pmap_t); 83 void (*pmapop_reference)(pmap_t);
84 void (*pmapop_destroy)(pmap_t); 84 void (*pmapop_destroy)(pmap_t);
85 void (*pmapop_copy)(pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t); 85 void (*pmapop_copy)(pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t);
86 void (*pmapop_update)(pmap_t); 86 void (*pmapop_update)(pmap_t);
87 int (*pmapop_enter)(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int); 87 int (*pmapop_enter)(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int);
88 void (*pmapop_remove)(pmap_t, vaddr_t, vaddr_t); 88 void (*pmapop_remove)(pmap_t, vaddr_t, vaddr_t);
89 void (*pmapop_kenter_pa)(vaddr_t, paddr_t, vm_prot_t, u_int); 89 void (*pmapop_kenter_pa)(vaddr_t, paddr_t, vm_prot_t, u_int);
90 void (*pmapop_kremove)(vaddr_t, vsize_t); 90 void (*pmapop_kremove)(vaddr_t, vsize_t);
91 bool (*pmapop_extract)(pmap_t, vaddr_t, paddr_t *); 91 bool (*pmapop_extract)(pmap_t, vaddr_t, paddr_t *);
92 92
93 void (*pmapop_protect)(pmap_t, vaddr_t, vaddr_t, vm_prot_t); 93 void (*pmapop_protect)(pmap_t, vaddr_t, vaddr_t, vm_prot_t);
94 void (*pmapop_unwire)(pmap_t, vaddr_t); 94 void (*pmapop_unwire)(pmap_t, vaddr_t);
95 void (*pmapop_page_protect)(struct vm_page *, vm_prot_t); 95 void (*pmapop_page_protect)(struct vm_page *, vm_prot_t);
96 void (*pmapop_pv_protect)(paddr_t, vm_prot_t); 96 void (*pmapop_pv_protect)(paddr_t, vm_prot_t);
97 bool (*pmapop_query_bit)(struct vm_page *, int); 97 bool (*pmapop_query_bit)(struct vm_page *, int);
98 bool (*pmapop_clear_bit)(struct vm_page *, int); 98 bool (*pmapop_clear_bit)(struct vm_page *, int);
99 99
100 void (*pmapop_activate)(struct lwp *); 100 void (*pmapop_activate)(struct lwp *);
101 void (*pmapop_deactivate)(struct lwp *); 101 void (*pmapop_deactivate)(struct lwp *);
102 102
103 void (*pmapop_pinit)(pmap_t); 103 void (*pmapop_pinit)(pmap_t);
104 void (*pmapop_procwr)(struct proc *, vaddr_t, size_t); 104 void (*pmapop_procwr)(struct proc *, vaddr_t, size_t);
105 105
106 void (*pmapop_pte_print)(volatile struct pte *); 106 void (*pmapop_pte_print)(volatile struct pte *);
107 void (*pmapop_pteg_check)(void); 107 void (*pmapop_pteg_check)(void);
108 void (*pmapop_print_mmuregs)(void); 108 void (*pmapop_print_mmuregs)(void);
109 void (*pmapop_print_pte)(pmap_t, vaddr_t); 109 void (*pmapop_print_pte)(pmap_t, vaddr_t);
110 void (*pmapop_pteg_dist)(void); 110 void (*pmapop_pteg_dist)(void);
111 void (*pmapop_pvo_verify)(void); 111 void (*pmapop_pvo_verify)(void);
112 vaddr_t (*pmapop_steal_memory)(vsize_t, vaddr_t *, vaddr_t *); 112 vaddr_t (*pmapop_steal_memory)(vsize_t, vaddr_t *, vaddr_t *);
113 void (*pmapop_bootstrap)(paddr_t, paddr_t); 113 void (*pmapop_bootstrap)(paddr_t, paddr_t);
114 void (*pmapop_bootstrap1)(paddr_t, paddr_t); 114 void (*pmapop_bootstrap1)(paddr_t, paddr_t);
115 void (*pmapop_bootstrap2)(void); 115 void (*pmapop_bootstrap2)(void);
116}; 116};
117 117
118#ifdef _KERNEL 118#ifdef _KERNEL
119#include <sys/cdefs.h> 119#include <sys/cdefs.h>
120__BEGIN_DECLS 120__BEGIN_DECLS
121#include <sys/param.h> 121#include <sys/param.h>
122#include <sys/systm.h> 122#include <sys/systm.h>
123 123
124#if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE) 124#if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE)
125extern register_t iosrtable[]; 125extern register_t iosrtable[];
126#endif 126#endif
127extern int pmap_use_altivec; 127extern int pmap_use_altivec;
128 128
129#define pmap_clear_modify(pg) (pmap_clear_bit((pg), PTE_CHG)) 129#define pmap_clear_modify(pg) (pmap_clear_bit((pg), PTE_CHG))
130#define pmap_clear_reference(pg) (pmap_clear_bit((pg), PTE_REF)) 130#define pmap_clear_reference(pg) (pmap_clear_bit((pg), PTE_REF))
131#define pmap_is_modified(pg) (pmap_query_bit((pg), PTE_CHG)) 131#define pmap_is_modified(pg) (pmap_query_bit((pg), PTE_CHG))
132#define pmap_is_referenced(pg) (pmap_query_bit((pg), PTE_REF)) 132#define pmap_is_referenced(pg) (pmap_query_bit((pg), PTE_REF))
133 133
134#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 134#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
135#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) 135#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
136 136
137/* ARGSUSED */ 137/* ARGSUSED */
138static __inline bool 138static __inline bool
139pmap_remove_all(struct pmap *pmap) 139pmap_remove_all(struct pmap *pmap)
140{ 140{
141 /* Nothing. */ 141 /* Nothing. */
142 return false; 142 return false;
143} 143}
144 144
145#if (defined(PPC_OEA) + defined(PPC_OEA64) + defined(PPC_OEA64_BRIDGE)) != 1 145#if (defined(PPC_OEA) + defined(PPC_OEA64) + defined(PPC_OEA64_BRIDGE)) != 1
146#define PMAP_NEEDS_FIXUP 146#define PMAP_NEEDS_FIXUP
147#endif 147#endif
148 148
149extern volatile struct pteg *pmap_pteg_table; 149extern volatile struct pteg *pmap_pteg_table;
150extern unsigned int pmap_pteg_cnt; 150extern unsigned int pmap_pteg_cnt;
151extern unsigned int pmap_pteg_mask; 151extern unsigned int pmap_pteg_mask;
152 152
153void pmap_bootstrap(vaddr_t, vaddr_t); 153void pmap_bootstrap(vaddr_t, vaddr_t);
154void pmap_bootstrap1(vaddr_t, vaddr_t); 154void pmap_bootstrap1(vaddr_t, vaddr_t);
155void pmap_bootstrap2(void); 155void pmap_bootstrap2(void);
156bool pmap_extract(pmap_t, vaddr_t, paddr_t *); 156bool pmap_extract(pmap_t, vaddr_t, paddr_t *);
157bool pmap_query_bit(struct vm_page *, int); 157bool pmap_query_bit(struct vm_page *, int);
158bool pmap_clear_bit(struct vm_page *, int); 158bool pmap_clear_bit(struct vm_page *, int);
159void pmap_real_memory(paddr_t *, psize_t *); 159void pmap_real_memory(paddr_t *, psize_t *);
160void pmap_procwr(struct proc *, vaddr_t, size_t); 160void pmap_procwr(struct proc *, vaddr_t, size_t);
161int pmap_pte_spill(pmap_t, vaddr_t, bool); 161int pmap_pte_spill(pmap_t, vaddr_t, bool);
162int pmap_ste_spill(pmap_t, vaddr_t, bool); 162int pmap_ste_spill(pmap_t, vaddr_t, bool);
163void pmap_pinit(pmap_t); 163void pmap_pinit(pmap_t);
164 164
165#ifdef PPC_OEA601 165#ifdef PPC_OEA601
166bool pmap_extract_ioseg601(vaddr_t, paddr_t *); 166bool pmap_extract_ioseg601(vaddr_t, paddr_t *);
167#endif /* PPC_OEA601 */ 167#endif /* PPC_OEA601 */
168#ifdef PPC_OEA 168#ifdef PPC_OEA
169bool pmap_extract_battable(vaddr_t, paddr_t *); 169bool pmap_extract_battable(vaddr_t, paddr_t *);
170#endif /* PPC_OEA */ 170#endif /* PPC_OEA */
171 171
172u_int powerpc_mmap_flags(paddr_t); 172u_int powerpc_mmap_flags(paddr_t);
173#define POWERPC_MMAP_FLAG_MASK 0xf 173#define POWERPC_MMAP_FLAG_MASK 0xf
174#define POWERPC_MMAP_FLAG_PREFETCHABLE 0x1 174#define POWERPC_MMAP_FLAG_PREFETCHABLE 0x1
175#define POWERPC_MMAP_FLAG_CACHEABLE 0x2 175#define POWERPC_MMAP_FLAG_CACHEABLE 0x2
176 176
177#define pmap_phys_address(ppn) (ppn & ~POWERPC_MMAP_FLAG_MASK) 177#define pmap_phys_address(ppn) (ppn & ~POWERPC_MMAP_FLAG_MASK)
178#define pmap_mmap_flags(ppn) powerpc_mmap_flags(ppn) 178#define pmap_mmap_flags(ppn) powerpc_mmap_flags(ppn)
179 179
180static __inline paddr_t vtophys (vaddr_t); 180static __inline paddr_t vtophys (vaddr_t);
181 181
182/* 182/*
183 * Alternate mapping hooks for pool pages. Avoids thrashing the TLB. 183 * Alternate mapping hooks for pool pages. Avoids thrashing the TLB.
184 * 184 *
185 * Note: This won't work if we have more memory than can be direct-mapped 185 * Note: This won't work if we have more memory than can be direct-mapped
186 * VA==PA all at once. But pmap_copy_page() and pmap_zero_page() will have 186 * VA==PA all at once. But pmap_copy_page() and pmap_zero_page() will have
187 * this problem, too. 187 * this problem, too.
188 */ 188 */
189#if !defined(PPC_OEA64) && !defined (PPC_OEA64_BRIDGE) 189#if !defined(PPC_OEA64) && !defined (PPC_OEA64_BRIDGE)
190#define PMAP_MAP_POOLPAGE(pa) (pa) 190#define PMAP_MAP_POOLPAGE(pa) (pa)
191#define PMAP_UNMAP_POOLPAGE(pa) (pa) 191#define PMAP_UNMAP_POOLPAGE(pa) (pa)
192#define POOL_VTOPHYS(va) vtophys((vaddr_t) va) 192#define POOL_VTOPHYS(va) vtophys((vaddr_t) va)
193#endif 193#endif
194 194
195static __inline paddr_t 195static __inline paddr_t
196vtophys(vaddr_t va) 196vtophys(vaddr_t va)
197{ 197{
198 paddr_t pa; 198 paddr_t pa;
199 199
200 if (pmap_extract(pmap_kernel(), va, &pa)) 200 if (pmap_extract(pmap_kernel(), va, &pa))
201 return pa; 201 return pa;
202 KASSERTMSG(0, "vtophys: pmap_extract of %#"PRIxVADDR" failed", va); 202 KASSERTMSG(0, "vtophys: pmap_extract of %#"PRIxVADDR" failed", va);
203 return (paddr_t) -1; 203 return (paddr_t) -1;
204} 204}
205 205
206 206
207#ifdef PMAP_NEEDS_FIXUP 207#ifdef PMAP_NEEDS_FIXUP
208extern const struct pmap_ops *pmapops; 208extern const struct pmap_ops *pmapops;
209extern const struct pmap_ops pmap32_ops; 209extern const struct pmap_ops pmap32_ops;
210extern const struct pmap_ops pmap64_ops; 210extern const struct pmap_ops pmap64_ops;
211extern const struct pmap_ops pmap64bridge_ops; 211extern const struct pmap_ops pmap64bridge_ops;
212 212
213static __inline void 213static __inline void
214pmap_setup32(void) 214pmap_setup32(void)
215{ 215{
216 pmapops = &pmap32_ops; 216 pmapops = &pmap32_ops;
217} 217}
218 218
219static __inline void 219static __inline void
220pmap_setup64(void) 220pmap_setup64(void)
221{ 221{
222 pmapops = &pmap64_ops; 222 pmapops = &pmap64_ops;
223} 223}
224 224
225static __inline void 225static __inline void
226pmap_setup64bridge(void) 226pmap_setup64bridge(void)
227{ 227{
228 pmapops = &pmap64bridge_ops; 228 pmapops = &pmap64bridge_ops;
229} 229}
230#endif 230#endif
231 231
232bool pmap_pageidlezero (paddr_t); 232bool pmap_pageidlezero (paddr_t);
233void pmap_syncicache (paddr_t, psize_t); 233void pmap_syncicache (paddr_t, psize_t);
234#ifdef PPC_OEA64 234#ifdef PPC_OEA64
235vaddr_t pmap_setusr (vaddr_t); 235vaddr_t pmap_setusr (vaddr_t);
236vaddr_t pmap_unsetusr (void); 236vaddr_t pmap_unsetusr (void);
237#endif 237#endif
238 238
239#ifdef PPC_OEA64_BRIDGE 239#ifdef PPC_OEA64_BRIDGE
240int pmap_setup_segment0_map(int use_large_pages, ...); 240int pmap_setup_segment0_map(int use_large_pages, ...);
241#endif 241#endif
242 242
243#define PMAP_MD_PREFETCHABLE 0x2000000 243#define PMAP_MD_PREFETCHABLE 0x2000000
244#define PMAP_STEAL_MEMORY 244#define PMAP_STEAL_MEMORY
245#define PMAP_NEED_PROCWR 245#define PMAP_NEED_PROCWR
246 246
247void pmap_zero_page(paddr_t); 247void pmap_zero_page(paddr_t);
248void pmap_copy_page(paddr_t, paddr_t); 248void pmap_copy_page(paddr_t, paddr_t);
249 249
250LIST_HEAD(pvo_head, pvo_entry); 250LIST_HEAD(pvo_head, pvo_entry);
251 251
252#define __HAVE_VM_PAGE_MD 252#define __HAVE_VM_PAGE_MD
253 253
254struct pmap_page { 254struct pmap_page {
255 unsigned int pp_attrs; 255 unsigned int pp_attrs;
256 struct pvo_head pp_pvoh; 256 struct pvo_head pp_pvoh;
257#ifdef MODULAR 257#ifdef MODULAR
258 uintptr_t pp_dummy[3]; 258 uintptr_t pp_dummy[3];
259#endif 259#endif
260}; 260};
261 261
262struct vm_page_md { 262struct vm_page_md {
263 struct pmap_page mdpg_pp; 263 struct pmap_page mdpg_pp;
264#define mdpg_attrs mdpg_pp.pp_attrs 264#define mdpg_attrs mdpg_pp.pp_attrs
265#define mdpg_pvoh mdpg_pp.pp_pvoh 265#define mdpg_pvoh mdpg_pp.pp_pvoh
266#ifdef MODULAR 266#ifdef MODULAR
267#define mdpg_dummy mdpg_pp.pp_dummy 267#define mdpg_dummy mdpg_pp.pp_dummy
268#endif 268#endif
269}; 269};
270 270
271#define VM_MDPAGE_INIT(pg) do { \ 271#define VM_MDPAGE_INIT(pg) do { \
272 (pg)->mdpage.mdpg_attrs = 0; \ 272 (pg)->mdpage.mdpg_attrs = 0; \
273 LIST_INIT(&(pg)->mdpage.mdpg_pvoh); \ 273 LIST_INIT(&(pg)->mdpage.mdpg_pvoh); \
274} while (/*CONSTCOND*/0) 274} while (/*CONSTCOND*/0)
275 275
276__END_DECLS 276__END_DECLS
277#endif /* _KERNEL */ 277#endif /* _KERNEL */
278 278
279#endif /* _POWERPC_OEA_PMAP_H_ */ 279#endif /* _POWERPC_OEA_PMAP_H_ */