Blame view
virt/kvm/iodev.h
1.94 KB
e2174021c KVM: Portability:... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __KVM_IODEV_H__ #define __KVM_IODEV_H__ |
edf884172 KVM: Move arch de... |
18 |
#include <linux/kvm_types.h> |
bda9020e2 KVM: remove in_ra... |
19 |
#include <asm/errno.h> |
e2174021c KVM: Portability:... |
20 |
|
d76685c4a KVM: cleanup io_d... |
21 |
struct kvm_io_device; |
69fa2d786 KVM: document loc... |
22 23 |
/** * kvm_io_device_ops are called under kvm slots_lock. |
bda9020e2 KVM: remove in_ra... |
24 25 |
* read and write handlers return 0 if the transaction has been handled, * or non-zero to have it passed to the next device. |
69fa2d786 KVM: document loc... |
26 |
**/ |
d76685c4a KVM: cleanup io_d... |
27 |
struct kvm_io_device_ops { |
bda9020e2 KVM: remove in_ra... |
28 29 30 31 32 |
int (*read)(struct kvm_io_device *this, gpa_t addr, int len, void *val); int (*write)(struct kvm_io_device *this, |
e2174021c KVM: Portability:... |
33 34 |
gpa_t addr, int len, |
bda9020e2 KVM: remove in_ra... |
35 |
const void *val); |
e2174021c KVM: Portability:... |
36 |
void (*destructor)(struct kvm_io_device *this); |
d76685c4a KVM: cleanup io_d... |
37 |
}; |
e2174021c KVM: Portability:... |
38 |
|
d76685c4a KVM: cleanup io_d... |
39 40 |
struct kvm_io_device { const struct kvm_io_device_ops *ops; |
e2174021c KVM: Portability:... |
41 |
}; |
d76685c4a KVM: cleanup io_d... |
42 43 44 45 46 |
static inline void kvm_iodevice_init(struct kvm_io_device *dev, const struct kvm_io_device_ops *ops) { dev->ops = ops; } |
bda9020e2 KVM: remove in_ra... |
47 48 |
static inline int kvm_iodevice_read(struct kvm_io_device *dev, gpa_t addr, int l, void *v) |
e2174021c KVM: Portability:... |
49 |
{ |
bda9020e2 KVM: remove in_ra... |
50 |
return dev->ops->read ? dev->ops->read(dev, addr, l, v) : -EOPNOTSUPP; |
e2174021c KVM: Portability:... |
51 |
} |
bda9020e2 KVM: remove in_ra... |
52 53 |
static inline int kvm_iodevice_write(struct kvm_io_device *dev, gpa_t addr, int l, const void *v) |
e2174021c KVM: Portability:... |
54 |
{ |
bda9020e2 KVM: remove in_ra... |
55 |
return dev->ops->write ? dev->ops->write(dev, addr, l, v) : -EOPNOTSUPP; |
e2174021c KVM: Portability:... |
56 57 58 59 |
} static inline void kvm_iodevice_destructor(struct kvm_io_device *dev) { |
d76685c4a KVM: cleanup io_d... |
60 61 |
if (dev->ops->destructor) dev->ops->destructor(dev); |
e2174021c KVM: Portability:... |
62 63 64 |
} #endif /* __KVM_IODEV_H__ */ |