Deleted Added
full compact
virtio.h (238072) virtio.h (238360)
1/*-
2 * This header is BSD licensed so anyone can use the definitions to implement
3 * compatible drivers/servers.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
1/*-
2 * This header is BSD licensed so anyone can use the definitions to implement
3 * compatible drivers/servers.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/dev/virtio/virtio.h 238072 2012-07-03 15:15:41Z obrien $
28 * $FreeBSD: head/sys/dev/virtio/virtio.h 238360 2012-07-11 02:57:19Z grehan $
29 */
30
31#ifndef _VIRTIO_H_
32#define _VIRTIO_H_
33
34struct vq_alloc_info;
35
36/* VirtIO device IDs. */

--- 49 unchanged lines hidden (view full) ---

86 */
87#define VIRTIO_MAX_INDIRECT ((int) (PAGE_SIZE / 16))
88
89/*
90 * VirtIO instance variables indices.
91 */
92#define VIRTIO_IVAR_DEVTYPE 1
93#define VIRTIO_IVAR_FEATURE_DESC 2
29 */
30
31#ifndef _VIRTIO_H_
32#define _VIRTIO_H_
33
34struct vq_alloc_info;
35
36/* VirtIO device IDs. */

--- 49 unchanged lines hidden (view full) ---

86 */
87#define VIRTIO_MAX_INDIRECT ((int) (PAGE_SIZE / 16))
88
89/*
90 * VirtIO instance variables indices.
91 */
92#define VIRTIO_IVAR_DEVTYPE 1
93#define VIRTIO_IVAR_FEATURE_DESC 2
94#define VIRTIO_IVAR_VENDOR 3
95#define VIRTIO_IVAR_DEVICE 4
96#define VIRTIO_IVAR_SUBVENDOR 5
97#define VIRTIO_IVAR_SUBDEVICE 6
94
95struct virtio_feature_desc {
96 uint64_t vfd_val;
97 char *vfd_str;
98};
99
100const char *virtio_device_name(uint16_t devid);
98
99struct virtio_feature_desc {
100 uint64_t vfd_val;
101 char *vfd_str;
102};
103
104const char *virtio_device_name(uint16_t devid);
101int virtio_get_device_type(device_t dev);
102void virtio_set_feature_desc(device_t dev,
103 struct virtio_feature_desc *feature_desc);
104void virtio_describe(device_t dev, const char *msg,
105 uint64_t features, struct virtio_feature_desc *feature_desc);
106
107/*
108 * VirtIO Bus Methods.
109 */
105void virtio_describe(device_t dev, const char *msg,
106 uint64_t features, struct virtio_feature_desc *feature_desc);
107
108/*
109 * VirtIO Bus Methods.
110 */
111void virtio_read_ivar(device_t dev, int ivar, uintptr_t *val);
112void virtio_write_ivar(device_t dev, int ivar, uintptr_t val);
110uint64_t virtio_negotiate_features(device_t dev, uint64_t child_features);
111int virtio_alloc_virtqueues(device_t dev, int flags, int nvqs,
112 struct vq_alloc_info *info);
113int virtio_setup_intr(device_t dev, enum intr_type type);
114int virtio_with_feature(device_t dev, uint64_t feature);
115void virtio_stop(device_t dev);
116int virtio_reinit(device_t dev, uint64_t features);
117void virtio_reinit_complete(device_t dev);

--- 25 unchanged lines hidden (view full) ---

143{ \
144 virtio_write_device_config(dev, offset, &val, sizeof(type)); \
145}
146
147VIRTIO_RDWR_DEVICE_CONFIG(1, uint8_t);
148VIRTIO_RDWR_DEVICE_CONFIG(2, uint16_t);
149VIRTIO_RDWR_DEVICE_CONFIG(4, uint32_t);
150
113uint64_t virtio_negotiate_features(device_t dev, uint64_t child_features);
114int virtio_alloc_virtqueues(device_t dev, int flags, int nvqs,
115 struct vq_alloc_info *info);
116int virtio_setup_intr(device_t dev, enum intr_type type);
117int virtio_with_feature(device_t dev, uint64_t feature);
118void virtio_stop(device_t dev);
119int virtio_reinit(device_t dev, uint64_t features);
120void virtio_reinit_complete(device_t dev);

--- 25 unchanged lines hidden (view full) ---

146{ \
147 virtio_write_device_config(dev, offset, &val, sizeof(type)); \
148}
149
150VIRTIO_RDWR_DEVICE_CONFIG(1, uint8_t);
151VIRTIO_RDWR_DEVICE_CONFIG(2, uint16_t);
152VIRTIO_RDWR_DEVICE_CONFIG(4, uint32_t);
153
154#define VIRTIO_READ_IVAR(name, ivar) \
155static inline int \
156__CONCAT(virtio_get_,name)(device_t dev) \
157{ \
158 uintptr_t val; \
159 virtio_read_ivar(dev, ivar, &val); \
160 return ((int) val); \
161}
162
163VIRTIO_READ_IVAR(device_type, VIRTIO_IVAR_DEVTYPE);
164VIRTIO_READ_IVAR(vendor, VIRTIO_IVAR_VENDOR);
165VIRTIO_READ_IVAR(device, VIRTIO_IVAR_DEVICE);
166VIRTIO_READ_IVAR(subvendor, VIRTIO_IVAR_SUBVENDOR);
167VIRTIO_READ_IVAR(subdevice, VIRTIO_IVAR_SUBDEVICE);
168
169#define VIRTIO_WRITE_IVAR(name, ivar) \
170static inline void \
171__CONCAT(virtio_set_,name)(device_t dev, void *val) \
172{ \
173 virtio_write_ivar(dev, ivar, (uintptr_t) val); \
174}
175
176VIRTIO_WRITE_IVAR(feature_desc, VIRTIO_IVAR_FEATURE_DESC);
177
151#endif /* _VIRTIO_H_ */
178#endif /* _VIRTIO_H_ */