]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/xen/interface/tmem.h
MFV r345495:
[FreeBSD/FreeBSD.git] / sys / xen / interface / tmem.h
1 /******************************************************************************
2  * tmem.h
3  * 
4  * Guest OS interface to Xen Transcendent Memory.
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) 2004, K A Fraser
25  */
26
27 #ifndef __XEN_PUBLIC_TMEM_H__
28 #define __XEN_PUBLIC_TMEM_H__
29
30 #include "xen.h"
31
32 /* version of ABI */
33 #define TMEM_SPEC_VERSION          1
34
35 /* Commands to HYPERVISOR_tmem_op() */
36 #ifdef __XEN__
37 #define TMEM_CONTROL               0 /* Now called XEN_SYSCTL_tmem_op */
38 #else
39 #undef TMEM_CONTROL
40 #endif
41 #define TMEM_NEW_POOL              1
42 #define TMEM_DESTROY_POOL          2
43 #define TMEM_PUT_PAGE              4
44 #define TMEM_GET_PAGE              5
45 #define TMEM_FLUSH_PAGE            6
46 #define TMEM_FLUSH_OBJECT          7
47 #if __XEN_INTERFACE_VERSION__ < 0x00040400
48 #define TMEM_NEW_PAGE              3
49 #define TMEM_READ                  8
50 #define TMEM_WRITE                 9
51 #define TMEM_XCHG                 10
52 #endif
53
54 /* Privileged commands to HYPERVISOR_tmem_op() */
55 #define TMEM_AUTH                 101
56 #define TMEM_RESTORE_NEW          102
57
58 /* Bits for HYPERVISOR_tmem_op(TMEM_NEW_POOL) */
59 #define TMEM_POOL_PERSIST          1
60 #define TMEM_POOL_SHARED           2
61 #define TMEM_POOL_PRECOMPRESSED    4
62 #define TMEM_POOL_PAGESIZE_SHIFT   4
63 #define TMEM_POOL_PAGESIZE_MASK  0xf
64 #define TMEM_POOL_VERSION_SHIFT   24
65 #define TMEM_POOL_VERSION_MASK  0xff
66 #define TMEM_POOL_RESERVED_BITS  0x00ffff00
67
68 /* Bits for client flags (save/restore) */
69 #define TMEM_CLIENT_COMPRESS       1
70 #define TMEM_CLIENT_FROZEN         2
71
72 /* Special errno values */
73 #define EFROZEN                 1000
74 #define EEMPTY                  1001
75
76 struct xen_tmem_oid {
77     uint64_t oid[3];
78 };
79 typedef struct xen_tmem_oid xen_tmem_oid_t;
80 DEFINE_XEN_GUEST_HANDLE(xen_tmem_oid_t);
81
82 #ifndef __ASSEMBLY__
83 #if __XEN_INTERFACE_VERSION__ < 0x00040400
84 typedef xen_pfn_t tmem_cli_mfn_t;
85 #endif
86 typedef XEN_GUEST_HANDLE(char) tmem_cli_va_t;
87 struct tmem_op {
88     uint32_t cmd;
89     int32_t pool_id;
90     union {
91         struct {
92             uint64_t uuid[2];
93             uint32_t flags;
94             uint32_t arg1;
95         } creat; /* for cmd == TMEM_NEW_POOL, TMEM_AUTH, TMEM_RESTORE_NEW */
96         struct {
97 #if __XEN_INTERFACE_VERSION__ < 0x00040600
98             uint64_t oid[3];
99 #else
100             xen_tmem_oid_t oid;
101 #endif
102             uint32_t index;
103             uint32_t tmem_offset;
104             uint32_t pfn_offset;
105             uint32_t len;
106             xen_pfn_t cmfn; /* client machine page frame */
107         } gen; /* for all other cmd ("generic") */
108     } u;
109 };
110 typedef struct tmem_op tmem_op_t;
111 DEFINE_XEN_GUEST_HANDLE(tmem_op_t);
112 #endif
113
114 #endif /* __XEN_PUBLIC_TMEM_H__ */
115
116 /*
117  * Local variables:
118  * mode: C
119  * c-file-style: "BSD"
120  * c-basic-offset: 4
121  * tab-width: 4
122  * indent-tabs-mode: nil
123  * End:
124  */