[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/32] turn info kqemu into generic info accelerator
From: |
Glauber Costa |
Subject: |
[Qemu-devel] [PATCH 10/32] turn info kqemu into generic info accelerator |
Date: |
Thu, 23 Oct 2008 12:18:54 -0200 |
From: Glauber Costa <address@hidden>
Yet another accel field: info.
>From this point on, "info kqemu" is no more. "info accelerator" should
be used instead.
Signed-off-by: Glauber Costa <address@hidden>
---
accel.c | 6 ++++++
accel.h | 8 ++++++++
kqemu.c | 26 ++++++++++++++++++++++++++
monitor.c | 35 ++++++++++++-----------------------
4 files changed, 52 insertions(+), 23 deletions(-)
diff --git a/accel.c b/accel.c
index 6776244..cb615d7 100644
--- a/accel.c
+++ b/accel.c
@@ -8,6 +8,11 @@ int _accel_nop(void)
return 0;
}
+int noaccel_info(CPUState *env, char *buf)
+{
+ return snprintf(buf, MAX_INFO_BUF, "no accelerator present.\n");
+}
+
#define accel_nop ((void *)_accel_nop)
/* Accelerator wrapper for the no-accel (raw qemu) case */
@@ -16,5 +21,6 @@ QEMUAccel noaccel = {
.init_env = accel_nop,
.flush_cache = accel_nop,
.flush_page = accel_nop,
+ .info = noaccel_info,
};
diff --git a/accel.h b/accel.h
index 935cfef..549ce01 100644
--- a/accel.h
+++ b/accel.h
@@ -1,11 +1,14 @@
#ifndef _ACCEL_H_
#define _ACCEL_H_
+#define MAX_INFO_BUF 1024
+
typedef struct QEMUAccel {
void (*cpu_interrupt)(CPUState *env);
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,4 +38,9 @@ static inline void accel_flush_page(CPUState *env,
target_ulong addr)
{
current_accel->flush_page(env, addr);
}
+
+static inline int accel_info(CPUState *env, char *buf)
+{
+ return current_accel->info(env, buf);
+}
#endif
diff --git a/kqemu.c b/kqemu.c
index 3f2433a..424d8f4 100644
--- a/kqemu.c
+++ b/kqemu.c
@@ -1047,11 +1047,37 @@ static void qpi_init(void)
0x1000, qpi_io_memory);
}
+static int kqemu_info(CPUState *env, char *buf)
+{
+ int val, len;
+ int bufsiz = MAX_INFO_BUF;
+ val = 0;
+ val = env->kqemu_enabled;
+ len = snprintf(buf, bufsiz, "kqemu support: ");
+ buf += len;
+ bufsiz -= len;
+
+ switch(val) {
+ default:
+ len += snprintf(buf, bufsiz, "present, but bogus value\n");
+ break;
+ case 1:
+ len += snprintf(buf, bufsiz, "enabled for user code\n");
+ break;
+ case 2:
+ len += snprintf(buf, bufsiz, "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,
};
#endif
diff --git a/monitor.c b/monitor.c
index f0a0bc3..d3ab137 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 <dirent.h>
#include "qemu-timer.h"
#include "migration.h"
@@ -1233,34 +1234,22 @@ static void mem_info(void)
}
#endif
-static void do_info_kqemu(void)
+static void do_info_accelerator(void)
{
-#ifdef USE_KQEMU
+ char buf[MAX_INFO_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
@@ -1493,8 +1482,8 @@ static const 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
- [Qemu-devel] [PATCH 07/32] introduce QEMUAccel and fill it with interrupt specific driver, (continued)
- [Qemu-devel] [PATCH 07/32] introduce QEMUAccel and fill it with interrupt specific driver, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 06/32] split kqemu_init into two, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 08/32] init env made accel driver, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 09/32] wrap cache flushing functions into accel drivers, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 13/32] move disabling code to kqemu.c instead of vl.c, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 15/32] wrap modify_page through accel calls, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 18/32] provide --accel option, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 10/32] turn info kqemu into generic info accelerator,
Glauber Costa <=
- [Qemu-devel] [PATCH 16/32] remove kqemu reference from hw/pc.c, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 12/32] move kqemu externs to kqemu.h, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 11/32] separate accelerator part of info profiler, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 21/32] get_env accel wrapper, Glauber Costa, 2008/10/23
- [Qemu-devel] [PATCH 17/32] build list of available accelerators, Glauber Costa, 2008/10/23