Merge branch 'upstream-merge'
[qemu-kvm/markmc.git] / target-ppc / libkvm.c
blobda93026f11525f2f163fa3d39e2ba17ce446c8ef
1 /*
2 * This file contains the powerpc specific implementation for the
3 * architecture dependent functions defined in kvm-common.h and
4 * libkvm.h
6 * Copyright (C) 2006 Qumranet, Inc.
8 * Authors:
9 * Avi Kivity <avi@qumranet.com>
10 * Yaniv Kamay <yaniv@qumranet.com>
12 * Copyright IBM Corp. 2007,2008
13 * Authors:
14 * Jerone Young <jyoung5@us.ibm.com>
15 * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
17 * This work is licensed under the GNU LGPL license, version 2.
20 #include "libkvm-all.h"
21 #include "libkvm.h"
22 #include <errno.h>
23 #include <stdio.h>
24 #include <inttypes.h>
26 int handle_dcr(kvm_vcpu_context_t vcpu)
28 int ret = 0;
29 struct kvm_run *run = vcpu->run;
30 kvm_context_t kvm = vcpu->kvm;
32 if (run->dcr.is_write)
33 ret = kvm->callbacks->powerpc_dcr_write(vcpu,
34 run->dcr.dcrn,
35 run->dcr.data);
36 else
37 ret = kvm->callbacks->powerpc_dcr_read(vcpu,
38 run->dcr.dcrn,
39 &(run->dcr.data));
41 return ret;
44 void kvm_show_code(kvm_vcpu_context_t vcpu)
46 fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__);
49 void kvm_show_regs(kvm_vcpu_context_t vcpu)
51 struct kvm_regs regs;
52 int i;
54 if (kvm_get_regs(vcpu, &regs))
55 return;
57 fprintf(stderr,"guest vcpu #%d\n", vcpu);
58 fprintf(stderr,"pc: %016"PRIx64" msr: %016"PRIx64"\n",
59 regs.pc, regs.msr);
60 fprintf(stderr,"lr: %016"PRIx64" ctr: %016"PRIx64"\n",
61 regs.lr, regs.ctr);
62 fprintf(stderr,"srr0: %016"PRIx64" srr1: %016"PRIx64"\n",
63 regs.srr0, regs.srr1);
64 for (i=0; i<32; i+=4)
66 fprintf(stderr, "gpr%02d: %016"PRIx64" %016"PRIx64" %016"PRIx64
67 " %016"PRIx64"\n", i,
68 regs.gpr[i],
69 regs.gpr[i+1],
70 regs.gpr[i+2],
71 regs.gpr[i+3]);
74 fflush(stdout);
77 int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
78 void **vm_mem)
80 int r;
82 r = kvm_init_coalesced_mmio(kvm);
83 if (r < 0)
84 return r;
86 return 0;
89 int kvm_arch_run(kvm_vcpu_context_t vcpu)
91 int ret = 0;
93 switch (vcpu->run->exit_reason){
94 case KVM_EXIT_DCR:
95 ret = handle_dcr(vcpu);
96 break;
97 default:
98 ret = 1;
99 break;
101 return ret;