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