No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / xen / include / xenpmap.h
blob652454d7c071f3ba496cc129866dcda2a6036297
1 /* $NetBSD: xenpmap.h,v 1.23 2009/07/29 12:02:06 cegger Exp $ */
3 /*
5 * Copyright (c) 2004 Christian Limpach.
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef _XEN_XENPMAP_H_
31 #define _XEN_XENPMAP_H_
32 #include "opt_xen.h"
34 #define INVALID_P2M_ENTRY (~0UL)
36 void xpq_queue_machphys_update(paddr_t, paddr_t);
37 void xpq_queue_invlpg(vaddr_t);
38 void xpq_queue_pte_update(paddr_t, pt_entry_t);
39 void xpq_queue_pt_switch(paddr_t);
40 void xpq_flush_queue(void);
41 void xpq_queue_set_ldt(vaddr_t, uint32_t);
42 void xpq_queue_tlb_flush(void);
43 void xpq_queue_pin_table(paddr_t);
44 void xpq_queue_unpin_table(paddr_t);
45 int xpq_update_foreign(paddr_t, pt_entry_t, int);
47 extern unsigned long *xpmap_phys_to_machine_mapping;
49 /*
50 * On Xen-2, the start of the day virtual memory starts at KERNTEXTOFF
51 * (0xc0100000). On Xen-3 for domain0 it starts at KERNBASE (0xc0000000).
52 * So the offset between physical and virtual address is different on
53 * Xen-2 and Xen-3 for domain0.
54 * starting with xen-3.0.2, we can add notes so that virtual memory starts
55 * at KERNBASE for domU as well.
56 */
57 #if defined(DOM0OPS) || !defined(XEN_COMPAT_030001)
58 #define XPMAP_OFFSET 0
59 #else
60 #define XPMAP_OFFSET (KERNTEXTOFF - KERNBASE)
61 #endif
63 #define mfn_to_pfn(mfn) (machine_to_phys_mapping[(mfn)])
64 #define pfn_to_mfn(pfn) (xpmap_phys_to_machine_mapping[(pfn)])
66 static __inline paddr_t
67 xpmap_mtop(paddr_t mpa)
69 return (
70 ((paddr_t)machine_to_phys_mapping[mpa >> PAGE_SHIFT] << PAGE_SHIFT)
71 + XPMAP_OFFSET) | (mpa & ~PG_FRAME);
74 static __inline paddr_t
75 xpmap_mtop_masked(paddr_t mpa)
77 return (
78 ((paddr_t)machine_to_phys_mapping[mpa >> PAGE_SHIFT] << PAGE_SHIFT)
79 + XPMAP_OFFSET);
82 static __inline paddr_t
83 xpmap_ptom(paddr_t ppa)
85 return (((paddr_t)xpmap_phys_to_machine_mapping[(ppa -
86 XPMAP_OFFSET) >> PAGE_SHIFT]) << PAGE_SHIFT)
87 | (ppa & ~PG_FRAME);
90 static __inline paddr_t
91 xpmap_ptom_masked(paddr_t ppa)
93 return (((paddr_t)xpmap_phys_to_machine_mapping[(ppa -
94 XPMAP_OFFSET) >> PAGE_SHIFT]) << PAGE_SHIFT);
97 static inline void
98 MULTI_update_va_mapping(
99 multicall_entry_t *mcl, vaddr_t va,
100 pt_entry_t new_val, unsigned long flags)
102 mcl->op = __HYPERVISOR_update_va_mapping;
103 mcl->args[0] = va;
104 #if defined(__x86_64__)
105 mcl->args[1] = new_val;
106 mcl->args[2] = flags;
107 #else
108 mcl->args[1] = (new_val & 0xffffffff);
109 #ifdef PAE
110 mcl->args[2] = (new_val >> 32);
111 #else
112 mcl->args[2] = 0;
113 #endif
114 mcl->args[3] = flags;
115 #endif
118 static inline void
119 MULTI_update_va_mapping_otherdomain(
120 multicall_entry_t *mcl, vaddr_t va,
121 pt_entry_t new_val, unsigned long flags, domid_t domid)
123 mcl->op = __HYPERVISOR_update_va_mapping_otherdomain;
124 mcl->args[0] = va;
125 #if defined(__x86_64__)
126 mcl->args[1] = new_val;
127 mcl->args[2] = flags;
128 mcl->args[3] = domid;
129 #else
130 mcl->args[1] = (new_val & 0xffffffff);
131 #ifdef PAE
132 mcl->args[2] = (new_val >> 32);
133 #else
134 mcl->args[2] = 0;
135 #endif
136 mcl->args[3] = flags;
137 mcl->args[4] = domid;
138 #endif
140 #if defined(__x86_64__)
141 #define MULTI_UVMFLAGS_INDEX 2
142 #define MULTI_UVMDOMID_INDEX 3
143 #else
144 #define MULTI_UVMFLAGS_INDEX 3
145 #define MULTI_UVMDOMID_INDEX 4
146 #endif
148 #if defined(__x86_64__)
149 void xen_set_user_pgd(paddr_t);
150 #endif
152 #endif /* _XEN_XENPMAP_H_ */