monitor/target-ppc: Define target_get_monitor_def
PATCH v6 1/1 monitor/target-ppc: Define target_get_monitor_def
At the moment get_monitor_def() returns only registers from statically defined monitor_defs array. However there is a lot of BOOK3S SPRs which are not in the list and cannot be printed from the monitor.
This adds a new target platform hook - target_get_monitor_def(). The hook is called if a register was not found in the static array returned by the target_monitor_defs() hook.
The hook is only defined for POWERPC, it returns registered SPRs and fails on unregistered ones providing the user with information on what is actually supported on the running CPU. The register value is saved as uint64_t as it is the biggest supported register size; target_ulong cannot be used because of the stub - it is in a "common" code and cannot include "cpu.h", etc; this is also why the hook prototype is redefined in the stub instead of being included from some header.
This replaces static descriptors for GPRs, FPRs, SRs with a helper which looks for a value in a corresponding array in the CPUPPCState. The immediate effect is that all 32 SRs can be printed now (instead of 16); later this can be reused for VSX or TM registers.
This replaces callbacks for MSR and XER with static descriptors in monitor_defs as they are stored in CPUPPCState.
While we are here, this adds "cr" as a synonym of "ccr".
---
Changes:
v6:
* fixed to compile of 32bit targets by changing ppc_cpu_get_reg_num not to receive registers array and setting the return register value right in target_get_monitor_def()
v5:
* rebased on the latest spapr-next (minor conflict stubs/Makefile.objs)
* removed duplicates
v4:
* rebased on the current upstream which moved MonitorDef to target-ppc
* reverted the change for registers other than GPR/FPR/SPR, such as FPSCR/PC/MSR/...
* removed CPU hook and made it a stub
v3:
* removed the check for endptr as strtoul() always initializes it
* check if there is any number after r/f/sr and fail if none
* added tolower()/strncasecmp() to support both r/f/sr and R/F/SR
v2:
* handles r**, f**, sr** if their numbers were parsed completely and correctly
* added "cr" as synonym of "ccr"
--- include/monitor/hmp-target.h | 1 + monitor.c | 10 +- stubs/Makefile.objs | 1 + stubs/target-get-monitor-def.c | 31 ++++++ target-ppc/cpu-qom.h | 2 + target-ppc/monitor.c | 235 +++++++++++------------------------------ 6 files changed, 107 insertions(+), 173 deletions(-) create mode 100644 stubs/target-get-monitor-def.c
include/monitor/hmp-target.h +1 -0
@@ -35,6 +35,7 @@ struct MonitorDef { };const MonitorDef *target_monitor_defs (void ); +int target_get_monitor_def (CPUState *cs,const char *name,uint64_t *pval);CPUArchState *mon_get_cpu_env (void );CPUState *mon_get_cpu (void );
monitor.c +9 -1
@@ -2136,6 +2136,8 @@ static int get_monitor_def(target_long *pval, const char *name) {const MonitorDef *md =target_monitor_defs ();void *ptr; +uint64_t tmp =0 ; +int ret;if (md ==NULL ) {return -1 ;
@@ -2163,7 +2165,13 @@ static int get_monitor_def(target_long *pval, const char *name)return 0 ; } } -return -1 ; + + ret =target_get_monitor_def (mon_get_cpu (), name, &tmp); +if (!ret) { + *pval = (target_long ) tmp; + } + +return ret; }static void next (void )
stubs/Makefile.objs +1 -0
@@ -36,4 +36,5 @@ stub-obj-y += cpus.o stub-obj-y += kvm.o stub-obj-y += qmp_pc_dimm_device_list.o stub-obj-y += target-monitor-defs.o +stub-obj-y += target-get-monitor-def.o stub-obj-y += vhost.o
stubs/target-get-monitor-def.c new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Stub for target_get_monitor_def. +* +* Copyright IBM Corp., 2015 +* +* Author: Alexey Kardashevskiy <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, +* or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +#include "stdint.h" + +typedef struct CPUState CPUState ; + +int target_get_monitor_def (CPUState *cs,const char *name,uint64_t *pval); + +int target_get_monitor_def (CPUState *cs,const char *name,uint64_t *pval) +{ +return -1 ; +}
target-ppc/cpu-qom.h +2 -0
@@ -118,6 +118,8 @@ void ppc_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, int flags);void ppc_cpu_dump_statistics (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags); +int ppc_cpu_get_monitor_def (CPUState *cs,const char *name, +uint64_t *pval);hwaddr ppc_cpu_get_phys_page_debug (CPUState *cpu,vaddr addr);int ppc_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int ppc_cpu_gdb_read_register_apple (CPUState *cpu,uint8_t *buf,int reg);
target-ppc/monitor.c +63 -172
260 lines not on this page · raw message
Signature · 1 line
2.5.0.rc3