pmap.h revision 1.17 1 /* $NetBSD: pmap.h,v 1.17 2008/12/09 20:45:44 pooka Exp $ */
2
3 /* $OpenBSD: pmap.h,v 1.14 2001/05/09 15:31:24 art Exp $ */
4
5 /*
6 * Copyright (c) 1998,1999 Michael Shalayeff
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by Michael Shalayeff.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34 /*
35 * Copyright 1996 1995 by Open Software Foundation, Inc.
36 * All Rights Reserved
37 *
38 * Permission to use, copy, modify, and distribute this software and
39 * its documentation for any purpose and without fee is hereby granted,
40 * provided that the above copyright notice appears in all copies and
41 * that both the copyright notice and this permission notice appear in
42 * supporting documentation.
43 *
44 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
45 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
46 * FOR A PARTICULAR PURPOSE.
47 *
48 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
49 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
50 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
51 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
52 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
53 */
54 /*
55 * Copyright (c) 1990,1993,1994 The University of Utah and
56 * the Computer Systems Laboratory at the University of Utah (CSL).
57 * All rights reserved.
58 *
59 * Permission to use, copy, modify and distribute this software is hereby
60 * granted provided that (1) source code retains these copyright, permission,
61 * and disclaimer notices, and (2) redistributions including binaries
62 * reproduce the notices in supporting documentation, and (3) all advertising
63 * materials mentioning features or use of this software display the following
64 * acknowledgement: ``This product includes software developed by the
65 * Computer Systems Laboratory at the University of Utah.''
66 *
67 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
68 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
69 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
70 *
71 * CSL requests users of this software to return to csl-dist (at) cs.utah.edu any
72 * improvements that they make and grant CSL redistribution rights.
73 *
74 * Utah $Hdr: pmap.h 1.24 94/12/14$
75 * Author: Mike Hibler, Bob Wheeler, University of Utah CSL, 9/90
76 */
77
78 /*
79 * Pmap header for hppa.
80 */
81
82 #ifndef _HPPA_PMAP_H_
83 #define _HPPA_PMAP_H_
84
85 #include <sys/simplelock.h>
86 #include <machine/pte.h>
87
88 struct pmap {
89 TAILQ_ENTRY(pmap) pmap_list; /* pmap free list */
90 struct simplelock pmap_lock; /* lock on map */
91 int pmap_refcnt; /* reference count */
92 pa_space_t pmap_space; /* space for this pmap */
93 u_int pmap_pid; /* protection id for pmap */
94 struct pmap_statistics pmap_stats; /* statistics */
95 };
96
97 #ifdef _KERNEL
98
99 #define PMAP_NC 0x100
100
101 #define cache_align(x) (((x) + dcache_line_mask) & ~(dcache_line_mask))
102 extern int dcache_line_mask;
103
104 #define PMAP_STEAL_MEMORY /* we have some memory to steal */
105
106 /*
107 * according to the parisc manual aliased va's should be
108 * different by high 12 bits only.
109 */
110 #define PMAP_PREFER(o,h,s,td) do { \
111 vaddr_t pmap_prefer_hint; \
112 pmap_prefer_hint = (*(h) & HPPA_PGAMASK) | ((o) & HPPA_PGAOFF); \
113 if (pmap_prefer_hint < *(h)) \
114 pmap_prefer_hint += HPPA_PGALIAS; \
115 *(h) = pmap_prefer_hint; \
116 } while(0)
117
118 #define pmap_kernel_va(VA) \
119 (((VA) >= VM_MIN_KERNEL_ADDRESS) && ((VA) <= VM_MAX_KERNEL_ADDRESS))
120
121 #define pmap_resident_count(pmap) ((pmap)->pmap_stats.resident_count)
122 #define pmap_wired_count(pmap) ((pmap)->pmap_stats.wired_count)
123 #define pmap_reference(pmap) \
124 do { if (pmap) { \
125 simple_lock(&pmap->pmap_lock); \
126 pmap->pmap_refcnt++; \
127 simple_unlock(&pmap->pmap_lock); \
128 } } while (0)
129 #define pmap_collect(pmap)
130 #define pmap_release(pmap)
131 #define pmap_copy(dpmap,spmap,da,len,sa)
132 #define pmap_update(p)
133 void pmap_activate(struct lwp *);
134
135 static __inline void
136 pmap_deactivate(struct lwp *l)
137 {
138 }
139
140 #define pmap_phys_address(x) ((x) << PGSHIFT)
141 #define pmap_phys_to_frame(x) ((x) >> PGSHIFT)
142
143 static __inline void
144 pmap_remove_all(struct pmap *pmap)
145 {
146 /* Nothing. */
147 }
148
149 static __inline int
150 pmap_prot(struct pmap *pmap, vm_prot_t prot)
151 {
152 extern u_int kern_prot[], user_prot[];
153
154 return (pmap == pmap_kernel() ? kern_prot : user_prot)[prot];
155 }
156
157 #define pmap_sid(pmap, va) \
158 ((((va) & 0xc0000000) != 0xc0000000) ? \
159 (pmap)->pmap_space : HPPA_SID_KERNEL)
160
161 #endif /* _KERNEL */
162
163 #endif /* _HPPA_PMAP_H_ */
164