kvm: qemu: add cpu_unregister_io_memory and make io mem table index dynamic
[kvm-userspace.git] / libkvm / kvm-common.h
blobb8a88ee00e1174ca6e432e128b952bc143ef4e46
1 /*
2 * This header is for functions & variables that will ONLY be
3 * used inside libkvm.
5 * derived from libkvm.c
7 * Copyright (C) 2006 Qumranet, Inc.
9 * Authors:
10 * Avi Kivity <avi@qumranet.com>
11 * Yaniv Kamay <yaniv@qumranet.com>
13 * This work is licensed under the GNU LGPL license, version 2.
16 #ifndef KVM_COMMON_H
17 #define KVM_COMMON_H
19 /* FIXME: share this number with kvm */
20 /* FIXME: or dynamically alloc/realloc regions */
21 #define KVM_MAX_NUM_MEM_REGIONS 8u
22 #define MAX_VCPUS 16
24 /* kvm abi verison variable */
25 extern int kvm_abi;
27 /**
28 * \brief The KVM context
30 * The verbose KVM context
33 struct kvm_context {
34 /// Filedescriptor to /dev/kvm
35 int fd;
36 int vm_fd;
37 int vcpu_fd[MAX_VCPUS];
38 struct kvm_run *run[MAX_VCPUS];
39 /// Callbacks that KVM uses to emulate various unvirtualizable functionality
40 struct kvm_callbacks *callbacks;
41 void *opaque;
42 /// A pointer to the memory used as the physical memory for the guest
43 void *physical_memory;
44 /// is dirty pages logging enabled for all regions or not
45 int dirty_pages_log_all;
46 /// do not create in-kernel irqchip if set
47 int no_irqchip_creation;
48 /// in-kernel irqchip status
49 int irqchip_in_kernel;
50 /// do not create in-kernel pit if set
51 int no_pit_creation;
52 /// in-kernel pit status
53 int pit_in_kernel;
56 void init_slots(void);
57 int get_free_slot(kvm_context_t kvm);
58 void register_slot(int slot, unsigned long phys_addr, unsigned long len,
59 int user_alloc, unsigned long userspace_addr, unsigned flags);
61 void free_slot(int slot);
62 int get_slot(unsigned long phys_addr);
64 int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory,
65 void **vm_mem);
66 int kvm_alloc_userspace_memory(kvm_context_t kvm, unsigned long memory,
67 void **vm_mem);
68 void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start,
69 unsigned long len, int log, int writable);
72 int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
73 void **vm_mem);
74 int kvm_arch_create_default_phys_mem(kvm_context_t kvm,
75 unsigned long phys_mem_bytes,
76 void **vm_mem);
77 int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu);
80 void kvm_show_code(kvm_context_t kvm, int vcpu);
82 int handle_halt(kvm_context_t kvm, int vcpu);
83 int handle_shutdown(kvm_context_t kvm, int vcpu);
84 void post_kvm_run(kvm_context_t kvm, int vcpu);
85 int pre_kvm_run(kvm_context_t kvm, int vcpu);
86 int handle_io_window(kvm_context_t kvm);
87 int handle_debug(kvm_context_t kvm, int vcpu);
88 int try_push_interrupts(kvm_context_t kvm);
90 #endif