debuggers.hg

view freebsd-5.3-xen-sparse/i386-xen/include/xenpmap.h @ 4628:35357e323f14

bitkeeper revision 1.1338 (4266317ezHysqYzH_WRvfueqwU4i4Q)

Grant tables for FreeBSD.
Signed-off-by: Kip Macy <kmacy@fsmware.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Apr 20 10:39:58 2005 +0000 (2005-04-20)
parents 5fd95a1db011
children f9f8f250228f
line source
1 /*
2 *
3 * Copyright (c) 2004 Christian Limpach.
4 * Copyright (c) 2004,2005 Kip Macy
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Christian Limpach.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
34 #ifndef _XEN_XENPMAP_H_
35 #define _XEN_XENPMAP_H_
36 #include <machine/xenvar.h>
37 void xen_invlpg(vm_offset_t);
38 void xen_queue_pt_update(pt_entry_t *, pt_entry_t);
39 void xen_pt_switch(uint32_t);
40 void xen_set_ldt(unsigned long, unsigned long);
41 void xen_tlb_flush(void);
42 void xen_pgd_pin(unsigned long);
43 void xen_pgd_unpin(unsigned long);
44 void xen_pt_pin(unsigned long);
45 void xen_pt_unpin(unsigned long);
46 void xen_flush_queue(void);
47 void pmap_ref(pt_entry_t *pte, unsigned long ma);
50 #ifdef PMAP_DEBUG
51 #define PMAP_REF pmap_ref
52 #define PMAP_DEC_REF_PAGE pmap_dec_ref_page
53 #define PMAP_MARK_PRIV pmap_mark_privileged
54 #define PMAP_MARK_UNPRIV pmap_mark_unprivileged
55 #else
56 #define PMAP_MARK_PRIV(a)
57 #define PMAP_MARK_UNPRIV(a)
58 #define PMAP_REF(a, b)
59 #define PMAP_DEC_REF_PAGE(a)
60 #endif
62 #define ALWAYS_SYNC 0
63 #define PT_DEBUG
65 #ifdef PT_DEBUG
66 #define PT_LOG() printk("WP PT_SET %s:%d\n", __FILE__, __LINE__)
67 #else
68 #define PT_LOG()
69 #endif
71 #define pmap_valid_entry(E) ((E) & PG_V) /* is PDE or PTE valid? */
73 #define PT_GET(_ptp) \
74 (pmap_valid_entry(*(_ptp)) ? xpmap_mtop(*(_ptp)) : *(_ptp))
76 #ifdef WRITABLE_PAGETABLES
77 #define PT_SET_VA(_ptp,_npte,sync) do { \
78 PMAP_REF((_ptp), xpmap_ptom(_npte)); \
79 PT_LOG(); \
80 *(_ptp) = xpmap_ptom((_npte)); \
81 } while (/*CONSTCOND*/0)
82 #define PT_SET_VA_MA(_ptp,_npte,sync) do { \
83 PMAP_REF((_ptp), (_npte)); \
84 PT_LOG(); \
85 *(_ptp) = (_npte); \
86 } while (/*CONSTCOND*/0)
87 #define PT_CLEAR_VA(_ptp, sync) do { \
88 PMAP_REF((pt_entry_t *)(_ptp), 0); \
89 PT_LOG(); \
90 *(_ptp) = 0; \
91 } while (/*CONSTCOND*/0)
93 #define PD_SET_VA(_ptp,_npte,sync) do { \
94 PMAP_REF((_ptp), xpmap_ptom(_npte)); \
95 xen_queue_pt_update((pt_entry_t *)vtomach((_ptp)), \
96 xpmap_ptom((_npte))); \
97 if (sync || ALWAYS_SYNC) xen_flush_queue(); \
98 } while (/*CONSTCOND*/0)
99 #define PD_SET_VA_MA(_ptp,_npte,sync) do { \
100 PMAP_REF((_ptp), (_npte)); \
101 xen_queue_pt_update((pt_entry_t *)vtomach((_ptp)), (_npte)); \
102 if (sync || ALWAYS_SYNC) xen_flush_queue(); \
103 } while (/*CONSTCOND*/0)
104 #define PD_CLEAR_VA(_ptp, sync) do { \
105 PMAP_REF((pt_entry_t *)(_ptp), 0); \
106 xen_queue_pt_update((pt_entry_t *)vtomach(_ptp), 0); \
107 if (sync || ALWAYS_SYNC) xen_flush_queue(); \
108 } while (/*CONSTCOND*/0)
111 #else /* !WRITABLE_PAGETABLES */
113 #define PT_SET_VA(_ptp,_npte,sync) do { \
114 PMAP_REF((_ptp), xpmap_ptom(_npte)); \
115 xen_queue_pt_update((pt_entry_t *)vtomach(_ptp), \
116 xpmap_ptom(_npte)); \
117 if (sync || ALWAYS_SYNC) xen_flush_queue(); \
118 } while (/*CONSTCOND*/0)
119 #define PT_SET_VA_MA(_ptp,_npte,sync) do { \
120 PMAP_REF((_ptp), (_npte)); \
121 xen_queue_pt_update((pt_entry_t *)vtomach(_ptp), _npte);\
122 if (sync || ALWAYS_SYNC) xen_flush_queue(); \
123 } while (/*CONSTCOND*/0)
124 #define PT_CLEAR_VA(_ptp, sync) do { \
125 PMAP_REF((pt_entry_t *)(_ptp), 0); \
126 xen_queue_pt_update((pt_entry_t *)vtomach(_ptp), 0); \
127 if (sync || ALWAYS_SYNC) \
128 xen_flush_queue(); \
129 } while (/*CONSTCOND*/0)
131 #define PD_SET_VA PT_SET_VA
132 #define PD_SET_VA_MA PT_SET_VA_MA
133 #define PD_CLEAR_VA PT_CLEAR_VA
135 #endif
137 #define PT_SET_MA(_va, _ma) \
138 HYPERVISOR_update_va_mapping(((unsigned long)_va), \
139 ((unsigned long)_ma), \
140 UVMF_INVLPG| UVMF_LOCAL)\
142 #define PT_UPDATES_FLUSH() do { \
143 xen_flush_queue(); \
144 } while (/*CONSTCOND*/0)
147 static __inline uint32_t
148 xpmap_mtop(uint32_t mpa)
149 {
150 return (((xen_machine_phys[(mpa >> PAGE_SHIFT)]) << PAGE_SHIFT)
151 | (mpa & ~PG_FRAME));
152 }
154 static __inline vm_paddr_t
155 xpmap_ptom(uint32_t ppa)
156 {
157 return phystomach(ppa) | (ppa & ~PG_FRAME);
158 }
160 #endif /* _XEN_XENPMAP_H_ */