This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / include / xen / interface / memory.h
1 /******************************************************************************
2  * memory.h
3  * 
4  * Memory reservation and information.
5  * 
6  * Copyright (c) 2005, Keir Fraser <keir@xensource.com>
7  */
8
9 #ifndef __XEN_PUBLIC_MEMORY_H__
10 #define __XEN_PUBLIC_MEMORY_H__
11
12 /*
13  * Increase or decrease the specified domain's memory reservation. Returns the
14  * number of extents successfully allocated or freed.
15  * arg == addr of struct xen_memory_reservation.
16  */
17 #define XENMEM_increase_reservation 0
18 #define XENMEM_decrease_reservation 1
19 #define XENMEM_populate_physmap     6
20 struct xen_memory_reservation {
21
22     /*
23      * XENMEM_increase_reservation:
24      *   OUT: MFN (*not* GMFN) bases of extents that were allocated
25      * XENMEM_decrease_reservation:
26      *   IN:  GMFN bases of extents to free
27      * XENMEM_populate_physmap:
28      *   IN:  GPFN bases of extents to populate with memory
29      *   OUT: GMFN bases of extents that were allocated
30      *   (NB. This command also updates the mach_to_phys translation table)
31      */
32     XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
33
34     /* Number of extents, and size/alignment of each (2^extent_order pages). */
35     xen_ulong_t    nr_extents;
36     unsigned int   extent_order;
37
38     /*
39      * Maximum # bits addressable by the user of the allocated region (e.g., 
40      * I/O devices often have a 32-bit limitation even in 64-bit systems). If 
41      * zero then the user has no addressing restriction.
42      * This field is not used by XENMEM_decrease_reservation.
43      */
44     unsigned int   address_bits;
45
46     /*
47      * Domain whose reservation is being changed.
48      * Unprivileged domains can specify only DOMID_SELF.
49      */
50     domid_t        domid;
51 };
52 typedef struct xen_memory_reservation xen_memory_reservation_t;
53 DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t);
54
55 /*
56  * An atomic exchange of memory pages. If return code is zero then
57  * @out.extent_list provides GMFNs of the newly-allocated memory.
58  * Returns zero on complete success, otherwise a negative error code.
59  * On complete success then always @nr_exchanged == @in.nr_extents.
60  * On partial success @nr_exchanged indicates how much work was done.
61  */
62 #define XENMEM_exchange             11
63 struct xen_memory_exchange {
64     /*
65      * [IN] Details of memory extents to be exchanged (GMFN bases).
66      * Note that @in.address_bits is ignored and unused.
67      */
68     struct xen_memory_reservation in;
69
70     /*
71      * [IN/OUT] Details of new memory extents.
72      * We require that:
73      *  1. @in.domid == @out.domid
74      *  2. @in.nr_extents  << @in.extent_order == 
75      *     @out.nr_extents << @out.extent_order
76      *  3. @in.extent_start and @out.extent_start lists must not overlap
77      *  4. @out.extent_start lists GPFN bases to be populated
78      *  5. @out.extent_start is overwritten with allocated GMFN bases
79      */
80     struct xen_memory_reservation out;
81
82     /*
83      * [OUT] Number of input extents that were successfully exchanged:
84      *  1. The first @nr_exchanged input extents were successfully
85      *     deallocated.
86      *  2. The corresponding first entries in the output extent list correctly
87      *     indicate the GMFNs that were successfully exchanged.
88      *  3. All other input and output extents are untouched.
89      *  4. If not all input exents are exchanged then the return code of this
90      *     command will be non-zero.
91      *  5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER!
92      */
93     xen_ulong_t nr_exchanged;
94 };
95 typedef struct xen_memory_exchange xen_memory_exchange_t;
96 DEFINE_XEN_GUEST_HANDLE(xen_memory_exchange_t);
97
98 /*
99  * Returns the maximum machine frame number of mapped RAM in this system.
100  * This command always succeeds (it never returns an error code).
101  * arg == NULL.
102  */
103 #define XENMEM_maximum_ram_page     2
104
105 /*
106  * Returns the current or maximum memory reservation, in pages, of the
107  * specified domain (may be DOMID_SELF). Returns -ve errcode on failure.
108  * arg == addr of domid_t.
109  */
110 #define XENMEM_current_reservation  3
111 #define XENMEM_maximum_reservation  4
112
113 /*
114  * Returns a list of MFN bases of 2MB extents comprising the machine_to_phys
115  * mapping table. Architectures which do not have a m2p table do not implement
116  * this command.
117  * arg == addr of xen_machphys_mfn_list_t.
118  */
119 #define XENMEM_machphys_mfn_list    5
120 struct xen_machphys_mfn_list {
121     /*
122      * Size of the 'extent_start' array. Fewer entries will be filled if the
123      * machphys table is smaller than max_extents * 2MB.
124      */
125     unsigned int max_extents;
126
127     /*
128      * Pointer to buffer to fill with list of extent starts. If there are
129      * any large discontiguities in the machine address space, 2MB gaps in
130      * the machphys table will be represented by an MFN base of zero.
131      */
132     XEN_GUEST_HANDLE(xen_pfn_t) extent_start;
133
134     /*
135      * Number of extents written to the above array. This will be smaller
136      * than 'max_extents' if the machphys table is smaller than max_e * 2MB.
137      */
138     unsigned int nr_extents;
139 };
140 typedef struct xen_machphys_mfn_list xen_machphys_mfn_list_t;
141 DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t);
142
143 /*
144  * Returns the location in virtual address space of the machine_to_phys
145  * mapping table. Architectures which do not have a m2p table, or which do not
146  * map it by default into guest address space, do not implement this command.
147  * arg == addr of xen_machphys_mapping_t.
148  */
149 #define XENMEM_machphys_mapping     12
150 struct xen_machphys_mapping {
151     xen_ulong_t v_start, v_end; /* Start and end virtual addresses.   */
152     xen_ulong_t max_mfn;        /* Maximum MFN that can be looked up. */
153 };
154 typedef struct xen_machphys_mapping xen_machphys_mapping_t;
155 DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
156
157 /*
158  * Sets the GPFN at which a particular page appears in the specified guest's
159  * pseudophysical address space.
160  * arg == addr of xen_add_to_physmap_t.
161  */
162 #define XENMEM_add_to_physmap      7
163 struct xen_add_to_physmap {
164     /* Which domain to change the mapping for. */
165     domid_t domid;
166
167     /* Source mapping space. */
168 #define XENMAPSPACE_shared_info 0 /* shared info page */
169 #define XENMAPSPACE_grant_table 1 /* grant table page */
170     unsigned int space;
171
172     /* Index into source mapping space. */
173     xen_ulong_t idx;
174
175     /* GPFN where the source mapping page should appear. */
176     xen_pfn_t     gpfn;
177 };
178 typedef struct xen_add_to_physmap xen_add_to_physmap_t;
179 DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);
180
181 /*
182  * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
183  * code on failure. This call only works for auto-translated guests.
184  */
185 #define XENMEM_translate_gpfn_list  8
186 struct xen_translate_gpfn_list {
187     /* Which domain to translate for? */
188     domid_t domid;
189
190     /* Length of list. */
191     xen_ulong_t nr_gpfns;
192
193     /* List of GPFNs to translate. */
194     XEN_GUEST_HANDLE(xen_pfn_t) gpfn_list;
195
196     /*
197      * Output list to contain MFN translations. May be the same as the input
198      * list (in which case each input GPFN is overwritten with the output MFN).
199      */
200     XEN_GUEST_HANDLE(xen_pfn_t) mfn_list;
201 };
202 typedef struct xen_translate_gpfn_list xen_translate_gpfn_list_t;
203 DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
204
205 /*
206  * Returns the pseudo-physical memory map as it was when the domain
207  * was started.
208  */
209 #define XENMEM_memory_map           9
210 struct xen_memory_map {
211     /*
212      * On call the number of entries which can be stored in buffer. On
213      * return the number of entries which have been stored in
214      * buffer.
215      */
216     unsigned int nr_entries;
217
218     /*
219      * Entries in the buffer are in the same format as returned by the
220      * BIOS INT 0x15 EAX=0xE820 call.
221      */
222     XEN_GUEST_HANDLE(void) buffer;
223 };
224 typedef struct xen_memory_map xen_memory_map_t;
225 DEFINE_XEN_GUEST_HANDLE(xen_memory_map_t);
226
227 /*
228  * Returns the real physical memory map. Passes the same structure as
229  * XENMEM_memory_map.
230  */
231 #define XENMEM_machine_memory_map       10
232
233 #endif /* __XEN_PUBLIC_MEMORY_H__ */
234
235 /*
236  * Local variables:
237  * mode: C
238  * c-set-style: "BSD"
239  * c-basic-offset: 4
240  * tab-width: 4
241  * indent-tabs-mode: nil
242  * End:
243  */