Fix pci_add nic not to exit on bad model
[qemu-kvm/fedora.git] / kvm / libkvm / libkvm-powerpc.c
blobf2cd8dc32e7d66366d2d1166c2a12e347b2e152e
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.h"
21 #include "kvm-powerpc.h"
22 #include <errno.h>
23 #include <stdio.h>
24 #include <inttypes.h>
26 int handle_dcr(struct kvm_run *run, kvm_context_t kvm, int vcpu)
28 int ret = 0;
30 if (run->dcr.is_write)
31 ret = kvm->callbacks->powerpc_dcr_write(vcpu,
32 run->dcr.dcrn,
33 run->dcr.data);
34 else
35 ret = kvm->callbacks->powerpc_dcr_read(vcpu,
36 run->dcr.dcrn,
37 &(run->dcr.data));
39 return ret;
42 void kvm_show_code(kvm_context_t kvm, int vcpu)
44 fprintf(stderr, "%s: Operation not supported\n", __FUNCTION__);
47 void kvm_show_regs(kvm_context_t kvm, int vcpu)
49 struct kvm_regs regs;
50 int i;
52 if (kvm_get_regs(kvm, vcpu, &regs))
53 return;
55 fprintf(stderr,"guest vcpu #%d\n", vcpu);
56 fprintf(stderr,"pc: %016"PRIx64" msr: %016"PRIx64"\n",
57 regs.pc, regs.msr);
58 fprintf(stderr,"lr: %016"PRIx64" ctr: %016"PRIx64"\n",
59 regs.lr, regs.ctr);
60 fprintf(stderr,"srr0: %016"PRIx64" srr1: %016"PRIx64"\n",
61 regs.srr0, regs.srr1);
62 for (i=0; i<32; i+=4)
64 fprintf(stderr, "gpr%02d: %016"PRIx64" %016"PRIx64" %016"PRIx64
65 " %016"PRIx64"\n", i,
66 regs.gpr[i],
67 regs.gpr[i+1],
68 regs.gpr[i+2],
69 regs.gpr[i+3]);
72 fflush(stdout);
75 int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
76 void **vm_mem)
78 int r;
80 r = kvm_init_coalesced_mmio(kvm);
81 if (r < 0)
82 return r;
84 return 0;
87 int kvm_arch_run(struct kvm_run *run, kvm_context_t kvm, int vcpu)
89 int ret = 0;
91 switch (run->exit_reason){
92 case KVM_EXIT_DCR:
93 ret = handle_dcr(run, kvm, vcpu);
94 break;
95 default:
96 ret = 1;
97 break;
99 return ret;