]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm: Move interrupt table to struct kvm
authorPekka Enberg <penberg@cs.helsinki.fi>
Sun, 28 Mar 2010 16:41:48 +0000 (19:41 +0300)
committerPekka Enberg <penberg@cs.helsinki.fi>
Sun, 28 Mar 2010 16:41:48 +0000 (19:41 +0300)
This patch moves the global interrupt table to struct kvm.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
tools/kvm/include/kvm/interrupt.h
tools/kvm/include/kvm/kvm.h
tools/kvm/interrupt.c
tools/kvm/kvm.c

index 95d294fb0681671c0fcb5e210a9f7e105d19d36a..b24e3fd3f766e502eb8a9eef927b5e969f211d89 100644 (file)
@@ -11,10 +11,11 @@ struct ivt_entry {
        uint16_t segment;
 } __attribute__((packed));
 
-void ivt_reset(void);
-void ivt_copy_table(void *dst, unsigned int size);
-struct ivt_entry * const ivt_get_entry(unsigned int n);
-void ivt_set_entry(struct ivt_entry e, unsigned int n);
-void ivt_set_all(struct ivt_entry e);
+struct interrupt_table {
+       struct ivt_entry entries[IVT_VECTORS];
+};
+
+void interrupt_table__copy(struct interrupt_table *self, void *dst, unsigned int size);
+void interrupt_table__setup(struct interrupt_table *self, struct ivt_entry e);
 
 #endif /* KVM__INTERRUPT_H */
index f46b32cd2422c73c70156d3ac6d84639ed6703e5..1022177ab45b9fc1830a87a56c6a7840d6dd2976 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef KVM__KVM_H
 #define KVM__KVM_H
 
+#include "kvm/interrupt.h"
+
 #include <linux/kvm.h> /* for struct kvm_regs */
 
 #include <stdbool.h>
@@ -21,6 +23,8 @@ struct kvm {
 
        struct kvm_regs         regs;
        struct kvm_sregs        sregs;
+
+       struct interrupt_table  interrupt_table;
 };
 
 struct kvm *kvm__init(void);
index 0d4ba997ae50d37efec6d658016949bf4ce8b59d..de8d8a1fb6203d7db8cd36d11f7c1717012cdb11 100644 (file)
@@ -4,38 +4,18 @@
 
 #include <string.h>
 
-static struct ivt_entry ivt_table[IVT_VECTORS];
-
-void ivt_reset(void)
+void interrupt_table__copy(struct interrupt_table *self, void *dst, unsigned int size)
 {
-       memset(ivt_table, 0x0, sizeof(ivt_table));
-}
-
-void ivt_copy_table(void *dst, unsigned int size)
-{
-       if (size < sizeof(ivt_table))
+       if (size < sizeof(self->entries))
                die("An attempt to overwrite host memory");
-       memcpy(dst, ivt_table, sizeof(ivt_table));
-}
 
-struct ivt_entry * const ivt_get_entry(unsigned int n)
-{
-       struct ivt_entry *v = NULL;
-       if (n < IVT_VECTORS)
-               v = &ivt_table[n];
-       return (struct ivt_entry * const)v;
-}
-
-void ivt_set_entry(struct ivt_entry e, unsigned int n)
-{
-       if (n < IVT_VECTORS)
-               ivt_table[n] = e;
+       memcpy(dst, self->entries, sizeof(self->entries));
 }
 
-void ivt_set_all(struct ivt_entry e)
+void interrupt_table__setup(struct interrupt_table *self, struct ivt_entry e)
 {
        unsigned int i;
 
        for (i = 0; i < IVT_VECTORS; i++)
-               ivt_table[i] = e;
+               self->entries[i] = e;
 }
index a6d5f4ed44d1399509b577fbea11dde03e839732..638441d3107d4f9a94a1944443e464c72d54154e 100644 (file)
@@ -261,9 +261,9 @@ static bool load_bzimage(struct kvm *self, int fd, const char *kernel_cmdline)
                .segment        = nr >> 4,
                .offset         = (nr - (nr & ~0xf)),
        };
-       ivt_set_all(real_mode_irq);
+       interrupt_table__setup(&self->interrupt_table, real_mode_irq);
        p = guest_flat_to_host(self, 0);
-       ivt_copy_table(p, IVT_VECTORS * sizeof(real_mode_irq));
+       interrupt_table__copy(&self->interrupt_table, p, IVT_VECTORS * sizeof(real_mode_irq));
 
        return true;
 }