From patchwork Fri Dec 11 17:04:49 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 40918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3BF91B6EF7 for ; Sat, 12 Dec 2009 04:52:45 +1100 (EST) Received: from localhost ([127.0.0.1]:35591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NJ9fW-0007Mf-EM for incoming@patchwork.ozlabs.org; Fri, 11 Dec 2009 12:52:42 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NJ91r-0003v7-4z for qemu-devel@nongnu.org; Fri, 11 Dec 2009 12:11:43 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NJ91m-0003rn-8Q for qemu-devel@nongnu.org; Fri, 11 Dec 2009 12:11:42 -0500 Received: from [199.232.76.173] (port=46079 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NJ91l-0003rc-TZ for qemu-devel@nongnu.org; Fri, 11 Dec 2009 12:11:38 -0500 Received: from mx20.gnu.org ([199.232.41.8]:41336) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NJ91l-00065k-4b for qemu-devel@nongnu.org; Fri, 11 Dec 2009 12:11:37 -0500 Received: from mail.codesourcery.com ([38.113.113.100]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NJ91k-0007L9-Ai for qemu-devel@nongnu.org; Fri, 11 Dec 2009 12:11:36 -0500 Received: (qmail 10230 invoked from network); 11 Dec 2009 17:04:54 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Dec 2009 17:04:54 -0000 From: Nathan Froyd To: qemu-devel@nongnu.org Date: Fri, 11 Dec 2009 09:04:49 -0800 Message-Id: <1260551091-2890-6-git-send-email-froydnj@codesourcery.com> X-Mailer: git-send-email 1.6.3.2 In-Reply-To: <1260551091-2890-1-git-send-email-froydnj@codesourcery.com> References: <1260551091-2890-1-git-send-email-froydnj@codesourcery.com> X-detected-operating-system: by mx20.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [Qemu-devel] [PATCH 5/7] linux-user: add core dump support for MIPS X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Nathan Froyd --- linux-user/elfload.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 97dc3a7..eb89f5f 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -594,6 +594,52 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i regs->regs[29] = infop->start_stack; } +/* See linux kernel: arch/mips/include/asm/elf.h. */ +#define ELF_NREG 45 +typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG]; + +/* See linux kernel: arch/mips/include/asm/reg.h. */ +enum { +#ifdef TARGET_MIPS64 + TARGET_EF_R0 = 0, +#else + TARGET_EF_R0 = 6, +#endif + TARGET_EF_R26 = TARGET_EF_R0 + 26, + TARGET_EF_R27 = TARGET_EF_R0 + 27, + TARGET_EF_LO = TARGET_EF_R0 + 32, + TARGET_EF_HI = TARGET_EF_R0 + 33, + TARGET_EF_CP0_EPC = TARGET_EF_R0 + 34, + TARGET_EF_CP0_BADVADDR = TARGET_EF_R0 + 35, + TARGET_EF_CP0_STATUS = TARGET_EF_R0 + 36, + TARGET_EF_CP0_CAUSE = TARGET_EF_R0 + 37 +}; + +/* See linux kernel: arch/mips/kernel/process.c:elf_dump_regs. */ +static void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUState *env) +{ + int i; + + for (i = 0; i < TARGET_EF_R0; i++) { + (*regs)[i] = 0; + } + (*regs)[TARGET_EF_R0] = 0; + + for (i = 1; i < ARRAY_SIZE(env->active_tc.gpr); i++) { + (*regs)[TARGET_EF_R0 + i] = tswapl(env->active_tc.gpr[i]); + } + + (*regs)[TARGET_EF_R26] = 0; + (*regs)[TARGET_EF_R27] = 0; + (*regs)[TARGET_EF_LO] = tswapl(env->active_tc.LO[0]); + (*regs)[TARGET_EF_HI] = tswapl(env->active_tc.HI[0]); + (*regs)[TARGET_EF_CP0_EPC] = tswapl(env->active_tc.PC); + (*regs)[TARGET_EF_CP0_BADVADDR] = tswapl(env->CP0_BadVAddr); + (*regs)[TARGET_EF_CP0_STATUS] = tswapl(env->CP0_Status); + (*regs)[TARGET_EF_CP0_CAUSE] = tswapl(env->CP0_Cause); +} + +#define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE 4096 #endif /* TARGET_MIPS */