From patchwork Thu Feb 9 03:26:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 140298 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8B69EB71A7 for ; Thu, 9 Feb 2012 14:23:39 +1100 (EST) Received: from localhost ([::1]:47626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvKbe-00006B-Aj for incoming@patchwork.ozlabs.org; Wed, 08 Feb 2012 22:23:34 -0500 Received: from eggs.gnu.org ([140.186.70.92]:43499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvKbV-000064-HF for qemu-devel@nongnu.org; Wed, 08 Feb 2012 22:23:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvKbR-0001hB-Ix for qemu-devel@nongnu.org; Wed, 08 Feb 2012 22:23:25 -0500 Received: from [222.73.24.84] (port=63576 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvKbQ-0001gx-IX for qemu-devel@nongnu.org; Wed, 08 Feb 2012 22:23:21 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 8A93F17011D; Thu, 9 Feb 2012 11:23:16 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id q193NE91000455; Thu, 9 Feb 2012 11:23:15 +0800 Received: from [10.167.225.226] ([10.167.225.226]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2012020911214670-576903 ; Thu, 9 Feb 2012 11:21:46 +0800 Message-ID: <4F333CEC.7080007@cn.fujitsu.com> Date: Thu, 09 Feb 2012 11:26:36 +0800 From: Wen Congyang User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100413 Fedora/3.0.4-2.fc13 Thunderbird/3.0.4 MIME-Version: 1.0 To: qemu-devel , Jan Kiszka , Dave Anderson , HATAYAMA Daisuke , Luiz Capitulino , Eric Blake References: <4F333AAA.1070601@cn.fujitsu.com> In-Reply-To: <4F333AAA.1070601@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2012-02-09 11:21:46, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2012-02-09 11:21:47, Serialize complete at 2012-02-09 11:21:47 X-detected-operating-system: by eggs.gnu.org: FreeBSD 6.x (1) X-Received-From: 222.73.24.84 Subject: [Qemu-devel] [RFC][PATCH 08/16 v6] target-i386: add API to get dump info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 290c43a..268d1f6 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: * @@ -531,11 +532,13 @@ int cpu_write_elf64_note(int fd, CPUState *env, int cpuid, int cpu_write_elf32_note(int fd, CPUState *env, int cpuid, target_phys_addr_t *offset); int cpu_add_extra_memory_mapping(MemoryMappingList *list); +int cpu_get_dump_info(ArchDumpInfo *info); #else #define cpu_get_memory_mapping(list, env) #define cpu_write_elf64_note(fd, env, cpuid, offset) ({ -1; }) #define cpu_write_elf32_note(fd, env, cpuid, offset) ({ -1; }) #define cpu_add_extra_memory_mapping(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..a36468b --- /dev/null +++ b/dump.h @@ -0,0 +1,10 @@ +#ifndef DUMP_H +#define DUMP_H + +typedef struct ArchDumpInfo { + int d_machine; /* Architecture */ + int d_endian; /* ELFDATA2LSB or ELFDATA2MSB */ + int d_class; /* ELFCLASS32 or ELFCLASS64 */ +} ArchDumpInfo; + +#endif diff --git a/target-i386/arch-dump.c b/target-i386/arch-dump.c index d96f6ae..92a53bc 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 */ @@ -538,3 +539,36 @@ int cpu_add_extra_memory_mapping(MemoryMappingList *list) #endif return 0; } + +int cpu_get_dump_info(ArchDumpInfo *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; +}