Annotation of Gnu-Mach/xen/public/memory.h, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.