[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH qemu 1/2] monitor: Add CPU class callback to read regi
From: |
Alexey Kardashevskiy |
Subject: |
[Qemu-ppc] [PATCH qemu 1/2] monitor: Add CPU class callback to read registers for monitor |
Date: |
Thu, 6 Aug 2015 15:25:56 +1000 |
At the moment the monitor only prints registers from monitor_defs.
Some may not be supported but it will print those anyway, other
may be missing in the list so monitor_defs needs an update every time
new register is added.
This defines a CPUClass callback to read various registers from CPU.
Next patch makes use of it.
Signed-off-by: Alexey Kardashevskiy <address@hidden>
---
include/qom/cpu.h | 1 +
monitor.c | 14 +++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 20aabc9..fcf981f 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -144,6 +144,7 @@ typedef struct CPUClass {
int flags);
void (*dump_statistics)(CPUState *cpu, FILE *f,
fprintf_function cpu_fprintf, int flags);
+ int (*get_monitor_def)(CPUState *cs, const char *name, uint64_t *pval);
int64_t (*get_arch_id)(CPUState *cpu);
bool (*get_paging_enabled)(const CPUState *cpu);
void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list,
diff --git a/monitor.c b/monitor.c
index aeea2b5..bdfcacc 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3303,13 +3303,25 @@ static int get_monitor_def(target_long *pval, const
char *name)
{
const MonitorDef *md;
void *ptr;
+ CPUState *cs = mon_get_cpu();
+ CPUClass *cc = CPU_GET_CLASS(cs);
+
+ if (cc->get_monitor_def) {
+ uint64_t tmp = 0;
+ int ret = cc->get_monitor_def(cs, name, &tmp);
+
+ if (!ret) {
+ *pval = (target_long) tmp;
+ }
+ return ret;
+ }
for(md = monitor_defs; md->name != NULL; md++) {
if (compare_cmd(name, md->name)) {
if (md->get_value) {
*pval = md->get_value(md, md->offset);
} else {
- CPUArchState *env = mon_get_cpu_env();
+ CPUArchState *env = cs->env_ptr;
ptr = (uint8_t *)env + md->offset;
switch(md->type) {
case MD_I32:
--
2.4.0.rc3.8.gfb3e7d5