diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2014-12-15 16:47:07 -0500 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2014-12-15 16:49:19 -0500 |
commit | 2d7ce0e8a704d1aedc4462817a4eade1c3b00fbe (patch) | |
tree | 2a1bbc31ee8c6c8fd11e62c5923245d9c9153ba7 /tools | |
parent | d71de9ec6ba806104439d3a669befda84757b5af (diff) |
tools/virtio: more stubs
As usual, add more stubs to fix test build after main
codebase changes.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/virtio/linux/virtio.h | 1 | ||||
-rw-r--r-- | tools/virtio/linux/virtio_byteorder.h | 8 | ||||
-rw-r--r-- | tools/virtio/linux/virtio_config.h | 70 | ||||
-rw-r--r-- | tools/virtio/uapi/linux/virtio_types.h | 1 | ||||
-rw-r--r-- | tools/virtio/virtio_test.c | 1 |
5 files changed, 79 insertions, 2 deletions
diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h index 8eb6421761cd..a3e07016a440 100644 --- a/tools/virtio/linux/virtio.h +++ b/tools/virtio/linux/virtio.h | |||
@@ -6,6 +6,7 @@ | |||
6 | /* TODO: empty stubs for now. Broken but enough for virtio_ring.c */ | 6 | /* TODO: empty stubs for now. Broken but enough for virtio_ring.c */ |
7 | #define list_add_tail(a, b) do {} while (0) | 7 | #define list_add_tail(a, b) do {} while (0) |
8 | #define list_del(a) do {} while (0) | 8 | #define list_del(a) do {} while (0) |
9 | #define list_for_each_entry(a, b, c) while (0) | ||
9 | /* end of stubs */ | 10 | /* end of stubs */ |
10 | 11 | ||
11 | struct virtio_device { | 12 | struct virtio_device { |
diff --git a/tools/virtio/linux/virtio_byteorder.h b/tools/virtio/linux/virtio_byteorder.h new file mode 100644 index 000000000000..9de9e6ac1d10 --- /dev/null +++ b/tools/virtio/linux/virtio_byteorder.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef _LINUX_VIRTIO_BYTEORDER_STUB_H | ||
2 | #define _LINUX_VIRTIO_BYTEORDER_STUB_H | ||
3 | |||
4 | #include <asm/byteorder.h> | ||
5 | #include "../../include/linux/byteorder/generic.h" | ||
6 | #include "../../include/linux/virtio_byteorder.h" | ||
7 | |||
8 | #endif | ||
diff --git a/tools/virtio/linux/virtio_config.h b/tools/virtio/linux/virtio_config.h index 83b27e8e9d72..806d683ab107 100644 --- a/tools/virtio/linux/virtio_config.h +++ b/tools/virtio/linux/virtio_config.h | |||
@@ -1,6 +1,72 @@ | |||
1 | #define VIRTIO_TRANSPORT_F_START 28 | 1 | #include <linux/virtio_byteorder.h> |
2 | #define VIRTIO_TRANSPORT_F_END 32 | 2 | #include <linux/virtio.h> |
3 | #include <uapi/linux/virtio_config.h> | ||
4 | |||
5 | /* | ||
6 | * __virtio_test_bit - helper to test feature bits. For use by transports. | ||
7 | * Devices should normally use virtio_has_feature, | ||
8 | * which includes more checks. | ||
9 | * @vdev: the device | ||
10 | * @fbit: the feature bit | ||
11 | */ | ||
12 | static inline bool __virtio_test_bit(const struct virtio_device *vdev, | ||
13 | unsigned int fbit) | ||
14 | { | ||
15 | return vdev->features & (1ULL << fbit); | ||
16 | } | ||
17 | |||
18 | /** | ||
19 | * __virtio_set_bit - helper to set feature bits. For use by transports. | ||
20 | * @vdev: the device | ||
21 | * @fbit: the feature bit | ||
22 | */ | ||
23 | static inline void __virtio_set_bit(struct virtio_device *vdev, | ||
24 | unsigned int fbit) | ||
25 | { | ||
26 | vdev->features |= (1ULL << fbit); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * __virtio_clear_bit - helper to clear feature bits. For use by transports. | ||
31 | * @vdev: the device | ||
32 | * @fbit: the feature bit | ||
33 | */ | ||
34 | static inline void __virtio_clear_bit(struct virtio_device *vdev, | ||
35 | unsigned int fbit) | ||
36 | { | ||
37 | vdev->features &= ~(1ULL << fbit); | ||
38 | } | ||
3 | 39 | ||
4 | #define virtio_has_feature(dev, feature) \ | 40 | #define virtio_has_feature(dev, feature) \ |
5 | (__virtio_test_bit((dev), feature)) | 41 | (__virtio_test_bit((dev), feature)) |
6 | 42 | ||
43 | static inline u16 virtio16_to_cpu(struct virtio_device *vdev, __virtio16 val) | ||
44 | { | ||
45 | return __virtio16_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
46 | } | ||
47 | |||
48 | static inline __virtio16 cpu_to_virtio16(struct virtio_device *vdev, u16 val) | ||
49 | { | ||
50 | return __cpu_to_virtio16(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
51 | } | ||
52 | |||
53 | static inline u32 virtio32_to_cpu(struct virtio_device *vdev, __virtio32 val) | ||
54 | { | ||
55 | return __virtio32_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
56 | } | ||
57 | |||
58 | static inline __virtio32 cpu_to_virtio32(struct virtio_device *vdev, u32 val) | ||
59 | { | ||
60 | return __cpu_to_virtio32(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
61 | } | ||
62 | |||
63 | static inline u64 virtio64_to_cpu(struct virtio_device *vdev, __virtio64 val) | ||
64 | { | ||
65 | return __virtio64_to_cpu(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
66 | } | ||
67 | |||
68 | static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val) | ||
69 | { | ||
70 | return __cpu_to_virtio64(virtio_has_feature(vdev, VIRTIO_F_VERSION_1), val); | ||
71 | } | ||
72 | |||
diff --git a/tools/virtio/uapi/linux/virtio_types.h b/tools/virtio/uapi/linux/virtio_types.h new file mode 100644 index 000000000000..e7a1096e7c97 --- /dev/null +++ b/tools/virtio/uapi/linux/virtio_types.h | |||
@@ -0,0 +1 @@ | |||
#include "../../include/uapi/linux/virtio_types.h" | |||
diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c index db3437c641a6..67873c30c5bf 100644 --- a/tools/virtio/virtio_test.c +++ b/tools/virtio/virtio_test.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <sys/types.h> | 11 | #include <sys/types.h> |
12 | #include <fcntl.h> | 12 | #include <fcntl.h> |
13 | #include <stdbool.h> | 13 | #include <stdbool.h> |
14 | #include <linux/virtio_types.h> | ||
14 | #include <linux/vhost.h> | 15 | #include <linux/vhost.h> |
15 | #include <linux/virtio.h> | 16 | #include <linux/virtio.h> |
16 | #include <linux/virtio_ring.h> | 17 | #include <linux/virtio_ring.h> |