pmap.h revision 1.25.4.3 1 1.25.4.3 nathanw /* $NetBSD: pmap.h,v 1.25.4.3 2002/11/11 22:02:53 nathanw Exp $ */
2 1.25.4.2 nathanw
3 1.25.4.2 nathanw /*-
4 1.25.4.2 nathanw * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 1.25.4.2 nathanw * Copyright (C) 1995, 1996 TooLs GmbH.
6 1.25.4.2 nathanw * All rights reserved.
7 1.25.4.2 nathanw *
8 1.25.4.2 nathanw * Redistribution and use in source and binary forms, with or without
9 1.25.4.2 nathanw * modification, are permitted provided that the following conditions
10 1.25.4.2 nathanw * are met:
11 1.25.4.2 nathanw * 1. Redistributions of source code must retain the above copyright
12 1.25.4.2 nathanw * notice, this list of conditions and the following disclaimer.
13 1.25.4.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
14 1.25.4.2 nathanw * notice, this list of conditions and the following disclaimer in the
15 1.25.4.2 nathanw * documentation and/or other materials provided with the distribution.
16 1.25.4.2 nathanw * 3. All advertising materials mentioning features or use of this software
17 1.25.4.2 nathanw * must display the following acknowledgement:
18 1.25.4.2 nathanw * This product includes software developed by TooLs GmbH.
19 1.25.4.2 nathanw * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 1.25.4.2 nathanw * derived from this software without specific prior written permission.
21 1.25.4.2 nathanw *
22 1.25.4.2 nathanw * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 1.25.4.2 nathanw * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.25.4.2 nathanw * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.25.4.2 nathanw * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 1.25.4.2 nathanw * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 1.25.4.2 nathanw * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 1.25.4.2 nathanw * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 1.25.4.2 nathanw * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 1.25.4.2 nathanw * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 1.25.4.2 nathanw * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.25.4.2 nathanw */
33 1.25.4.2 nathanw
34 1.25.4.3 nathanw #ifndef _POWERPC_PMAP_H_
35 1.25.4.3 nathanw #define _POWERPC_PMAP_H_
36 1.25.4.2 nathanw
37 1.25.4.2 nathanw #include <machine/pte.h>
38 1.25.4.2 nathanw
39 1.25.4.2 nathanw /*
40 1.25.4.2 nathanw * Segment registers
41 1.25.4.2 nathanw */
42 1.25.4.2 nathanw #ifndef _LOCORE
43 1.25.4.2 nathanw typedef u_int sr_t;
44 1.25.4.2 nathanw #endif /* _LOCORE */
45 1.25.4.2 nathanw #define SR_TYPE 0x80000000
46 1.25.4.2 nathanw #define SR_SUKEY 0x40000000
47 1.25.4.2 nathanw #define SR_PRKEY 0x20000000
48 1.25.4.2 nathanw #define SR_VSID 0x00ffffff
49 1.25.4.2 nathanw
50 1.25.4.2 nathanw #ifndef _LOCORE
51 1.25.4.2 nathanw /*
52 1.25.4.2 nathanw * Pmap stuff
53 1.25.4.2 nathanw */
54 1.25.4.2 nathanw struct pmap {
55 1.25.4.2 nathanw sr_t pm_sr[16]; /* segments used in this pmap */
56 1.25.4.2 nathanw int pm_refs; /* ref count */
57 1.25.4.2 nathanw struct pmap_statistics pm_stats; /* pmap statistics */
58 1.25.4.2 nathanw };
59 1.25.4.2 nathanw
60 1.25.4.2 nathanw typedef struct pmap *pmap_t;
61 1.25.4.2 nathanw
62 1.25.4.2 nathanw #ifdef _KERNEL
63 1.25.4.2 nathanw extern struct pmap kernel_pmap_;
64 1.25.4.2 nathanw #define pmap_kernel() (&kernel_pmap_)
65 1.25.4.2 nathanw
66 1.25.4.2 nathanw #define pmap_clear_modify(pg) (ptemodify((pg), PTE_CHG, 0))
67 1.25.4.2 nathanw #define pmap_clear_reference(pg) (ptemodify((pg), PTE_REF, 0))
68 1.25.4.2 nathanw #define pmap_is_modified(pg) (ptebits((pg), PTE_CHG))
69 1.25.4.2 nathanw #define pmap_is_referenced(pg) (ptebits((pg), PTE_REF))
70 1.25.4.2 nathanw #define pmap_unwire(pm, va)
71 1.25.4.2 nathanw #define pmap_update(pmap) /* nothing (yet) */
72 1.25.4.2 nathanw
73 1.25.4.2 nathanw static __inline void
74 1.25.4.2 nathanw pmap_remove_all(struct pmap *pmap)
75 1.25.4.2 nathanw {
76 1.25.4.2 nathanw /* Nothing. */
77 1.25.4.2 nathanw }
78 1.25.4.2 nathanw
79 1.25.4.2 nathanw #define pmap_phys_address(x) (x)
80 1.25.4.2 nathanw
81 1.25.4.2 nathanw #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
82 1.25.4.2 nathanw #define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
83 1.25.4.2 nathanw
84 1.25.4.2 nathanw void pmap_bootstrap __P((u_int kernelstart, u_int kernelend));
85 1.25.4.2 nathanw boolean_t pmap_extract __P((struct pmap *, vaddr_t, paddr_t *));
86 1.25.4.2 nathanw boolean_t ptemodify __P((struct vm_page *, u_int, u_int));
87 1.25.4.2 nathanw int ptebits __P((struct vm_page *, int));
88 1.25.4.2 nathanw void pmap_real_memory __P((paddr_t *, psize_t *));
89 1.25.4.2 nathanw void pmap_pinit __P((pmap_t));
90 1.25.4.2 nathanw
91 1.25.4.2 nathanw #define PMAP_NEED_PROCWR
92 1.25.4.2 nathanw void pmap_procwr __P((struct proc *, vaddr_t, size_t));
93 1.25.4.2 nathanw
94 1.25.4.2 nathanw /*
95 1.25.4.2 nathanw * Alternate mapping hooks for pool pages. Avoids thrashing the TLB.
96 1.25.4.2 nathanw *
97 1.25.4.2 nathanw * Note: This won't work if we have more memory than can be direct-mapped
98 1.25.4.2 nathanw * VA==PA all at once. But pmap_copy_page() and pmap_zero_page() will have
99 1.25.4.2 nathanw * this problem, too.
100 1.25.4.2 nathanw */
101 1.25.4.2 nathanw #define PMAP_MAP_POOLPAGE(pa) (pa)
102 1.25.4.2 nathanw #define PMAP_UNMAP_POOLPAGE(pa) (pa)
103 1.25.4.2 nathanw
104 1.25.4.2 nathanw static __inline paddr_t vtophys __P((vaddr_t));
105 1.25.4.2 nathanw
106 1.25.4.2 nathanw static __inline paddr_t
107 1.25.4.2 nathanw vtophys(va)
108 1.25.4.2 nathanw vaddr_t va;
109 1.25.4.2 nathanw {
110 1.25.4.2 nathanw paddr_t pa;
111 1.25.4.2 nathanw
112 1.25.4.2 nathanw /* XXX should check battable */
113 1.25.4.2 nathanw
114 1.25.4.2 nathanw if (pmap_extract(pmap_kernel(), va, &pa))
115 1.25.4.2 nathanw return pa;
116 1.25.4.2 nathanw return va;
117 1.25.4.2 nathanw }
118 1.25.4.2 nathanw
119 1.25.4.2 nathanw #endif /* _KERNEL */
120 1.25.4.2 nathanw #endif /* _LOCORE */
121 1.25.4.2 nathanw
122 1.25.4.3 nathanw #endif /* _POWERPC_PMAP_H_ */
123