Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / xen / include / xen3-public / memory.h
blobabc4cd12dffa116d3e71ff2cea25d6e5d1f82608
1 /* $NetBSD: memory.h,v 1.5 2007/10/17 19:58:30 garbled Exp $ */
2 /******************************************************************************
3 * memory.h
4 *
5 * Memory reservation and information.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to
9 * deal in the Software without restriction, including without limitation the
10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
25 * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
28 #ifndef __XEN_PUBLIC_MEMORY_H__
29 #define __XEN_PUBLIC_MEMORY_H__
32 * Increase or decrease the specified domain's memory reservation. Returns the
33 * number of extents successfully allocated or freed.
34 * arg == addr of struct xen_memory_reservation.
36 #define XENMEM_increase_reservation 0
37 #define XENMEM_decrease_reservation 1
38 #define XENMEM_populate_physmap 6
40 #if __XEN_INTERFACE_VERSION__ >= 0x00030209
42 * Maximum # bits addressable by the user of the allocated region (e.g., I/O
43 * devices often have a 32-bit limitation even in 64-bit systems). If zero
44 * then the user has no addressing restriction. This field is not used by
45 * XENMEM_decrease_reservation.
47 #define XENMEMF_address_bits(x) (x)
48 #define XENMEMF_get_address_bits(x) ((x) & 0xffu)
49 /* NUMA node to allocate from. */
50 #define XENMEMF_node(x) (((x) + 1) << 8)
51 #define XENMEMF_get_node(x) ((((x) >> 8) - 1) & 0xffu)
52 #endif
54 struct xen_memory_reservation {
57 * XENMEM_increase_reservation:
58 * OUT: MFN (*not* GMFN) bases of extents that were allocated
59 * XENMEM_decrease_reservation:
60 * IN: GMFN bases of extents to free
61 * XENMEM_populate_physmap:
62 * IN: GPFN bases of extents to populate with memory
63 * OUT: GMFN bases of extents that were allocated
64 * (NB. This command also updates the mach_to_phys translation table)
66 XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
68 /* Number of extents, and size/alignment of each (2^extent_order pages). */
69 xen_ulong_t nr_extents;
70 unsigned int extent_order;
72 #if __XEN_INTERFACE_VERSION__ >= 0x00030209
73 /* XENMEMF flags. */
74 unsigned int mem_flags;
75 #else
76 unsigned int address_bits;
77 #endif
80 * Domain whose reservation is being changed.
81 * Unprivileged domains can specify only DOMID_SELF.
83 domid_t domid;
85 typedef struct xen_memory_reservation xen_memory_reservation_t;
86 DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t);
89 * An atomic exchange of memory pages. If return code is zero then
90 * @out.extent_list provides GMFNs of the newly-allocated memory.
91 * Returns zero on complete success, otherwise a negative error code.
92 * On complete success then always @nr_exchanged == @in.nr_extents.
93 * On partial success @nr_exchanged indicates how much work was done.
95 #define XENMEM_exchange 11
96 struct xen_memory_exchange {
98 * [IN] Details of memory extents to be exchanged (GMFN bases).
99 * Note that @in.address_bits is ignored and unused.
101 struct xen_memory_reservation in;
104 * [IN/OUT] Details of new memory extents.
105 * We require that:
106 * 1. @in.domid == @out.domid
107 * 2. @in.nr_extents << @in.extent_order ==
108 * @out.nr_extents << @out.extent_order
109 * 3. @in.extent_start and @out.extent_start lists must not overlap
110 * 4. @out.extent_start lists GPFN bases to be populated
111 * 5. @out.extent_start is overwritten with allocated GMFN bases
113 struct xen_memory_reservation out;
116 * [OUT] Number of input extents that were successfully exchanged:
117 * 1. The first @nr_exchanged input extents were successfully
118 * deallocated.
119 * 2. The corresponding first entries in the output extent list correctly
120 * indicate the GMFNs that were successfully exchanged.
121 * 3. All other input and output extents are untouched.
122 * 4. If not all input exents are exchanged then the return code of this
123 * command will be non-zero.
124 * 5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER!
126 xen_ulong_t nr_exchanged;
128 typedef struct xen_memory_exchange xen_memory_exchange_t;
129 DEFINE_XEN_GUEST_HANDLE(xen_memory_exchange_t);
132 * Returns the maximum machine frame number of mapped RAM in this system.
133 * This command always succeeds (it never returns an error code).
134 * arg == NULL.
136 #define XENMEM_maximum_ram_page 2
139 * Returns the current or maximum memory reservation, in pages, of the
140 * specified domain (may be DOMID_SELF). Returns -ve errcode on failure.
141 * arg == addr of domid_t.
143 #define XENMEM_current_reservation 3
144 #define XENMEM_maximum_reservation 4
147 * Returns the maximum GPFN in use by the guest, or -ve errcode on failure.
149 #define XENMEM_maximum_gpfn 14
152 * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
153 * mapping table. Architectures which do not have a m2p table do not implement
154 * this command.
155 * arg == addr of xen_machphys_mfn_list_t.
157 #define XENMEM_machphys_mfn_list 5
158 struct xen_machphys_mfn_list {
160 * Size of the 'extent_start' array. Fewer entries will be filled if the
161 * machphys table is smaller than max_extents * 2MB.
163 unsigned int max_extents;
166 * Pointer to buffer to fill with list of extent starts. If there are
167 * any large discontiguities in the machine address space, 2MB gaps in
168 * the machphys table will be represented by an MFN base of zero.
170 XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
173 * Number of extents written to the above array. This will be smaller
174 * than 'max_extents' if the machphys table is smaller than max_e * 2MB.
176 unsigned int nr_extents;
178 typedef struct xen_machphys_mfn_list xen_machphys_mfn_list_t;
179 DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t);
182 * Returns the location in virtual address space of the machine_to_phys
183 * mapping table. Architectures which do not have a m2p table, or which do not
184 * map it by default into guest address space, do not implement this command.
185 * arg == addr of xen_machphys_mapping_t.
187 #define XENMEM_machphys_mapping 12
188 struct xen_machphys_mapping {
189 xen_ulong_t v_start, v_end; /* Start and end virtual addresses. */
190 xen_ulong_t max_mfn; /* Maximum MFN that can be looked up. */
192 typedef struct xen_machphys_mapping xen_machphys_mapping_t;
193 DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
196 * Sets the GPFN at which a particular page appears in the specified guest's
197 * pseudophysical address space.
198 * arg == addr of xen_add_to_physmap_t.
200 #define XENMEM_add_to_physmap 7
201 struct xen_add_to_physmap {
202 /* Which domain to change the mapping for. */
203 domid_t domid;
205 /* Source mapping space. */
206 #define XENMAPSPACE_shared_info 0 /* shared info page */
207 #define XENMAPSPACE_grant_table 1 /* grant table page */
208 unsigned int space;
210 /* Index into source mapping space. */
211 xen_ulong_t idx;
213 /* GPFN where the source mapping page should appear. */
214 xen_pfn_t gpfn;
216 typedef struct xen_add_to_physmap xen_add_to_physmap_t;
217 DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);
220 * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
221 * code on failure. This call only works for auto-translated guests.
223 #define XENMEM_translate_gpfn_list 8
224 struct xen_translate_gpfn_list {
225 /* Which domain to translate for? */
226 domid_t domid;
228 /* Length of list. */
229 xen_ulong_t nr_gpfns;
231 /* List of GPFNs to translate. */
232 XEN_GUEST_HANDLE(xen_pfn_t) gpfn_list;
235 * Output list to contain MFN translations. May be the same as the input
236 * list (in which case each input GPFN is overwritten with the output MFN).
238 XEN_GUEST_HANDLE(xen_pfn_t) mfn_list;
240 typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t;
241 DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
244 * Returns the pseudo-physical memory map as it was when the domain
245 * was started (specified by XENMEM_set_memory_map).
246 * arg == addr of xen_memory_map_t.
248 #define XENMEM_memory_map 9
249 struct xen_memory_map {
251 * On call the number of entries which can be stored in buffer. On
252 * return the number of entries which have been stored in
253 * buffer.
255 unsigned int nr_entries;
258 * Entries in the buffer are in the same format as returned by the
259 * BIOS INT 0x15 EAX=0xE820 call.
261 XEN_GUEST_HANDLE(void) buffer;
263 typedef struct xen_memory_map xen_memory_map_t;
264 DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t);
267 * Returns the real physical memory map. Passes the same structure as
268 * XENMEM_memory_map.
269 * arg == addr of xen_memory_map_t.
271 #define XENMEM_machine_memory_map 10
274 * Set the pseudo-physical memory map of a domain, as returned by
275 * XENMEM_memory_map.
276 * arg == addr of xen_foreign_memory_map_t.
278 #define XENMEM_set_memory_map 13
279 struct xen_foreign_memory_map {
280 domid_t domid;
281 struct xen_memory_map map;
283 typedef struct xen_foreign_memory_map xen_foreign_memory_map_t;
284 DEFINE_XEN_GUEST_HANDLE(xen_foreign_memory_map_t);
286 #endif /* __XEN_PUBLIC_MEMORY_H__ */
289 * Local variables:
290 * mode: C
291 * c-set-style: "BSD"
292 * c-basic-offset: 4
293 * tab-width: 4
294 * indent-tabs-mode: nil
295 * End: