]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm: Add proper 00E0 ioport handling
authorPekka Enberg <penberg@cs.helsinki.fi>
Sun, 4 Jul 2010 10:41:45 +0000 (13:41 +0300)
committerPekka Enberg <penberg@cs.helsinki.fi>
Sun, 4 Jul 2010 10:41:45 +0000 (13:41 +0300)
We use 00E0 ioport for trapping to the hypervisor. This patch cleans up
handling of the ioport to call exit() in ioport emulation handler.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
tools/kvm/Makefile
tools/kvm/ioport.c
tools/kvm/main.c

index 5dee20b1d8a45230ddcf27090eb85aa9d76083ad..6096ac713a6b5f048d01976b4b4628286eda2a73 100644 (file)
@@ -79,7 +79,7 @@ bios/int10.o: bios/int10.S bios/int10-real.S
 
 check: $(PROGRAM)
        $(MAKE) -C tests
-       ./$(PROGRAM) --dbgtest tests/pit/tick.bin
+       ./$(PROGRAM) tests/pit/tick.bin
 .PHONY: check
 
 clean:
index 42454d2d30e307eb4c33c0fc33a16b246abc09f7..4bcc2b7dbf9619a6c9b9405dcba14042ce05c59a 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <assert.h>
 #include <limits.h>
+#include <stdlib.h>
 #include <stdio.h>
 
 static uint8_t ioport_to_uint8(void *data)
@@ -28,6 +29,15 @@ static struct ioport_operations cmos_ram_rtc_ops = {
        .io_out         = cmos_ram_rtc_io_out,
 };
 
+static bool debug_io_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
+{
+       exit(EXIT_SUCCESS);
+}
+
+static struct ioport_operations debug_ops = {
+       .io_out         = debug_io_out,
+};
+
 static bool dummy_io_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
 {
        return true;
@@ -70,6 +80,10 @@ static struct ioport_operations *ioport_ops[USHRT_MAX] = {
        [0x00A0]        = &dummy_read_write_ioport_ops,
        [0x00A1]        = &dummy_read_write_ioport_ops,
 
+       /* PORT 00E0-00EF are 'motherboard specific' so we use them for our
+          internal debugging purposes.  */
+       [0x00E0]        = &debug_ops,
+
        /* PORT 00ED - DUMMY PORT FOR DELAY??? */
        [0x00ED]        = &dummy_write_only_ioport_ops,
 
index 9002c0ff6d2b62a26cdabf63fc46cb85137a9f0a..91be73585c9def0fb8de7db00ac4638170c665f7 100644 (file)
 #include <string.h>
 #include <stdio.h>
 
-unsigned int dbgtest_mode;
-
 static void usage(char *argv[])
 {
-       fprintf(stderr, "  usage: %s [--dbgtest] [--single-step] [--kernel=]<kernel-image>\n",
+       fprintf(stderr, "  usage: %s [--single-step] [--kernel=]<kernel-image>\n",
                argv[0]);
        exit(1);
 }
@@ -55,9 +53,6 @@ int main(int argc, char *argv[])
                } else if (option_matches(argv[i], "--params=")) {
                        kernel_cmdline = &argv[i][9];
                        continue;
-               } else if (option_matches(argv[i], "--dbgtest")) {
-                       dbgtest_mode = 1;
-                       continue;
                } else if (option_matches(argv[i], "--single-step")) {
                        single_step = true;
                        continue;
@@ -137,13 +132,6 @@ int main(int argc, char *argv[])
 
 exit_kvm:
 
-       if (dbgtest_mode) {
-               if (kvm->kvm_run->exit_reason == KVM_EXIT_IO &&
-                       kvm->kvm_run->io.port == 0xe0)
-                       fprintf(stderr, "KVM: this is an expected IO error\n");
-                       goto out;
-       }
-
        fprintf(stderr, "KVM exit reason: %" PRIu32 " (\"%s\")\n",
                kvm->kvm_run->exit_reason, kvm_exit_reasons[kvm->kvm_run->exit_reason]);
        if (kvm->kvm_run->exit_reason == KVM_EXIT_UNKNOWN)