This source file includes following definitions.
- kvm_iodevice_init
- kvm_iodevice_read
- kvm_iodevice_write
- kvm_iodevice_destructor
1
2
3 #ifndef __KVM_IODEV_H__
4 #define __KVM_IODEV_H__
5
6 #include <linux/kvm_types.h>
7 #include <linux/errno.h>
8
9 struct kvm_io_device;
10 struct kvm_vcpu;
11
12
13
14
15
16
17 struct kvm_io_device_ops {
18 int (*read)(struct kvm_vcpu *vcpu,
19 struct kvm_io_device *this,
20 gpa_t addr,
21 int len,
22 void *val);
23 int (*write)(struct kvm_vcpu *vcpu,
24 struct kvm_io_device *this,
25 gpa_t addr,
26 int len,
27 const void *val);
28 void (*destructor)(struct kvm_io_device *this);
29 };
30
31
32 struct kvm_io_device {
33 const struct kvm_io_device_ops *ops;
34 };
35
36 static inline void kvm_iodevice_init(struct kvm_io_device *dev,
37 const struct kvm_io_device_ops *ops)
38 {
39 dev->ops = ops;
40 }
41
42 static inline int kvm_iodevice_read(struct kvm_vcpu *vcpu,
43 struct kvm_io_device *dev, gpa_t addr,
44 int l, void *v)
45 {
46 return dev->ops->read ? dev->ops->read(vcpu, dev, addr, l, v)
47 : -EOPNOTSUPP;
48 }
49
50 static inline int kvm_iodevice_write(struct kvm_vcpu *vcpu,
51 struct kvm_io_device *dev, gpa_t addr,
52 int l, const void *v)
53 {
54 return dev->ops->write ? dev->ops->write(vcpu, dev, addr, l, v)
55 : -EOPNOTSUPP;
56 }
57
58 static inline void kvm_iodevice_destructor(struct kvm_io_device *dev)
59 {
60 if (dev->ops->destructor)
61 dev->ops->destructor(dev);
62 }
63
64 #endif