blob: 1b192a803858c1945a45e9e5d7dac322b1833b39 [file] [log] [blame]
aurel32d76d1652008-12-16 10:43:58 +00001/*
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 Bonzini1de7afc2012-12-17 18:20:00 +010015#include "qemu/timer.h"
aurel32d76d1652008-12-16 10:43:58 +000016#include "kvm_ppc.h"
Paolo Bonzini9c17d612012-12-17 18:20:04 +010017#include "sysemu/device_tree.h"
aurel32d76d1652008-12-16 10:43:58 +000018
19#define PROC_DEVTREE_PATH "/proc/device-tree"
20
21static QEMUTimer *kvmppc_timer;
22static unsigned int kvmppc_timer_rate;
23
aurel32d76d1652008-12-16 10:43:58 +000024static void kvmppc_timer_hack(void *opaque)
25{
Frediano Ziglio74e26c12011-09-22 11:26:15 +020026 qemu_notify_event();
Paolo Bonzini74475452011-03-11 16:47:48 +010027 qemu_mod_timer(kvmppc_timer, qemu_get_clock_ns(vm_clock) + kvmppc_timer_rate);
aurel32d76d1652008-12-16 10:43:58 +000028}
29
30void 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 Weil5cbdb3a2012-04-07 09:23:39 +020034 * run. So, until QEMU gains IO threads, we create this timer to ensure
aurel32d76d1652008-12-16 10:43:58 +000035 * that the device model gets a chance to run. */
Juan Quintela6ee093c2009-09-10 03:04:26 +020036 kvmppc_timer_rate = get_ticks_per_sec() / 10;
Paolo Bonzini74475452011-03-11 16:47:48 +010037 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);
aurel32d76d1652008-12-16 10:43:58 +000039}
40