diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-06-07 08:22:56 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-06-07 09:20:17 +0200 |
commit | 5f86146fb3ad18ef25036329f48d9ea2b7f4ab70 (patch) | |
tree | a60296ec605946c0c0266e7c79577b5fb73fd585 | |
parent | 4720bd050655a56b4b048d8856a03ae187481a7f (diff) | |
download | qemu-5f86146fb3ad18ef25036329f48d9ea2b7f4ab70.tar.gz qemu-5f86146fb3ad18ef25036329f48d9ea2b7f4ab70.tar.bz2 qemu-5f86146fb3ad18ef25036329f48d9ea2b7f4ab70.zip |
dump: remove dumping stuff from cpu-all.h
This simplifies things, because they will only be included for softmmu
targets and because the stubs are taken out-of-line in separate files,
which in the future could even be compiled only once.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | Makefile.target | 10 | ||||
-rw-r--r-- | cpu-all.h | 70 | ||||
-rw-r--r-- | dump-stub.c | 77 | ||||
-rw-r--r-- | dump.c | 11 | ||||
-rw-r--r-- | dump.h | 12 | ||||
-rw-r--r-- | memory_mapping-stub.c | 33 | ||||
-rw-r--r-- | memory_mapping.c | 3 | ||||
-rw-r--r-- | memory_mapping.h | 16 | ||||
-rw-r--r-- | target-i386/arch_memory_mapping.c | 1 |
9 files changed, 132 insertions, 101 deletions
diff --git a/Makefile.target b/Makefile.target index f1ec554699..4c811713ad 100644 --- a/Makefile.target +++ b/Makefile.target @@ -3,6 +3,8 @@ CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y) CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y) CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y) +CONFIG_NO_GET_MEMORY_MAPPING = $(if $(subst n,,$(CONFIG_HAVE_GET_MEMORY_MAPPING)),n,y) +CONFIG_NO_CORE_DUMP = $(if $(subst n,,$(CONFIG_HAVE_CORE_DUMP)),n,y) include ../config-host.mak include config-devices.mak @@ -144,10 +146,10 @@ obj-$(CONFIG_KVM) += kvm.o kvm-all.o obj-$(CONFIG_NO_KVM) += kvm-stub.o obj-$(CONFIG_VGA) += vga.o obj-y += memory.o savevm.o cputlb.o -obj-y += memory_mapping.o -obj-$(CONFIG_HAVE_GET_MEMORY_MAPPING) += arch_memory_mapping.o -obj-$(CONFIG_HAVE_CORE_DUMP) += arch_dump.o -obj-y += dump.o +obj-$(CONFIG_HAVE_GET_MEMORY_MAPPING) += memory_mapping.o arch_memory_mapping.o +obj-$(CONFIG_HAVE_CORE_DUMP) += dump.o arch_dump.o +obj-$(CONFIG_NO_GET_MEMORY_MAPPING) += memory_mapping-stub.o +obj-$(CONFIG_NO_CORE_DUMP) += dump-stub.o LIBS+=-lz QEMU_CFLAGS += $(VNC_TLS_CFLAGS) @@ -22,8 +22,6 @@ #include "qemu-common.h" #include "qemu-tls.h" #include "cpu-common.h" -#include "memory_mapping.h" -#include "dump.h" /* some important defines: * @@ -525,72 +523,4 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr, uint8_t *buf, int len, int is_write); -#if defined(CONFIG_HAVE_GET_MEMORY_MAPPING) -int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env); -bool cpu_paging_enabled(CPUArchState *env); -#else -static inline int cpu_get_memory_mapping(MemoryMappingList *list, - CPUArchState *env) -{ - return -1; -} - -static inline bool cpu_paging_enabled(CPUArchState *env) -{ - return true; -} -#endif - -typedef int (*write_core_dump_function)(void *buf, size_t size, void *opaque); -#if defined(CONFIG_HAVE_CORE_DUMP) -int cpu_write_elf64_note(write_core_dump_function f, CPUArchState *env, - int cpuid, void *opaque); -int cpu_write_elf32_note(write_core_dump_function f, CPUArchState *env, - int cpuid, void *opaque); -int cpu_write_elf64_qemunote(write_core_dump_function f, CPUArchState *env, - void *opaque); -int cpu_write_elf32_qemunote(write_core_dump_function f, CPUArchState *env, - void *opaque); -int cpu_get_dump_info(ArchDumpInfo *info); -ssize_t cpu_get_note_size(int class, int machine, int nr_cpus); -#else -static inline int cpu_write_elf64_note(write_core_dump_function f, - CPUArchState *env, int cpuid, - void *opaque) -{ - return -1; -} - -static inline int cpu_write_elf32_note(write_core_dump_function f, - CPUArchState *env, int cpuid, - void *opaque) -{ - return -1; -} - -static inline int cpu_write_elf64_qemunote(write_core_dump_function f, - CPUArchState *env, - void *opaque) -{ - return -1; -} - -static inline int cpu_write_elf32_qemunote(write_core_dump_function f, - CPUArchState *env, - void *opaque) -{ - return -1; -} - -static inline int cpu_get_dump_info(ArchDumpInfo *info) -{ - return -1; -} - -static inline ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) -{ - return -1; -} -#endif - #endif /* CPU_ALL_H */ diff --git a/dump-stub.c b/dump-stub.c new file mode 100644 index 0000000000..4c8bedb6ce --- /dev/null +++ b/dump-stub.c @@ -0,0 +1,77 @@ +/* + * QEMU dump + * + * Copyright Fujitsu, Corp. 2011, 2012 + * + * Authors: + * Wen Congyang <wency@cn.fujitsu.com> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#include "qemu-common.h" +#include <unistd.h> +#include "elf.h" +#include <sys/procfs.h> +#include <glib.h> +#include "cpu.h" +#include "cpu-all.h" +#include "targphys.h" +#include "monitor.h" +#include "kvm.h" +#include "dump.h" +#include "sysemu.h" +#include "bswap.h" +#include "memory_mapping.h" +#include "error.h" +#include "qmp-commands.h" +#include "gdbstub.h" + +/* we need this function in hmp.c */ +void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, + int64_t begin, bool has_length, int64_t length, + Error **errp) +{ + error_set(errp, QERR_UNSUPPORTED); +} + +int cpu_write_elf64_note(write_core_dump_function f, + CPUArchState *env, int cpuid, + void *opaque) +{ + return -1; +} + +int cpu_write_elf32_note(write_core_dump_function f, + CPUArchState *env, int cpuid, + void *opaque) +{ + return -1; +} + +int cpu_write_elf64_qemunote(write_core_dump_function f, + CPUArchState *env, + void *opaque) +{ + return -1; +} + +int cpu_write_elf32_qemunote(write_core_dump_function f, + CPUArchState *env, + void *opaque) +{ + return -1; +} + +int cpu_get_dump_info(ArchDumpInfo *info) +{ + return -1; +} + +ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) +{ + return -1; +} + @@ -29,7 +29,6 @@ #include "qmp-commands.h" #include "gdbstub.h" -#if defined(CONFIG_HAVE_CORE_DUMP) static uint16_t cpu_convert_to_target16(uint16_t val, int endian) { if (endian == ELFDATA2LSB) { @@ -876,13 +875,3 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, g_free(s); } - -#else -/* we need this function in hmp.c */ -void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, - int64_t begin, bool has_length, int64_t length, - Error **errp) -{ - error_set(errp, QERR_UNSUPPORTED); -} -#endif @@ -20,4 +20,16 @@ typedef struct ArchDumpInfo { int d_class; /* ELFCLASS32 or ELFCLASS64 */ } ArchDumpInfo; +typedef int (*write_core_dump_function)(void *buf, size_t size, void *opaque); +int cpu_write_elf64_note(write_core_dump_function f, CPUArchState *env, + int cpuid, void *opaque); +int cpu_write_elf32_note(write_core_dump_function f, CPUArchState *env, + int cpuid, void *opaque); +int cpu_write_elf64_qemunote(write_core_dump_function f, CPUArchState *env, + void *opaque); +int cpu_write_elf32_qemunote(write_core_dump_function f, CPUArchState *env, + void *opaque); +int cpu_get_dump_info(ArchDumpInfo *info); +ssize_t cpu_get_note_size(int class, int machine, int nr_cpus); + #endif diff --git a/memory_mapping-stub.c b/memory_mapping-stub.c new file mode 100644 index 0000000000..104281d78e --- /dev/null +++ b/memory_mapping-stub.c @@ -0,0 +1,33 @@ +/* + * QEMU memory mapping + * + * Copyright Fujitsu, Corp. 2011, 2012 + * + * Authors: + * Wen Congyang <wency@cn.fujitsu.com> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#include "cpu.h" +#include "cpu-all.h" +#include "memory_mapping.h" + +int qemu_get_guest_memory_mapping(MemoryMappingList *list) +{ + return -2; +} + +int cpu_get_memory_mapping(MemoryMappingList *list, + CPUArchState *env) +{ + return -1; +} + +bool cpu_paging_enabled(CPUArchState *env) +{ + return true; +} + diff --git a/memory_mapping.c b/memory_mapping.c index 8810bb09e3..1125e3fccf 100644 --- a/memory_mapping.c +++ b/memory_mapping.c @@ -165,8 +165,6 @@ void memory_mapping_list_init(MemoryMappingList *list) QTAILQ_INIT(&list->head); } -#if defined(CONFIG_HAVE_GET_MEMORY_MAPPING) - static CPUArchState *find_paging_enabled_cpu(CPUArchState *start_cpu) { CPUArchState *env; @@ -210,7 +208,6 @@ int qemu_get_guest_memory_mapping(MemoryMappingList *list) return 0; } -#endif void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list) { diff --git a/memory_mapping.h b/memory_mapping.h index a1aa64f4ca..3f003586d4 100644 --- a/memory_mapping.h +++ b/memory_mapping.h @@ -16,7 +16,6 @@ #include "qemu-queue.h" -#ifndef CONFIG_USER_ONLY /* The physical and virtual address in the memory mapping are contiguous. */ typedef struct MemoryMapping { target_phys_addr_t phys_addr; @@ -31,6 +30,9 @@ typedef struct MemoryMappingList { QTAILQ_HEAD(, MemoryMapping) head; } MemoryMappingList; +int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env); +bool cpu_paging_enabled(CPUArchState *env); + /* * add or merge the memory region [phys_addr, phys_addr + length) into the * memory mapping's list. The region's virtual address starts with virt_addr, @@ -51,14 +53,7 @@ void memory_mapping_list_init(MemoryMappingList *list); * -1: failed * -2: unsupported */ -#if defined(CONFIG_HAVE_GET_MEMORY_MAPPING) int qemu_get_guest_memory_mapping(MemoryMappingList *list); -#else -static inline int qemu_get_guest_memory_mapping(MemoryMappingList *list) -{ - return -2; -} -#endif /* get guest's memory mapping without do paging(virtual address is 0). */ void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list); @@ -66,9 +61,4 @@ void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list); void memory_mapping_filter(MemoryMappingList *list, int64_t begin, int64_t length); -#else - -/* We use MemoryMappingList* in cpu-all.h */ -typedef struct MemoryMappingList MemoryMappingList; -#endif #endif diff --git a/target-i386/arch_memory_mapping.c b/target-i386/arch_memory_mapping.c index bd50e1143a..efb0211fdc 100644 --- a/target-i386/arch_memory_mapping.c +++ b/target-i386/arch_memory_mapping.c @@ -13,6 +13,7 @@ #include "cpu.h" #include "cpu-all.h" +#include "memory_mapping.h" /* PAE Paging or IA-32e Paging */ static void walk_pte(MemoryMappingList *list, target_phys_addr_t pte_start_addr, |