From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z771g-0005au-JR for qemu-devel@nongnu.org; Mon, 22 Jun 2015 15:05:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z771d-0002NJ-2d for qemu-devel@nongnu.org; Mon, 22 Jun 2015 15:05:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42481) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z771c-0002N0-OZ for qemu-devel@nongnu.org; Mon, 22 Jun 2015 15:04:56 -0400 From: Markus Armbruster Date: Mon, 22 Jun 2015 21:04:32 +0200 Message-Id: <1434999889-849-8-git-send-email-armbru@redhat.com> In-Reply-To: <1434999889-849-1-git-send-email-armbru@redhat.com> References: <1434999889-849-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 07/24] monitor: Split mon_get_cpu fn to remove ENV_GET_CPU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Crosthwaite , Peter Crosthwaite From: Peter Crosthwaite The monitor currently has one helper, mon_get_cpu() which will return an env pointer. The target specific users of this API want an env, but all the target agnostic users really just want the cpu pointer. These users then need to use the target-specifically defined ENV_GET_CPU to navigate back up to the CPU from the ENV. Split the API for the two uses cases to remove all need for ENV_GET_CPU. Reviewed-by: Richard Henderson Reviewed-by: Andreas F=C3=A4rber Signed-off-by: Peter Crosthwaite Acked-by: Luiz Capitulino Signed-off-by: Markus Armbruster --- monitor.c | 65 ++++++++++++++++++++++++++++-----------------------------= ------ 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/monitor.c b/monitor.c index 8b1dbf8..a5ba7fe 100644 --- a/monitor.c +++ b/monitor.c @@ -939,28 +939,28 @@ int monitor_set_cpu(int cpu_index) return 0; } =20 -static CPUArchState *mon_get_cpu(void) +static CPUState *mon_get_cpu(void) { if (!cur_mon->mon_cpu) { monitor_set_cpu(0); } cpu_synchronize_state(cur_mon->mon_cpu); - return cur_mon->mon_cpu->env_ptr; + return cur_mon->mon_cpu; +} + +static CPUArchState *mon_get_cpu_env(void) +{ + return mon_get_cpu()->env_ptr; } =20 int monitor_get_cpu_index(void) { - CPUState *cpu =3D ENV_GET_CPU(mon_get_cpu()); - return cpu->cpu_index; + return mon_get_cpu()->cpu_index; } =20 static void hmp_info_registers(Monitor *mon, const QDict *qdict) { - CPUState *cpu; - CPUArchState *env; - env =3D mon_get_cpu(); - cpu =3D ENV_GET_CPU(env); - cpu_dump_state(cpu, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU); + cpu_dump_state(mon_get_cpu(), (FILE *)mon, monitor_fprintf, CPU_DUMP= _FPU); } =20 static void hmp_info_jit(Monitor *mon, const QDict *qdict) @@ -993,12 +993,7 @@ static void hmp_info_history(Monitor *mon, const QDi= ct *qdict) =20 static void hmp_info_cpustats(Monitor *mon, const QDict *qdict) { - CPUState *cpu; - CPUArchState *env; - - env =3D mon_get_cpu(); - cpu =3D ENV_GET_CPU(env); - cpu_dump_statistics(cpu, (FILE *)mon, &monitor_fprintf, 0); + cpu_dump_statistics(mon_get_cpu(), (FILE *)mon, &monitor_fprintf, 0)= ; } =20 static void hmp_info_trace_events(Monitor *mon, const QDict *qdict) @@ -1131,16 +1126,14 @@ static void monitor_printc(Monitor *mon, int c) static void memory_dump(Monitor *mon, int count, int format, int wsize, hwaddr addr, int is_physical) { - CPUArchState *env; int l, line_size, i, max_digits, len; uint8_t buf[16]; uint64_t v; =20 if (format =3D=3D 'i') { - int flags; - flags =3D 0; - env =3D mon_get_cpu(); + int flags =3D 0; #ifdef TARGET_I386 + CPUArchState *env =3D mon_get_cpu_env(); if (wsize =3D=3D 2) { flags =3D 1; } else if (wsize =3D=3D 4) { @@ -1161,10 +1154,11 @@ static void memory_dump(Monitor *mon, int count, = int format, int wsize, } #endif #ifdef TARGET_PPC + CPUArchState *env =3D mon_get_cpu_env(); flags =3D msr_le << 16; flags |=3D env->bfd_mach; #endif - monitor_disas(mon, env, addr, count, is_physical, flags); + monitor_disas(mon, mon_get_cpu_env(), addr, count, is_physical, = flags); return; } =20 @@ -1203,8 +1197,7 @@ static void memory_dump(Monitor *mon, int count, in= t format, int wsize, if (is_physical) { cpu_physical_memory_read(addr, buf, l); } else { - env =3D mon_get_cpu(); - if (cpu_memory_rw_debug(ENV_GET_CPU(env), addr, buf, l, 0) <= 0) { + if (cpu_memory_rw_debug(mon_get_cpu(), addr, buf, l, 0) < 0)= { monitor_printf(mon, " Cannot access memory\n"); break; } @@ -1583,7 +1576,7 @@ static void hmp_info_tlb(Monitor *mon, const QDict = *qdict) { CPUArchState *env; =20 - env =3D mon_get_cpu(); + env =3D mon_get_cpu_env(); =20 if (!(env->cr[0] & CR0_PG_MASK)) { monitor_printf(mon, "PG disabled\n"); @@ -1806,7 +1799,7 @@ static void hmp_info_mem(Monitor *mon, const QDict = *qdict) { CPUArchState *env; =20 - env =3D mon_get_cpu(); + env =3D mon_get_cpu_env(); =20 if (!(env->cr[0] & CR0_PG_MASK)) { monitor_printf(mon, "PG disabled\n"); @@ -1843,7 +1836,7 @@ static void print_tlb(Monitor *mon, int idx, tlb_t = *tlb) =20 static void hmp_info_tlb(Monitor *mon, const QDict *qdict) { - CPUArchState *env =3D mon_get_cpu(); + CPUArchState *env =3D mon_get_cpu_env(); int i; =20 monitor_printf (mon, "ITLB:\n"); @@ -1859,7 +1852,7 @@ static void hmp_info_tlb(Monitor *mon, const QDict = *qdict) #if defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_XTENS= A) static void hmp_info_tlb(Monitor *mon, const QDict *qdict) { - CPUArchState *env1 =3D mon_get_cpu(); + CPUArchState *env1 =3D mon_get_cpu_env(); =20 dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1); } @@ -2920,7 +2913,7 @@ typedef struct MonitorDef { #if defined(TARGET_I386) static target_long monitor_get_pc (const struct MonitorDef *md, int val) { - CPUArchState *env =3D mon_get_cpu(); + CPUArchState *env =3D mon_get_cpu_env(); return env->eip + env->segs[R_CS].base; } #endif @@ -2928,7 +2921,7 @@ static target_long monitor_get_pc (const struct Mon= itorDef *md, int val) #if defined(TARGET_PPC) static target_long monitor_get_ccr (const struct MonitorDef *md, int val= ) { - CPUArchState *env =3D mon_get_cpu(); + CPUArchState *env =3D mon_get_cpu_env(); unsigned int u; int i; =20 @@ -2941,31 +2934,31 @@ static target_long monitor_get_ccr (const struct = MonitorDef *md, int val) =20 static target_long monitor_get_msr (const struct MonitorDef *md, int val= ) { - CPUArchState *env =3D mon_get_cpu(); + CPUArchState *env =3D mon_get_cpu_env(); return env->msr; } =20 static target_long monitor_get_xer (const struct MonitorDef *md, int val= ) { - CPUArchState *env =3D mon_get_cpu(); + CPUArchState *env =3D mon_get_cpu_env(); return env->xer; } =20 static target_long monitor_get_decr (const struct MonitorDef *md, int va= l) { - CPUArchState *env =3D mon_get_cpu(); + CPUArchState *env =3D mon_get_cpu_env(); return cpu_ppc_load_decr(env); } =20 static target_long monitor_get_tbu (const struct MonitorDef *md, int val= ) { - CPUArchState *env =3D mon_get_cpu(); + CPUArchState *env =3D mon_get_cpu_env(); return cpu_ppc_load_tbu(env); } =20 static target_long monitor_get_tbl (const struct MonitorDef *md, int val= ) { - CPUArchState *env =3D mon_get_cpu(); + CPUArchState *env =3D mon_get_cpu_env(); return cpu_ppc_load_tbl(env); } #endif @@ -2974,7 +2967,7 @@ static target_long monitor_get_tbl (const struct Mo= nitorDef *md, int val) #ifndef TARGET_SPARC64 static target_long monitor_get_psr (const struct MonitorDef *md, int val= ) { - CPUArchState *env =3D mon_get_cpu(); + CPUArchState *env =3D mon_get_cpu_env(); =20 return cpu_get_psr(env); } @@ -2982,7 +2975,7 @@ static target_long monitor_get_psr (const struct Mo= nitorDef *md, int val) =20 static target_long monitor_get_reg(const struct MonitorDef *md, int val) { - CPUArchState *env =3D mon_get_cpu(); + CPUArchState *env =3D mon_get_cpu_env(); return env->regwptr[val]; } #endif @@ -3318,7 +3311,7 @@ static int get_monitor_def(target_long *pval, const= char *name) if (md->get_value) { *pval =3D md->get_value(md, md->offset); } else { - CPUArchState *env =3D mon_get_cpu(); + CPUArchState *env =3D mon_get_cpu_env(); ptr =3D (uint8_t *)env + md->offset; switch(md->type) { case MD_I32: --=20 1.9.3