From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RcvjJ-0003Ai-P0 for qemu-devel@nongnu.org; Tue, 20 Dec 2011 04:11:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RcvjD-0003RZ-Vt for qemu-devel@nongnu.org; Tue, 20 Dec 2011 04:11:25 -0500 Received: from [222.73.24.84] (port=51254 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RcvjD-0003RB-0a for qemu-devel@nongnu.org; Tue, 20 Dec 2011 04:11:19 -0500 Message-ID: <4EF051ED.4070508@cn.fujitsu.com> Date: Tue, 20 Dec 2011 17:14:21 +0800 From: Wen Congyang MIME-Version: 1.0 References: <4EF04D58.3030900@cn.fujitsu.com> In-Reply-To: <4EF04D58.3030900@cn.fujitsu.com> Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1 Subject: [Qemu-devel] [RFC][PATCH 7/8 v3] target-i386: add API to get dump info List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel , Jan Kiszka , Dave Anderson , HATAYAMA Daisuke Dump info contains: endian, class and architecture. The next patch will use these information to create vmcore. Signed-off-by: Wen Congyang --- cpu-all.h | 3 +++ dump.h | 10 ++++++++++ target-i386/arch-dump.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 0 deletions(-) create mode 100644 dump.h diff --git a/cpu-all.h b/cpu-all.h index 4d87d51..c53221a 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -23,6 +23,7 @@ #include "qemu-tls.h" #include "cpu-common.h" #include "memory_mapping.h" +#include "dump.h" /* some important defines: * @@ -592,11 +593,13 @@ int cpu_write_elf64_note(Monitor *mon, int fd, CPUState *env, int cpuid, int cpu_write_elf32_note(Monitor *mon, int fd, CPUState *env, int cpuid, target_phys_addr_t *offset); int cpu_add_extra_memory_mapping(Monitor *mon, MemoryMappingList *list); +int cpu_get_dump_info(DumpInfo *info); #else #define cpu_get_memory_mapping(list, env) #define cpu_write_elf64_note(mon, fd, env, cpuid, offset) ({ -1; }) #define cpu_write_elf32_note(mon, fd, env, cpuid, offset) ({ -1; }) #define cpu_add_extra_memory_mapping(mon, list) ({ 0; }) +#define cpu_get_dump_info(info) ({ -1; }) #endif #endif /* CPU_ALL_H */ diff --git a/dump.h b/dump.h new file mode 100644 index 0000000..a37de45 --- /dev/null +++ b/dump.h @@ -0,0 +1,10 @@ +#ifndef DUMP_H +#define DUMP_H + +typedef struct DumpInfo { + int d_machine; /* Architecture */ + int d_endian; /* ELFDATA2LSB or ELFDATA2MSB */ + int d_class; /* ELFCLASS32 or ELFCLASS64 */ +} DumpInfo; + +#endif diff --git a/target-i386/arch-dump.c b/target-i386/arch-dump.c index 2410c6a..87b19b6 100644 --- a/target-i386/arch-dump.c +++ b/target-i386/arch-dump.c @@ -15,6 +15,7 @@ #include "cpu.h" #include "cpu-all.h" +#include "dump.h" #include "monitor.h" /* PAE Paging or IA-32e Paging */ @@ -542,3 +543,36 @@ int cpu_add_extra_memory_mapping(Monitor *mon, MemoryMappingList *list) #endif return 0; } + +int cpu_get_dump_info(DumpInfo *info) +{ + bool lma = false; + RAMBlock *block; + +#ifdef TARGET_X86_64 + lma = !!(first_cpu->hflags & HF_LMA_MASK); +#endif + + if (lma) { + info->d_machine = EM_X86_64; + } else { + info->d_machine = EM_386; + } + info->d_endian = ELFDATA2LSB; + + if (lma) { + info->d_class = ELFCLASS64; + } else { + info->d_class = ELFCLASS32; + } + + QLIST_FOREACH(block, &ram_list.blocks, next) { + if (!lma && (block->offset + block->length > UINT_MAX)) { + /* The memory size is greater than 4G */ + info->d_class = ELFCLASS32; + break; + } + } + + return 0; +} -- 1.7.1