aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/public/tmem.h
blob: 74bd1c65a03382f484bfeb1450032d42d8229ce9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/******************************************************************************
 * tmem.h
 * 
 * Guest OS interface to Xen Transcendent Memory.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 * Copyright (c) 2004, K A Fraser
 */

#ifndef __XEN_PUBLIC_TMEM_H__
#define __XEN_PUBLIC_TMEM_H__

#include "xen.h"

/* version of ABI */
#define TMEM_SPEC_VERSION          1

/* Commands to HYPERVISOR_tmem_op() */
#define TMEM_CONTROL               0
#define TMEM_NEW_POOL              1
#define TMEM_DESTROY_POOL          2
#define TMEM_NEW_PAGE              3
#define TMEM_PUT_PAGE              4
#define TMEM_GET_PAGE              5
#define TMEM_FLUSH_PAGE            6
#define TMEM_FLUSH_OBJECT          7
#define TMEM_READ                  8
#define TMEM_WRITE                 9
#define TMEM_XCHG                 10

/* Privileged commands to HYPERVISOR_tmem_op() */
#define TMEM_AUTH                 101 
#define TMEM_RESTORE_NEW          102

/* Subops for HYPERVISOR_tmem_op(TMEM_CONTROL) */
#define TMEMC_THAW                   0
#define TMEMC_FREEZE                 1
#define TMEMC_FLUSH                  2
#define TMEMC_DESTROY                3
#define TMEMC_LIST                   4
#define TMEMC_SET_WEIGHT             5
#define TMEMC_SET_CAP                6
#define TMEMC_SET_COMPRESS           7
#define TMEMC_QUERY_FREEABLE_MB      8
#define TMEMC_SAVE_BEGIN             10
#define TMEMC_SAVE_GET_VERSION       11
#define TMEMC_SAVE_GET_MAXPOOLS      12
#define TMEMC_SAVE_GET_CLIENT_WEIGHT 13
#define TMEMC_SAVE_GET_CLIENT_CAP    14
#define TMEMC_SAVE_GET_CLIENT_FLAGS  15
#define TMEMC_SAVE_GET_POOL_FLAGS    16
#define TMEMC_SAVE_GET_POOL_NPAGES   17
#define TMEMC_SAVE_GET_POOL_UUID     18
#define TMEMC_SAVE_GET_NEXT_PAGE     19
#define TMEMC_SAVE_GET_NEXT_INV      20
#define TMEMC_SAVE_END               21
#define TMEMC_RESTORE_BEGIN          30
#define TMEMC_RESTORE_PUT_PAGE       32
#define TMEMC_RESTORE_FLUSH_PAGE     33

/* Bits for HYPERVISOR_tmem_op(TMEM_NEW_POOL) */
#define TMEM_POOL_PERSIST          1
#define TMEM_POOL_SHARED           2
#define TMEM_POOL_PRECOMPRESSED    4
#define TMEM_POOL_PAGESIZE_SHIFT   4
#define TMEM_POOL_PAGESIZE_MASK  0xf
#define TMEM_POOL_VERSION_SHIFT   24
#define TMEM_POOL_VERSION_MASK  0xff
#define TMEM_POOL_RESERVED_BITS  0x00ffff00

/* Bits for client flags (save/restore) */
#define TMEM_CLIENT_COMPRESS       1
#define TMEM_CLIENT_FROZEN         2

/* Special errno values */
#define EFROZEN                 1000
#define EEMPTY                  1001


#ifndef __ASSEMBLY__
typedef xen_pfn_t tmem_cli_mfn_t;
typedef XEN_GUEST_HANDLE(char) tmem_cli_va_t;
struct tmem_op {
    uint32_t cmd;
    int32_t pool_id;
    union {
        struct {
            uint64_t uuid[2];
            uint32_t flags;
            uint32_t arg1;
        } creat; /* for cmd == TMEM_NEW_POOL, TMEM_AUTH, TMEM_RESTORE_NEW */
        struct { 
            uint32_t subop;
            uint32_t cli_id;
            uint32_t arg1;
            uint32_t arg2;
            uint64_t oid[3];
            tmem_cli_va_t buf;
        } ctrl; /* for cmd == TMEM_CONTROL */
        struct {
            
            uint64_t oid[3];
            uint32_t index;
            uint32_t tmem_offset;
            uint32_t pfn_offset;
            uint32_t len;
            tmem_cli_mfn_t cmfn; /* client machine page frame */
        } gen; /* for all other cmd ("generic") */
    } u;
};
typedef struct tmem_op tmem_op_t;
DEFINE_XEN_GUEST_HANDLE(tmem_op_t);

struct tmem_handle {
    uint32_t pool_id;
    uint32_t index;
    uint64_t oid[3];
};
#endif

#endif /* __XEN_PUBLIC_TMEM_H__ */

/*
 * Local variables:
 * mode: C
 * c-set-style: "BSD"
 * c-basic-offset: 4
 * tab-width: 4
 * indent-tabs-mode: nil
 * End:
 */