From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KCKja-0002rj-TZ for qemu-devel@nongnu.org; Fri, 27 Jun 2008 16:39:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KCKjZ-0002qF-2Z for qemu-devel@nongnu.org; Fri, 27 Jun 2008 16:39:54 -0400 Received: from [199.232.76.173] (port=48161 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KCKjY-0002q5-PM for qemu-devel@nongnu.org; Fri, 27 Jun 2008 16:39:52 -0400 Received: from mx1.redhat.com ([66.187.233.31]:55932) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KCKjZ-0007zH-26 for qemu-devel@nongnu.org; Fri, 27 Jun 2008 16:39:53 -0400 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m5RKdpOj014231 for ; Fri, 27 Jun 2008 16:39:51 -0400 Received: from pobox-2.corp.redhat.com (pobox-2.corp.redhat.com [10.11.255.15]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m5RKdpgh005589 for ; Fri, 27 Jun 2008 16:39:51 -0400 Received: from localhost.localdomain (vpn-4-80.str.redhat.com [10.32.4.80]) by pobox-2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m5RKdadd004563 for ; Fri, 27 Jun 2008 16:39:50 -0400 From: Glauber Costa Date: Fri, 27 Jun 2008 17:38:08 -0300 Message-Id: <1214599103-13846-6-git-send-email-gcosta@redhat.com> In-Reply-To: <1214599103-13846-5-git-send-email-gcosta@redhat.com> References: <1214599103-13846-1-git-send-email-gcosta@redhat.com> <1214599103-13846-2-git-send-email-gcosta@redhat.com> <1214599103-13846-3-git-send-email-gcosta@redhat.com> <1214599103-13846-4-git-send-email-gcosta@redhat.com> <1214599103-13846-5-git-send-email-gcosta@redhat.com> Subject: [Qemu-devel] [PATCH 05/20] turn info kqemu into generic info accelerator Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --- accel.h | 8 ++++++++ kqemu.c | 24 ++++++++++++++++++++++++ monitor.c | 36 +++++++++++++----------------------- 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/accel.h b/accel.h index 8344b45..f6d53ea 100644 --- a/accel.h +++ b/accel.h @@ -3,6 +3,7 @@ typedef struct QEMUAccel { void (*init_env)(CPUState *env); void (*flush_cache)(CPUState *env, int global); void (*flush_page)(CPUState *env, target_ulong addr); + int (*info)(CPUState *env, char *buf); } QEMUAccel; extern QEMUAccel *current_accel; @@ -35,3 +36,10 @@ static inline void accel_flush_page(CPUState *env, target_ulong addr) if (current_accel && current_accel->flush_page) current_accel->flush_page(env, addr); } + +static inline int accel_info(CPUState *env, char *buf) +{ + if (current_accel && current_accel->info) + return current_accel->info(env, buf); + return 0; +} diff --git a/kqemu.c b/kqemu.c index 56e59fd..ac12e17 100644 --- a/kqemu.c +++ b/kqemu.c @@ -270,11 +270,35 @@ void kqemu_flush(CPUState *env, int global) nb_pages_to_flush = KQEMU_FLUSH_ALL; } +int kqemu_info(CPUState *env, char *buf) +{ + int val, len; + val = 0; + val = env->kqemu_enabled; + len = sprintf(buf, "kqemu support: "); + buf += len; + + switch(val) { + default: + len += sprintf(buf, "present, but bogus value\n"); + break; + case 1: + len += sprintf(buf, "enabled for user code\n"); + break; + case 2: + len += sprintf(buf, "enabled for user and kernel code\n"); + break; + } + + return len; +} + QEMUAccel kqemu_accel = { .cpu_interrupt = kqemu_cpu_interrupt, .init_env = kqemu_init_env, .flush_cache = kqemu_flush, .flush_page = kqemu_flush_page, + .info = kqemu_info, }; diff --git a/monitor.c b/monitor.c index fc135ca..ef189cc 100644 --- a/monitor.c +++ b/monitor.c @@ -34,6 +34,7 @@ #include "block.h" #include "audio/audio.h" #include "disas.h" +#include "accel.h" #include #include "qemu-timer.h" @@ -1217,34 +1218,23 @@ static void mem_info(void) } #endif -static void do_info_kqemu(void) +#define MAX_BUF 1024 +static void do_info_accelerator(void) { -#ifdef USE_KQEMU + char buf[MAX_BUF]; CPUState *env; - int val; - val = 0; + env = mon_get_cpu(); + if (!env) { term_printf("No cpu initialized yet"); return; } - val = env->kqemu_enabled; - term_printf("kqemu support: "); - switch(val) { - default: - case 0: - term_printf("disabled\n"); - break; - case 1: - term_printf("enabled for user code\n"); - break; - case 2: - term_printf("enabled for user and kernel code\n"); - break; - } -#else - term_printf("kqemu support: not compiled\n"); -#endif + + if (accel_info(env, buf)) + term_printf(buf); + else + term_printf("No accelerator present\n"); } #ifdef CONFIG_PROFILER @@ -1474,8 +1464,8 @@ static term_cmd_t info_cmds[] = { #endif { "jit", "", do_info_jit, "", "show dynamic compiler info", }, - { "kqemu", "", do_info_kqemu, - "", "show kqemu information", }, + { "accelerator", "", do_info_accelerator, + "", "show accelerator information", }, { "usb", "", usb_info, "", "show guest USB devices", }, { "usbhost", "", usb_host_info, -- 1.5.5.1