(no subject)
The monivation of this set is simple. Recently we have proposed patch to monitor.c with specific x86 APIC HMP commands. The patchset was denied with the main motivation "No more arch specific code in monitor.c" This patchset is the first step to move arch specific code from monitor.c targets.
So, monitor.c already contains a lot of generic code, as well as the target specifics code and eventually monitor.c volume will only grow. This trend leads to a variety of fouling code ifdeffery(and combinations thereof), poor readability, and entanglement of architecture of the project. If someone wants to improve processing logic commands at the monitor, it isn't necessarily must differentiate amongst the implementation of some ARM or x86_64 specific commands, because the project already has separation of target specific code on directories.
The presented solution is not the best, but it is quite simple (PATCH doesn't add more code!) and decides the above mentioned issue. Subsequently it will not prevent the introduction of more advanced mechanism that can more effectively resolve the issue.
There is a issue with the placement of code for multiple architectures (isn't for everyone), but this code is very small. This patch is a step towards solving the issue associated with maintaining the purity of the code and structure of the project, which solves not all, but doing a little better than it is.
Pavel Butsykin (3):
hmp-commands-info: move info_cmds content out of monitor.c
monitor: remove target-specific code from monitor.c
monitor: added generation of documentation for hmp-commands-info.hx
.gitignore | 1 + Makefile | 9 +- Makefile.target | 5 +- hmp-commands-info.hx | 715 ++++++++++++++++++++++ hmp-commands.hx | 120 ---- include/monitor/monitor-common.h | 43 ++ monitor.c | 1227 +------------------------------------- qemu-doc.texi | 2 + target-i386/Makefile.objs | 2 +- target-i386/monitor.c | 489 +++++++++++++++ target-ppc/Makefile.objs | 2 +- target-ppc/monitor.c | 250 ++++++++ target-sh4/Makefile.objs | 1 + target-sh4/monitor.c | 52 ++ target-sparc/Makefile.objs | 2 +- target-sparc/monitor.c | 153 +++++ target-xtensa/Makefile.objs | 1 + target-xtensa/monitor.c | 34 ++ 18 files changed, 1762 insertions(+), 1346 deletions(-) create mode 100644 hmp-commands-info.hx create mode 100644 include/monitor/monitor-common.h create mode 100644 target-i386/monitor.c create mode 100644 target-ppc/monitor.c create mode 100644 target-sh4/monitor.c create mode 100644 target-sparc/monitor.c create mode 100644 target-xtensa/monitor.c
PATCH 1/3 hmp-commands-info: move info_cmds content out of monitor.c
From: Pavel Butsykin <[email protected]>
For moving target- and device-specific code from monitor.c, to beginning we move info_cmds content to hmp-commands-info.hx
--- Makefile.target | 5 +- hmp-commands-info.hx | 711 +++++++++++++++++++++++++++++++++++++++++++++++++++ monitor.c | 373 +-------------------------- 3 files changed, 717 insertions(+), 372 deletions(-) create mode 100644 hmp-commands-info.hx
Makefile.target +4 -1
@@ -151,7 +151,7 @@ else obj-y += hw/$(TARGET_BASE_ARCH)/ endif -GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h +GENERATED_HEADERS += hmp-commands.h hmp-commands-info.h qmp-commands-old.h endif # CONFIG_SOFTMMU
@@ -193,6 +193,9 @@ gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh hmp-commands.h: $(SRC_PATH)/hmp-commands.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@") +hmp-commands-info.h: $(SRC_PATH)/hmp-commands-info.hx + $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@") + qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
hmp-commands-info.hx new file +711 -0
711 lines not on this page · raw message
monitor.c +2 -371
379 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 2/3 monitor: remove target-specific code from monitor.c
In reply to Denis V. LunevFrom: Pavel Butsykin <[email protected]>
Move target-specific code out of /monitor.c to /target-*/monitor.c, this will avoid code cluttering and using random ifdeffery. The solution is quite simple, but solves the issue of the separation of target-specific code from monitor
--- include/monitor/monitor-common.h | 43 ++ monitor.c | 854 +-------------------------------------- target-i386/Makefile.objs | 2 +- target-i386/monitor.c | 489 ++++++++++++++++++++++ target-ppc/Makefile.objs | 2 +- target-ppc/monitor.c | 250 ++++++++++++ target-sh4/Makefile.objs | 1 + target-sh4/monitor.c | 52 +++ target-sparc/Makefile.objs | 2 +- target-sparc/monitor.c | 153 +++++++ target-xtensa/Makefile.objs | 1 + target-xtensa/monitor.c | 34 ++ 12 files changed, 1032 insertions(+), 851 deletions(-) create mode 100644 include/monitor/monitor-common.h create mode 100644 target-i386/monitor.c create mode 100644 target-ppc/monitor.c create mode 100644 target-sh4/monitor.c create mode 100644 target-sparc/monitor.c create mode 100644 target-xtensa/monitor.c
include/monitor/monitor-common.h new file +43 -0
@@ -0,0 +1,43 @@ +/* +* QEMU monitor +* +* Copyright (c) 2003-2004 Fabrice Bellard +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +#ifndef MONITOR_COMMON_H +#define MONITOR_COMMON_H + +#define MD_TLONG 0 +#define MD_I32 1 + +typedef struct MonitorDef { +const char *name; +int offset; +target_long (*get_value)(const struct MonitorDef *md,int val); +int type; +}MonitorDef ; + +CPUArchState *mon_get_cpu_env (void ); + +void hmp_info_mem (Monitor *mon,const QDict *qdict); +void hmp_info_tlb (Monitor *mon,const QDict *qdict); +void hmp_mce (Monitor *mon,const QDict *qdict); + +#endif /* MONITOR_COMMON */
monitor.c +6 -848
886 lines not on this page · raw message
target-i386/Makefile.objs +1 -1
@@ -2,6 +2,6 @@ obj-y += translate.o helper.o cpu.o obj-y += excp_helper.o fpu_helper.o cc_helper.o int_helper.o svm_helper.o obj-y += smm_helper.o misc_helper.o mem_helper.o seg_helper.o obj-y += gdbstub.o -obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o +obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o monitor.o obj-$(CONFIG_KVM) += kvm.o obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
target-i386/monitor.c new file +489 -0
489 lines not on this page · raw message
target-ppc/Makefile.objs +1 -1
@@ -1,7 +1,7 @@ obj-y += cpu-models.o obj-y += translate.o ifeq ($(CONFIG_SOFTMMU),y) -obj-y += machine.o mmu_helper.o mmu-hash32.o +obj-y += machine.o mmu_helper.o mmu-hash32.o monitor.o obj-$(TARGET_PPC64) += mmu-hash64.o arch_dump.o endif obj-$(CONFIG_KVM) += kvm.o kvm_ppc.o
target-ppc/monitor.c new file +250 -0
250 lines not on this page · raw message
target-sh4/Makefile.objs +1 -0
@@ -1,2 +1,3 @@ obj-y += translate.o op_helper.o helper.o cpu.o +obj-$(CONFIG_SOFTMMU) += monitor.o obj-y += gdbstub.o
target-sh4/monitor.c new file +52 -0
52 lines not on this page · raw message
target-sparc/Makefile.objs +1 -1
@@ -1,4 +1,4 @@ -obj-$(CONFIG_SOFTMMU) += machine.o +obj-$(CONFIG_SOFTMMU) += machine.o monitor.o obj-y += translate.o helper.o cpu.o obj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o obj-$(TARGET_SPARC) += int32_helper.o
target-sparc/monitor.c new file +153 -0
153 lines not on this page · raw message
target-xtensa/Makefile.objs +1 -0
@@ -2,5 +2,6 @@ obj-y += xtensa-semi.o obj-y += core-dc232b.o obj-y += core-dc233c.o obj-y += core-fsf.o +obj-$(CONFIG_SOFTMMU) += monitor.o obj-y += translate.o op_helper.o helper.o cpu.o obj-y += gdbstub.o
target-xtensa/monitor.c new file +34 -0
@@ -0,0 +1,34 @@ +/* +* QEMU monitor +* +* Copyright (c) 2003-2004 Fabrice Bellard +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +#include "cpu.h" +#include "monitor/monitor.h" +#include "monitor/monitor-common.h" +#include "hmp.h" + +void hmp_info_tlb (Monitor *mon,const QDict *qdict) +{ +CPUArchState *env1 =mon_get_cpu_env (); + +dump_mmu ((FILE *)mon, (fprintf_function )monitor_printf, env1); +}
Signature · 1 line
2.1.4
PATCH 3/3 monitor: added generation of documentation for hmp-commands-info.hx
In reply to Denis V. LunevFrom: Pavel Butsykin <[email protected]>
It will be easier if you need to add info-commands to edit only hmp-commands-info.hx, before this had to edit monitor.c and hmp-commands.hx
--- .gitignore | 1 + Makefile | 9 ++-- hmp-commands-info.hx | 4 ++ hmp-commands.hx | 120 --------------------------------------------------- qemu-doc.texi | 2 + 5 files changed, 13 insertions(+), 123 deletions(-)
.gitignore +1 -0
@@ -47,6 +47,7 @@ /qemu-ga /qemu-bridge-helper /qemu-monitor.texi +/qemu-monitor-info.texi /qmp-commands.txt /vscclient /fsdev/virtfs-proxy-helper
Makefile +6 -3
@@ -344,7 +344,7 @@ qemu-%.tar.bz2: $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)" distclean: clean - rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi + rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi rm -f config-all-devices.mak config-all-disas.mak config.status rm -f po/*.mo tests/qemu-iotests/common.env rm -f roms/seabios/config.mak roms/vgabios/config.mak
@@ -508,13 +508,16 @@ qemu-options.texi: $(SRC_PATH)/qemu-options.hx qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@," GEN $@") +qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx + $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@," GEN $@") + qmp-commands.txt: $(SRC_PATH)/qmp-commands.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -q < $< > $@," GEN $@") qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@," GEN $@") -qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi +qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi $(call quiet-command, \ perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \ $(POD2MAN) --section=1 --center=" " --release=" " qemu.pod > $@, \
@@ -551,7 +554,7 @@ pdf: qemu-doc.pdf qemu-tech.pdf qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \ qemu-img.texi qemu-nbd.texi qemu-options.texi \ - qemu-monitor.texi qemu-img-cmds.texi + qemu-monitor.texi qemu-monitor-info.texi qemu-img-cmds.texi ifdef CONFIG_WIN32
hmp-commands-info.hx +4 -0
@@ -6,6 +6,9 @@ HXCOMM monitor info commands HXCOMM HXCOMM can be used for comments, discarded from both texi and C STEXI +@item info @var{subcommand} +@findex info +Show various information about the system state. @table @option ETEXI
@@ -708,4 +711,5 @@ ETEXI STEXI @end table +@end table ETEXI
hmp-commands.hx +0 -120
123 lines not on this page · raw message
qemu-doc.texi +2 -0
@@ -391,6 +391,8 @@ The following commands are available: @include qemu-monitor.texi +@include qemu-monitor-info.texi + @subsection Integer expressions The monitor understands integers expressions for every integer
Signature · 1 line
2.1.4