aurel32 | d76d165 | 2008-12-16 10:43:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * PowerPC KVM support |
| 3 | * |
| 4 | * Copyright IBM Corp. 2008 |
| 5 | * |
| 6 | * Authors: |
| 7 | * Hollis Blanchard <hollisb@us.ibm.com> |
| 8 | * |
| 9 | * This work is licensed under the terms of the GNU GPL, version 2 or later. |
| 10 | * See the COPYING file in the top-level directory. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include "qemu-common.h" |
Paolo Bonzini | 1de7afc | 2012-12-17 18:20:00 +0100 | [diff] [blame] | 15 | #include "qemu/timer.h" |
aurel32 | d76d165 | 2008-12-16 10:43:58 +0000 | [diff] [blame] | 16 | #include "kvm_ppc.h" |
Paolo Bonzini | 9c17d61 | 2012-12-17 18:20:04 +0100 | [diff] [blame] | 17 | #include "sysemu/device_tree.h" |
aurel32 | d76d165 | 2008-12-16 10:43:58 +0000 | [diff] [blame] | 18 | |
| 19 | #define PROC_DEVTREE_PATH "/proc/device-tree" |
| 20 | |
| 21 | static QEMUTimer *kvmppc_timer; |
| 22 | static unsigned int kvmppc_timer_rate; |
| 23 | |
aurel32 | d76d165 | 2008-12-16 10:43:58 +0000 | [diff] [blame] | 24 | static void kvmppc_timer_hack(void *opaque) |
| 25 | { |
Frediano Ziglio | 74e26c1 | 2011-09-22 11:26:15 +0200 | [diff] [blame] | 26 | qemu_notify_event(); |
Paolo Bonzini | 7447545 | 2011-03-11 16:47:48 +0100 | [diff] [blame] | 27 | qemu_mod_timer(kvmppc_timer, qemu_get_clock_ns(vm_clock) + kvmppc_timer_rate); |
aurel32 | d76d165 | 2008-12-16 10:43:58 +0000 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | void kvmppc_init(void) |
| 31 | { |
| 32 | /* XXX The only reason KVM yields control back to qemu is device IO. Since |
| 33 | * an idle guest does no IO, qemu's device model will never get a chance to |
Stefan Weil | 5cbdb3a | 2012-04-07 09:23:39 +0200 | [diff] [blame] | 34 | * run. So, until QEMU gains IO threads, we create this timer to ensure |
aurel32 | d76d165 | 2008-12-16 10:43:58 +0000 | [diff] [blame] | 35 | * that the device model gets a chance to run. */ |
Juan Quintela | 6ee093c | 2009-09-10 03:04:26 +0200 | [diff] [blame] | 36 | kvmppc_timer_rate = get_ticks_per_sec() / 10; |
Paolo Bonzini | 7447545 | 2011-03-11 16:47:48 +0100 | [diff] [blame] | 37 | kvmppc_timer = qemu_new_timer_ns(vm_clock, &kvmppc_timer_hack, NULL); |
| 38 | qemu_mod_timer(kvmppc_timer, qemu_get_clock_ns(vm_clock) + kvmppc_timer_rate); |
aurel32 | d76d165 | 2008-12-16 10:43:58 +0000 | [diff] [blame] | 39 | } |
| 40 | |