]>
Commit | Line | Data |
---|---|---|
eaa7115d LE |
1 | /** @file\r |
2 | Type and macro definitions specific to the Virtio Filesystem device.\r | |
3 | \r | |
4 | At the time of this writing, the latest released Virtio specification (v1.1)\r | |
5 | does not include the virtio-fs device. The development version of the\r | |
6 | specification defines it however; see the latest version at\r | |
7 | <https://github.com/oasis-tcs/virtio-spec/blob/87fa6b5d8155/virtio-fs.tex>.\r | |
8 | \r | |
9 | This header file is minimal, and only defines the types and macros that are\r | |
10 | necessary for the OvmfPkg implementation.\r | |
11 | \r | |
12 | Copyright (C) 2020, Red Hat, Inc.\r | |
13 | \r | |
14 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
15 | **/\r | |
16 | \r | |
17 | #ifndef VIRTIO_FS_H_\r | |
18 | #define VIRTIO_FS_H_\r | |
19 | \r | |
20 | #include <IndustryStandard/Virtio.h>\r | |
21 | \r | |
22 | //\r | |
23 | // Lowest numbered queue for sending normal priority requests.\r | |
24 | //\r | |
25 | #define VIRTIO_FS_REQUEST_QUEUE 1\r | |
26 | \r | |
27 | //\r | |
28 | // Number of bytes in the "VIRTIO_FS_CONFIG.Tag" field.\r | |
29 | //\r | |
30 | #define VIRTIO_FS_TAG_BYTES 36\r | |
31 | \r | |
32 | //\r | |
33 | // Device configuration layout.\r | |
34 | //\r | |
35 | #pragma pack (1)\r | |
36 | typedef struct {\r | |
37 | //\r | |
38 | // The Tag field can be considered the filesystem label, or a mount point\r | |
39 | // hint. It is UTF-8 encoded, and padded to full size with NUL bytes. If the\r | |
40 | // encoded bytes take up the entire Tag field, then there is no NUL\r | |
41 | // terminator.\r | |
42 | //\r | |
43 | UINT8 Tag[VIRTIO_FS_TAG_BYTES];\r | |
44 | //\r | |
45 | // The total number of request virtqueues exposed by the device (i.e.,\r | |
46 | // excluding the "hiprio" queue).\r | |
47 | //\r | |
48 | UINT32 NumReqQueues;\r | |
49 | } VIRTIO_FS_CONFIG;\r | |
50 | #pragma pack ()\r | |
51 | \r | |
6a2dc768 LE |
52 | //\r |
53 | // FUSE-related definitions follow.\r | |
54 | //\r | |
55 | // From virtio-v1.1-cs01-87fa6b5d8155, 5.11 File System Device: "[...] The\r | |
56 | // driver acts as the FUSE client mounting the file system. The virtio file\r | |
57 | // system device provides the mechanism for transporting FUSE requests [...]"\r | |
58 | //\r | |
59 | // Unfortunately, the documentation of the FUSE wire protocol is lacking. The\r | |
60 | // Virtio spec (as of this writing) simply defers to\r | |
61 | // "include/uapi/linux/fuse.h" in the Linux kernel source -- see the reference\r | |
62 | // in virtio spec file "introduction.tex", at commit 87fa6b5d8155.\r | |
63 | //\r | |
64 | // Of course, "include/uapi/linux/fuse.h" is a moving target (the virtio spec\r | |
65 | // does not specify a particular FUSE interface version). The OvmfPkg code\r | |
66 | // targets version 7.31, because that's the lowest version that the QEMU\r | |
67 | // virtio-fs daemon supports at this time -- see QEMU commit 72c42e2d6551\r | |
68 | // ("virtiofsd: Trim out compatibility code", 2020-01-23).\r | |
69 | //\r | |
70 | // Correspondingly, Linux's "include/uapi/linux/fuse.h" is consulted as checked\r | |
71 | // out at commit (c6ff213fe5b8^) = d78092e4937d ("fuse: fix page dereference\r | |
72 | // after free", 2020-09-18); that is, right before commit c6ff213fe5b8 ("fuse:\r | |
73 | // add submount support to <uapi/linux/fuse.h>", 2020-09-18) introduces FUSE\r | |
74 | // interface version 7.32.\r | |
75 | //\r | |
76 | #define VIRTIO_FS_FUSE_MAJOR 7\r | |
77 | #define VIRTIO_FS_FUSE_MINOR 31\r | |
78 | \r | |
fa97e372 LE |
79 | //\r |
80 | // FUSE operation codes.\r | |
81 | //\r | |
82 | typedef enum {\r | |
72d4f133 | 83 | VirtioFsFuseOpRelease = 18,\r |
fa97e372 | 84 | VirtioFsFuseOpInit = 26,\r |
b62a0c56 | 85 | VirtioFsFuseOpOpenDir = 27,\r |
72d4f133 | 86 | VirtioFsFuseOpReleaseDir = 29,\r |
fa97e372 LE |
87 | } VIRTIO_FS_FUSE_OPCODE;\r |
88 | \r | |
6a2dc768 LE |
89 | #pragma pack (1)\r |
90 | //\r | |
91 | // Request-response headers common to all request types.\r | |
92 | //\r | |
93 | typedef struct {\r | |
94 | UINT32 Len;\r | |
95 | UINT32 Opcode;\r | |
96 | UINT64 Unique;\r | |
97 | UINT64 NodeId;\r | |
98 | UINT32 Uid;\r | |
99 | UINT32 Gid;\r | |
100 | UINT32 Pid;\r | |
101 | UINT32 Padding;\r | |
102 | } VIRTIO_FS_FUSE_REQUEST;\r | |
103 | \r | |
104 | typedef struct {\r | |
105 | UINT32 Len;\r | |
106 | INT32 Error;\r | |
107 | UINT64 Unique;\r | |
108 | } VIRTIO_FS_FUSE_RESPONSE;\r | |
fa97e372 | 109 | \r |
72d4f133 LE |
110 | //\r |
111 | // Header for VirtioFsFuseOpRelease and VirtioFsFuseOpReleaseDir.\r | |
112 | //\r | |
113 | typedef struct {\r | |
114 | UINT64 FileHandle;\r | |
115 | UINT32 Flags;\r | |
116 | UINT32 ReleaseFlags;\r | |
117 | UINT64 LockOwner;\r | |
118 | } VIRTIO_FS_FUSE_RELEASE_REQUEST;\r | |
119 | \r | |
fa97e372 LE |
120 | //\r |
121 | // Headers for VirtioFsFuseOpInit.\r | |
122 | //\r | |
123 | typedef struct {\r | |
124 | UINT32 Major;\r | |
125 | UINT32 Minor;\r | |
126 | UINT32 MaxReadahead;\r | |
127 | UINT32 Flags;\r | |
128 | } VIRTIO_FS_FUSE_INIT_REQUEST;\r | |
129 | \r | |
130 | typedef struct {\r | |
131 | UINT32 Major;\r | |
132 | UINT32 Minor;\r | |
133 | UINT32 MaxReadahead;\r | |
134 | UINT32 Flags;\r | |
135 | UINT16 MaxBackground;\r | |
136 | UINT16 CongestionThreshold;\r | |
137 | UINT32 MaxWrite;\r | |
138 | UINT32 TimeGran;\r | |
139 | UINT16 MaxPages;\r | |
140 | UINT16 MapAlignment;\r | |
141 | UINT32 Unused[8];\r | |
142 | } VIRTIO_FS_FUSE_INIT_RESPONSE;\r | |
b62a0c56 LE |
143 | \r |
144 | //\r | |
145 | // Headers for VirtioFsFuseOpOpenDir.\r | |
146 | //\r | |
147 | typedef struct {\r | |
148 | UINT32 Flags;\r | |
149 | UINT32 Unused;\r | |
150 | } VIRTIO_FS_FUSE_OPEN_REQUEST;\r | |
151 | \r | |
152 | typedef struct {\r | |
153 | UINT64 FileHandle;\r | |
154 | UINT32 OpenFlags;\r | |
155 | UINT32 Padding;\r | |
156 | } VIRTIO_FS_FUSE_OPEN_RESPONSE;\r | |
6a2dc768 LE |
157 | #pragma pack ()\r |
158 | \r | |
eaa7115d | 159 | #endif // VIRTIO_FS_H_\r |