xref: /freebsd/sys/contrib/xen/hypfs.h (revision 3a9fd8242b35884921dfc4e886f284a75870a536)
1*3a9fd824SRoger Pau Monné /******************************************************************************
2*3a9fd824SRoger Pau Monné  * Xen Hypervisor Filesystem
3*3a9fd824SRoger Pau Monné  *
4*3a9fd824SRoger Pau Monné  * Copyright (c) 2019, SUSE Software Solutions Germany GmbH
5*3a9fd824SRoger Pau Monné  *
6*3a9fd824SRoger Pau Monné  * Permission is hereby granted, free of charge, to any person obtaining a copy
7*3a9fd824SRoger Pau Monné  * of this software and associated documentation files (the "Software"), to
8*3a9fd824SRoger Pau Monné  * deal in the Software without restriction, including without limitation the
9*3a9fd824SRoger Pau Monné  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10*3a9fd824SRoger Pau Monné  * sell copies of the Software, and to permit persons to whom the Software is
11*3a9fd824SRoger Pau Monné  * furnished to do so, subject to the following conditions:
12*3a9fd824SRoger Pau Monné  *
13*3a9fd824SRoger Pau Monné  * The above copyright notice and this permission notice shall be included in
14*3a9fd824SRoger Pau Monné  * all copies or substantial portions of the Software.
15*3a9fd824SRoger Pau Monné  *
16*3a9fd824SRoger Pau Monné  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*3a9fd824SRoger Pau Monné  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*3a9fd824SRoger Pau Monné  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19*3a9fd824SRoger Pau Monné  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20*3a9fd824SRoger Pau Monné  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21*3a9fd824SRoger Pau Monné  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22*3a9fd824SRoger Pau Monné  * DEALINGS IN THE SOFTWARE.
23*3a9fd824SRoger Pau Monné  *
24*3a9fd824SRoger Pau Monné  */
25*3a9fd824SRoger Pau Monné 
26*3a9fd824SRoger Pau Monné #ifndef __XEN_PUBLIC_HYPFS_H__
27*3a9fd824SRoger Pau Monné #define __XEN_PUBLIC_HYPFS_H__
28*3a9fd824SRoger Pau Monné 
29*3a9fd824SRoger Pau Monné #include "xen.h"
30*3a9fd824SRoger Pau Monné 
31*3a9fd824SRoger Pau Monné /*
32*3a9fd824SRoger Pau Monné  * Definitions for the __HYPERVISOR_hypfs_op hypercall.
33*3a9fd824SRoger Pau Monné  */
34*3a9fd824SRoger Pau Monné 
35*3a9fd824SRoger Pau Monné /* Highest version number of the hypfs interface currently defined. */
36*3a9fd824SRoger Pau Monné #define XEN_HYPFS_VERSION      1
37*3a9fd824SRoger Pau Monné 
38*3a9fd824SRoger Pau Monné /* Maximum length of a path in the filesystem. */
39*3a9fd824SRoger Pau Monné #define XEN_HYPFS_MAX_PATHLEN  1024
40*3a9fd824SRoger Pau Monné 
41*3a9fd824SRoger Pau Monné struct xen_hypfs_direntry {
42*3a9fd824SRoger Pau Monné     uint8_t type;
43*3a9fd824SRoger Pau Monné #define XEN_HYPFS_TYPE_DIR     0
44*3a9fd824SRoger Pau Monné #define XEN_HYPFS_TYPE_BLOB    1
45*3a9fd824SRoger Pau Monné #define XEN_HYPFS_TYPE_STRING  2
46*3a9fd824SRoger Pau Monné #define XEN_HYPFS_TYPE_UINT    3
47*3a9fd824SRoger Pau Monné #define XEN_HYPFS_TYPE_INT     4
48*3a9fd824SRoger Pau Monné #define XEN_HYPFS_TYPE_BOOL    5
49*3a9fd824SRoger Pau Monné     uint8_t encoding;
50*3a9fd824SRoger Pau Monné #define XEN_HYPFS_ENC_PLAIN    0
51*3a9fd824SRoger Pau Monné #define XEN_HYPFS_ENC_GZIP     1
52*3a9fd824SRoger Pau Monné     uint16_t pad;              /* Returned as 0. */
53*3a9fd824SRoger Pau Monné     uint32_t content_len;      /* Current length of data. */
54*3a9fd824SRoger Pau Monné     uint32_t max_write_len;    /* Max. length for writes (0 if read-only). */
55*3a9fd824SRoger Pau Monné };
56*3a9fd824SRoger Pau Monné typedef struct xen_hypfs_direntry xen_hypfs_direntry_t;
57*3a9fd824SRoger Pau Monné 
58*3a9fd824SRoger Pau Monné struct xen_hypfs_dirlistentry {
59*3a9fd824SRoger Pau Monné     xen_hypfs_direntry_t e;
60*3a9fd824SRoger Pau Monné     /* Offset in bytes to next entry (0 == this is the last entry). */
61*3a9fd824SRoger Pau Monné     uint16_t off_next;
62*3a9fd824SRoger Pau Monné     /* Zero terminated entry name, possibly with some padding for alignment. */
63*3a9fd824SRoger Pau Monné     char name[XEN_FLEX_ARRAY_DIM];
64*3a9fd824SRoger Pau Monné };
65*3a9fd824SRoger Pau Monné 
66*3a9fd824SRoger Pau Monné /*
67*3a9fd824SRoger Pau Monné  * Hypercall operations.
68*3a9fd824SRoger Pau Monné  */
69*3a9fd824SRoger Pau Monné 
70*3a9fd824SRoger Pau Monné /*
71*3a9fd824SRoger Pau Monné  * XEN_HYPFS_OP_get_version
72*3a9fd824SRoger Pau Monné  *
73*3a9fd824SRoger Pau Monné  * Read highest interface version supported by the hypervisor.
74*3a9fd824SRoger Pau Monné  *
75*3a9fd824SRoger Pau Monné  * arg1 - arg4: all 0/NULL
76*3a9fd824SRoger Pau Monné  *
77*3a9fd824SRoger Pau Monné  * Possible return values:
78*3a9fd824SRoger Pau Monné  * >0: highest supported interface version
79*3a9fd824SRoger Pau Monné  * <0: negative Xen errno value
80*3a9fd824SRoger Pau Monné  */
81*3a9fd824SRoger Pau Monné #define XEN_HYPFS_OP_get_version     0
82*3a9fd824SRoger Pau Monné 
83*3a9fd824SRoger Pau Monné /*
84*3a9fd824SRoger Pau Monné  * XEN_HYPFS_OP_read
85*3a9fd824SRoger Pau Monné  *
86*3a9fd824SRoger Pau Monné  * Read a filesystem entry.
87*3a9fd824SRoger Pau Monné  *
88*3a9fd824SRoger Pau Monné  * Returns the direntry and contents of an entry in the buffer supplied by the
89*3a9fd824SRoger Pau Monné  * caller (struct xen_hypfs_direntry with the contents following directly
90*3a9fd824SRoger Pau Monné  * after it).
91*3a9fd824SRoger Pau Monné  * The data buffer must be at least the size of the direntry returned. If the
92*3a9fd824SRoger Pau Monné  * data buffer was not large enough for all the data -ENOBUFS and no entry
93*3a9fd824SRoger Pau Monné  * data is returned, but the direntry will contain the needed size for the
94*3a9fd824SRoger Pau Monné  * returned data.
95*3a9fd824SRoger Pau Monné  * The format of the contents is according to its entry type and encoding.
96*3a9fd824SRoger Pau Monné  * The contents of a directory are multiple struct xen_hypfs_dirlistentry
97*3a9fd824SRoger Pau Monné  * items.
98*3a9fd824SRoger Pau Monné  *
99*3a9fd824SRoger Pau Monné  * arg1: XEN_GUEST_HANDLE(path name)
100*3a9fd824SRoger Pau Monné  * arg2: length of path name (including trailing zero byte)
101*3a9fd824SRoger Pau Monné  * arg3: XEN_GUEST_HANDLE(data buffer written by hypervisor)
102*3a9fd824SRoger Pau Monné  * arg4: data buffer size
103*3a9fd824SRoger Pau Monné  *
104*3a9fd824SRoger Pau Monné  * Possible return values:
105*3a9fd824SRoger Pau Monné  * 0: success
106*3a9fd824SRoger Pau Monné  * <0 : negative Xen errno value
107*3a9fd824SRoger Pau Monné  */
108*3a9fd824SRoger Pau Monné #define XEN_HYPFS_OP_read              1
109*3a9fd824SRoger Pau Monné 
110*3a9fd824SRoger Pau Monné /*
111*3a9fd824SRoger Pau Monné  * XEN_HYPFS_OP_write_contents
112*3a9fd824SRoger Pau Monné  *
113*3a9fd824SRoger Pau Monné  * Write contents of a filesystem entry.
114*3a9fd824SRoger Pau Monné  *
115*3a9fd824SRoger Pau Monné  * Writes an entry with the contents of a buffer supplied by the caller.
116*3a9fd824SRoger Pau Monné  * The data type and encoding can't be changed. The size can be changed only
117*3a9fd824SRoger Pau Monné  * for blobs and strings.
118*3a9fd824SRoger Pau Monné  *
119*3a9fd824SRoger Pau Monné  * arg1: XEN_GUEST_HANDLE(path name)
120*3a9fd824SRoger Pau Monné  * arg2: length of path name (including trailing zero byte)
121*3a9fd824SRoger Pau Monné  * arg3: XEN_GUEST_HANDLE(content buffer read by hypervisor)
122*3a9fd824SRoger Pau Monné  * arg4: content buffer size
123*3a9fd824SRoger Pau Monné  *
124*3a9fd824SRoger Pau Monné  * Possible return values:
125*3a9fd824SRoger Pau Monné  * 0: success
126*3a9fd824SRoger Pau Monné  * <0 : negative Xen errno value
127*3a9fd824SRoger Pau Monné  */
128*3a9fd824SRoger Pau Monné #define XEN_HYPFS_OP_write_contents    2
129*3a9fd824SRoger Pau Monné 
130*3a9fd824SRoger Pau Monné #endif /* __XEN_PUBLIC_HYPFS_H__ */
131