summaryrefslogtreecommitdiff
path: root/libkvm
diff options
context:
space:
mode:
authorJerone Young <jyoung5@us.ibm.com>2008-01-02 14:14:01 -0600
committerAvi Kivity <avi@qumranet.com>2008-01-03 17:44:58 +0200
commite7201f615c8802c624dd6aab9b02774556123a0e (patch)
treeaeef9afd3b683a63842ceadab35acf265cf7eb71 /libkvm
parentdf3671df6b8351de536dcb70a2f80f3c98744837 (diff)
kvm: libkvm: add powerpc libkvm support code
While the kernel code has not yet made it upstream, after seeing the skeleton patches making it in over the holiday, I decided to send this since it's for the most part stable with what we are hacking away with in kernel. Signed-off-by: Jerone Young <jyoung5@us.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'libkvm')
-rw-r--r--libkvm/libkvm-powerpc.c73
-rw-r--r--libkvm/libkvm.h4
2 files changed, 74 insertions, 3 deletions
diff --git a/libkvm/libkvm-powerpc.c b/libkvm/libkvm-powerpc.c
index 5a8c556a..33459bbf 100644
--- a/libkvm/libkvm-powerpc.c
+++ b/libkvm/libkvm-powerpc.c
@@ -1,18 +1,75 @@
+/*
+ * This header is for functions & variables that will ONLY be
+ * used inside libkvm for x86.
+ * THESE ARE NOT EXPOSED TO THE USER AND ARE ONLY FOR USE
+ * WITHIN LIBKVM.
+ *
+ * derived from libkvm.c
+ *
+ * Copyright (C) 2006 Qumranet, Inc.
+ *
+ * Authors:
+ * Avi Kivity <avi@qumranet.com>
+ * Yaniv Kamay <yaniv@qumranet.com>
+ *
+ * Copyright 2007 IBM Corporation.
+ * Added by & Authors:
+ * Jerone Young <jyoung5@us.ibm.com>
+ * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
+ *
+ *
+ * This work is licensed under the GNU LGPL license, version 2.
+ */
+
#include "libkvm.h"
#include "kvm-powerpc.h"
#include <errno.h>
+#include <stdio.h>
+
+int handle_dcr(struct kvm_run *run, kvm_context_t kvm)
+{
+ int ret = 0;
+
+ if (run->dcr.is_write)
+ ret = kvm->callbacks->powerpc_dcr_write(kvm,
+ run->dcr.dcrn,run->dcr.data);
+ else
+ ret = kvm->callbacks->powerpc_dcr_read(kvm,
+ run->dcr.dcrn, &(run->dcr.data));
+
+ return ret;
+}
-int kvm_run_abi10(kvm_context_t kvm, int vcpu)
+int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory,
+ void **vm_mem)
{
- return -ENOSYS;
+ fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__);
+ return -1;
}
void kvm_show_code(kvm_context_t kvm, int vcpu)
{
+ fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__);
}
void kvm_show_regs(kvm_context_t kvm, int vcpu)
{
+ struct kvm_regs regs;
+ int i;
+
+ if (kvm_get_regs(kvm, vcpu, &regs))
+ return;
+
+ for (i=0; i<32; i+=4)
+ {
+ fprintf(stderr, "gpr%02d: %08x %08x %08x %08x\n", i,
+ regs.gpr[i],
+ regs.gpr[i+1],
+ regs.gpr[i+2],
+ regs.gpr[i+3]);
+ }
+
+ fflush(stdout);
}
int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
@@ -30,5 +87,15 @@ int kvm_arch_create_default_phys_mem(kvm_context_t kvm,
int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu)
{
- return 0;
+ int ret = 0;
+
+ switch (run->exit_reason){
+ case KVM_EXIT_DCR:
+ ret = handle_dcr(run, kvm);
+ break;
+ default:
+ ret = 1;
+ break;
+ }
+ return ret;
}
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
index 3aae6f62..2574abef 100644
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -65,6 +65,10 @@ struct kvm_callbacks {
void (*post_kvm_run)(void *opaque, int vcpu);
int (*pre_kvm_run)(void *opaque, int vcpu);
int (*tpr_access)(void *opaque, int vcpu, uint64_t rip, int is_write);
+#if defined(__powerpc__)
+ int (*powerpc_dcr_read)(kvm_context_t kvm, uint32_t dcrn, uint32_t *data);
+ int (*powerpc_dcr_write)(kvm_context_t kvm, uint32_t dcrn, uint32_t data);
+#endif
};
/*!