pmap.h revision 1.16 1 /* $NetBSD: pmap.h,v 1.16 2008/01/06 13:27:20 dsl 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 typedef
89 struct pmap {
90 TAILQ_ENTRY(pmap) pmap_list; /* pmap free list */
91 struct simplelock pmap_lock; /* lock on map */
92 int pmap_refcnt; /* reference count */
93 pa_space_t pmap_space; /* space for this pmap */
94 u_int pmap_pid; /* protection id for pmap */
95 struct pmap_statistics pmap_stats; /* statistics */
96 } *pmap_t;
97 extern pmap_t kernel_pmap; /* The kernel's map */
98
99 #ifdef _KERNEL
100
101 #define PMAP_NC 0x100
102
103 #define cache_align(x) (((x) + dcache_line_mask) & ~(dcache_line_mask))
104 extern int dcache_line_mask;
105
106 #define PMAP_STEAL_MEMORY /* we have some memory to steal */
107
108 /*
109 * according to the parisc manual aliased va's should be
110 * different by high 12 bits only.
111 */
112 #define PMAP_PREFER(o,h,s,td) do { \
113 vaddr_t pmap_prefer_hint; \
114 pmap_prefer_hint = (*(h) & HPPA_PGAMASK) | ((o) & HPPA_PGAOFF); \
115 if (pmap_prefer_hint < *(h)) \
116 pmap_prefer_hint += HPPA_PGALIAS; \
117 *(h) = pmap_prefer_hint; \
118 } while(0)
119
120 #define pmap_kernel_va(VA) \
121 (((VA) >= VM_MIN_KERNEL_ADDRESS) && ((VA) <= VM_MAX_KERNEL_ADDRESS))
122
123 #define pmap_kernel() (kernel_pmap)
124 #define pmap_resident_count(pmap) ((pmap)->pmap_stats.resident_count)
125 #define pmap_wired_count(pmap) ((pmap)->pmap_stats.wired_count)
126 #define pmap_reference(pmap) \
127 do { if (pmap) { \
128 simple_lock(&pmap->pmap_lock); \
129 pmap->pmap_refcnt++; \
130 simple_unlock(&pmap->pmap_lock); \
131 } } while (0)
132 #define pmap_collect(pmap)
133 #define pmap_release(pmap)
134 #define pmap_copy(dpmap,spmap,da,len,sa)
135 #define pmap_update(p)
136 void pmap_activate(struct lwp *);
137
138 static __inline void
139 pmap_deactivate(struct lwp *l)
140 {
141 }
142
143 #define pmap_phys_address(x) ((x) << PGSHIFT)
144 #define pmap_phys_to_frame(x) ((x) >> PGSHIFT)
145
146 static __inline void
147 pmap_remove_all(struct pmap *pmap)
148 {
149 /* Nothing. */
150 }
151
152 static __inline int
153 pmap_prot(struct pmap *pmap, vm_prot_t prot)
154 {
155 extern u_int kern_prot[], user_prot[];
156
157 return (pmap == kernel_pmap ? kern_prot : user_prot)[prot];
158 }
159
160 #define pmap_sid(pmap, va) \
161 ((((va) & 0xc0000000) != 0xc0000000) ? \
162 (pmap)->pmap_space : HPPA_SID_KERNEL)
163
164 #endif /* _KERNEL */
165
166 #endif /* _HPPA_PMAP_H_ */
167