Deleted Added
full compact
pmap.h (160525) pmap.h (195149)
1/*-
2 * Copyright (c) 1991 Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * the Systems Programming Group of the University of Utah Computer
7 * Science Department and William Jolitz of UUNET Technologies Inc.
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 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
34 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
35 * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/30
1/*-
2 * Copyright (c) 1991 Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * the Systems Programming Group of the University of Utah Computer
7 * Science Department and William Jolitz of UUNET Technologies Inc.
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 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
34 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
35 * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/30
36 * $FreeBSD: head/sys/sparc64/include/pmap.h 160525 2006-07-20 17:48:41Z alc $
36 * $FreeBSD: head/sys/sparc64/include/pmap.h 195149 2009-06-28 22:42:51Z marius $
37 */
38
39#ifndef _MACHINE_PMAP_H_
40#define _MACHINE_PMAP_H_
41
42#include <sys/queue.h>
43#include <sys/_lock.h>
44#include <sys/_mutex.h>
45#include <machine/cache.h>
46#include <machine/tte.h>
47
48#define PMAP_CONTEXT_MAX 8192
49
50typedef struct pmap *pmap_t;
51
52struct md_page {
53 TAILQ_HEAD(, tte) tte_list;
54 struct pmap *pmap;
55 uint32_t colors[DCACHE_COLORS];
56 int32_t color;
57 uint32_t flags;
58};
59
60struct pmap {
61 struct mtx pm_mtx;
62 struct tte *pm_tsb;
63 vm_object_t pm_tsb_obj;
64 u_int pm_active;
65 u_int pm_context[MAXCPU];
66 struct pmap_statistics pm_stats;
67};
68
69#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx)
70#define PMAP_LOCK_ASSERT(pmap, type) \
71 mtx_assert(&(pmap)->pm_mtx, (type))
72#define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx)
73#define PMAP_LOCK_INIT(pmap) mtx_init(&(pmap)->pm_mtx, "pmap", \
74 NULL, MTX_DEF | MTX_DUPOK)
75#define PMAP_LOCKED(pmap) mtx_owned(&(pmap)->pm_mtx)
76#define PMAP_MTX(pmap) (&(pmap)->pm_mtx)
77#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx)
78#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx)
79
37 */
38
39#ifndef _MACHINE_PMAP_H_
40#define _MACHINE_PMAP_H_
41
42#include <sys/queue.h>
43#include <sys/_lock.h>
44#include <sys/_mutex.h>
45#include <machine/cache.h>
46#include <machine/tte.h>
47
48#define PMAP_CONTEXT_MAX 8192
49
50typedef struct pmap *pmap_t;
51
52struct md_page {
53 TAILQ_HEAD(, tte) tte_list;
54 struct pmap *pmap;
55 uint32_t colors[DCACHE_COLORS];
56 int32_t color;
57 uint32_t flags;
58};
59
60struct pmap {
61 struct mtx pm_mtx;
62 struct tte *pm_tsb;
63 vm_object_t pm_tsb_obj;
64 u_int pm_active;
65 u_int pm_context[MAXCPU];
66 struct pmap_statistics pm_stats;
67};
68
69#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx)
70#define PMAP_LOCK_ASSERT(pmap, type) \
71 mtx_assert(&(pmap)->pm_mtx, (type))
72#define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx)
73#define PMAP_LOCK_INIT(pmap) mtx_init(&(pmap)->pm_mtx, "pmap", \
74 NULL, MTX_DEF | MTX_DUPOK)
75#define PMAP_LOCKED(pmap) mtx_owned(&(pmap)->pm_mtx)
76#define PMAP_MTX(pmap) (&(pmap)->pm_mtx)
77#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx)
78#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx)
79
80void pmap_bootstrap(vm_offset_t ekva);
80void pmap_bootstrap(void);
81vm_paddr_t pmap_kextract(vm_offset_t va);
82void pmap_kenter(vm_offset_t va, vm_page_t m);
83void pmap_kremove(vm_offset_t);
84void pmap_kenter_flags(vm_offset_t va, vm_paddr_t pa, u_long flags);
85void pmap_kremove_flags(vm_offset_t va);
86boolean_t pmap_page_is_mapped(vm_page_t m);
87
88int pmap_cache_enter(vm_page_t m, vm_offset_t va);
89void pmap_cache_remove(vm_page_t m, vm_offset_t va);
90
91int pmap_remove_tte(struct pmap *pm1, struct pmap *pm2, struct tte *tp,
92 vm_offset_t va);
93int pmap_protect_tte(struct pmap *pm1, struct pmap *pm2, struct tte *tp,
94 vm_offset_t va);
95
96void pmap_map_tsb(void);
97
98#define vtophys(va) pmap_kextract((vm_offset_t)(va))
99
100extern struct pmap kernel_pmap_store;
101#define kernel_pmap (&kernel_pmap_store)
102extern vm_paddr_t phys_avail[];
103extern vm_offset_t virtual_avail;
104extern vm_offset_t virtual_end;
105
81vm_paddr_t pmap_kextract(vm_offset_t va);
82void pmap_kenter(vm_offset_t va, vm_page_t m);
83void pmap_kremove(vm_offset_t);
84void pmap_kenter_flags(vm_offset_t va, vm_paddr_t pa, u_long flags);
85void pmap_kremove_flags(vm_offset_t va);
86boolean_t pmap_page_is_mapped(vm_page_t m);
87
88int pmap_cache_enter(vm_page_t m, vm_offset_t va);
89void pmap_cache_remove(vm_page_t m, vm_offset_t va);
90
91int pmap_remove_tte(struct pmap *pm1, struct pmap *pm2, struct tte *tp,
92 vm_offset_t va);
93int pmap_protect_tte(struct pmap *pm1, struct pmap *pm2, struct tte *tp,
94 vm_offset_t va);
95
96void pmap_map_tsb(void);
97
98#define vtophys(va) pmap_kextract((vm_offset_t)(va))
99
100extern struct pmap kernel_pmap_store;
101#define kernel_pmap (&kernel_pmap_store)
102extern vm_paddr_t phys_avail[];
103extern vm_offset_t virtual_avail;
104extern vm_offset_t virtual_end;
105
106extern vm_paddr_t msgbuf_phys;
107
108#ifdef PMAP_STATS
109
110SYSCTL_DECL(_debug_pmap_stats);
111
112#define PMAP_STATS_VAR(name) \
113 static long name; \
114 SYSCTL_LONG(_debug_pmap_stats, OID_AUTO, name, CTLFLAG_RW, \
115 &name, 0, "")
116
117#define PMAP_STATS_INC(var) \
118 atomic_add_long(&var, 1)
119
120#else
121
122#define PMAP_STATS_VAR(name)
123#define PMAP_STATS_INC(var)
124
125#endif
126
127#endif /* !_MACHINE_PMAP_H_ */
106#ifdef PMAP_STATS
107
108SYSCTL_DECL(_debug_pmap_stats);
109
110#define PMAP_STATS_VAR(name) \
111 static long name; \
112 SYSCTL_LONG(_debug_pmap_stats, OID_AUTO, name, CTLFLAG_RW, \
113 &name, 0, "")
114
115#define PMAP_STATS_INC(var) \
116 atomic_add_long(&var, 1)
117
118#else
119
120#define PMAP_STATS_VAR(name)
121#define PMAP_STATS_INC(var)
122
123#endif
124
125#endif /* !_MACHINE_PMAP_H_ */