diff options
author | Gregory Haskins <ghaskins@novell.com> | 2007-05-31 14:08:53 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-07-16 05:05:47 -0400 |
commit | 2eeb2e94eb6232f0895da696c10e6636093ff72b (patch) | |
tree | 2b60e438899054f50ce0e93c33a7dcfee4dc5edc /drivers/kvm/kvm.h | |
parent | d9413cd757a7c96d97ddb46ab4e3e04760ae4c55 (diff) |
KVM: Adds support for in-kernel mmio handlers
Signed-off-by: Gregory Haskins <ghaskins@novell.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm.h')
-rw-r--r-- | drivers/kvm/kvm.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h index b08272bce213..31846b1c162f 100644 --- a/drivers/kvm/kvm.h +++ b/drivers/kvm/kvm.h | |||
@@ -265,6 +265,65 @@ struct kvm_stat { | |||
265 | u32 efer_reload; | 265 | u32 efer_reload; |
266 | }; | 266 | }; |
267 | 267 | ||
268 | struct kvm_io_device { | ||
269 | void (*read)(struct kvm_io_device *this, | ||
270 | gpa_t addr, | ||
271 | int len, | ||
272 | void *val); | ||
273 | void (*write)(struct kvm_io_device *this, | ||
274 | gpa_t addr, | ||
275 | int len, | ||
276 | const void *val); | ||
277 | int (*in_range)(struct kvm_io_device *this, gpa_t addr); | ||
278 | void (*destructor)(struct kvm_io_device *this); | ||
279 | |||
280 | void *private; | ||
281 | }; | ||
282 | |||
283 | static inline void kvm_iodevice_read(struct kvm_io_device *dev, | ||
284 | gpa_t addr, | ||
285 | int len, | ||
286 | void *val) | ||
287 | { | ||
288 | dev->read(dev, addr, len, val); | ||
289 | } | ||
290 | |||
291 | static inline void kvm_iodevice_write(struct kvm_io_device *dev, | ||
292 | gpa_t addr, | ||
293 | int len, | ||
294 | const void *val) | ||
295 | { | ||
296 | dev->write(dev, addr, len, val); | ||
297 | } | ||
298 | |||
299 | static inline int kvm_iodevice_inrange(struct kvm_io_device *dev, gpa_t addr) | ||
300 | { | ||
301 | return dev->in_range(dev, addr); | ||
302 | } | ||
303 | |||
304 | static inline void kvm_iodevice_destructor(struct kvm_io_device *dev) | ||
305 | { | ||
306 | dev->destructor(dev); | ||
307 | } | ||
308 | |||
309 | /* | ||
310 | * It would be nice to use something smarter than a linear search, TBD... | ||
311 | * Thankfully we dont expect many devices to register (famous last words :), | ||
312 | * so until then it will suffice. At least its abstracted so we can change | ||
313 | * in one place. | ||
314 | */ | ||
315 | struct kvm_io_bus { | ||
316 | int dev_count; | ||
317 | #define NR_IOBUS_DEVS 6 | ||
318 | struct kvm_io_device *devs[NR_IOBUS_DEVS]; | ||
319 | }; | ||
320 | |||
321 | void kvm_io_bus_init(struct kvm_io_bus *bus); | ||
322 | void kvm_io_bus_destroy(struct kvm_io_bus *bus); | ||
323 | struct kvm_io_device *kvm_io_bus_find_dev(struct kvm_io_bus *bus, gpa_t addr); | ||
324 | void kvm_io_bus_register_dev(struct kvm_io_bus *bus, | ||
325 | struct kvm_io_device *dev); | ||
326 | |||
268 | struct kvm_vcpu { | 327 | struct kvm_vcpu { |
269 | struct kvm *kvm; | 328 | struct kvm *kvm; |
270 | union { | 329 | union { |
@@ -393,6 +452,7 @@ struct kvm { | |||
393 | unsigned long rmap_overflow; | 452 | unsigned long rmap_overflow; |
394 | struct list_head vm_list; | 453 | struct list_head vm_list; |
395 | struct file *filp; | 454 | struct file *filp; |
455 | struct kvm_io_bus mmio_bus; | ||
396 | }; | 456 | }; |
397 | 457 | ||
398 | struct descriptor_table { | 458 | struct descriptor_table { |