From 92353de024c1b8e1113ad36b2774c62b88928b47 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Wed, 31 Mar 2010 21:08:16 +0300 Subject: [PATCH] kvm: Extract ioport emulation code to its own file Signed-off-by: Pekka Enberg --- tools/kvm/Makefile | 1 + tools/kvm/ioport.c | 21 +++++++++++++++++++++ tools/kvm/kvm.c | 18 ------------------ 3 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 tools/kvm/ioport.c diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile index 99b88c9295f5..da5b18bd574a 100644 --- a/tools/kvm/Makefile +++ b/tools/kvm/Makefile @@ -3,6 +3,7 @@ PROGRAM = kvm OBJS += cpu.o OBJS += cpuid.o OBJS += interrupt.o +OBJS += ioport.o OBJS += kvm.o OBJS += main.o OBJS += util.o diff --git a/tools/kvm/ioport.c b/tools/kvm/ioport.c new file mode 100644 index 000000000000..7725b5fc3aeb --- /dev/null +++ b/tools/kvm/ioport.c @@ -0,0 +1,21 @@ +#include "kvm/kvm.h" + +#include + +static void kvm__emulate_io_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) +{ + fprintf(stderr, "%s port=%x, size=%d, count=%" PRIu32 "\n", __func__, port, size, count); +} + +static void kvm__emulate_io_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) +{ + fprintf(stderr, "%s port=%x, size=%d, count=%" PRIu32 "\n", __func__, port, size, count); +} + +void kvm__emulate_io(struct kvm *self, uint16_t port, void *data, int direction, int size, uint32_t count) +{ + if (direction == KVM_EXIT_IO_IN) + kvm__emulate_io_in(self, port, data, size, count); + else + kvm__emulate_io_out(self, port, data, size, count); +} diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c index 0b7776557927..c651004edd6d 100644 --- a/tools/kvm/kvm.c +++ b/tools/kvm/kvm.c @@ -413,24 +413,6 @@ void kvm__run(struct kvm *self) die_perror("KVM_RUN failed"); } -static void kvm__emulate_io_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) -{ - fprintf(stderr, "%s port=%x, size=%d, count=%" PRIu32 "\n", __func__, port, size, count); -} - -static void kvm__emulate_io_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) -{ - fprintf(stderr, "%s port=%x, size=%d, count=%" PRIu32 "\n", __func__, port, size, count); -} - -void kvm__emulate_io(struct kvm *self, uint16_t port, void *data, int direction, int size, uint32_t count) -{ - if (direction == KVM_EXIT_IO_IN) - kvm__emulate_io_in(self, port, data, size, count); - else - kvm__emulate_io_out(self, port, data, size, count); -} - static void print_segment(const char *name, struct kvm_segment *seg) { printf(" %s %04" PRIx16 " %016" PRIx64 " %08" PRIx32 " %02" PRIx8 " %x %x %x %x %x %x %x\n", -- 2.39.5