From patchwork Sun May 27 05:32:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia Liu X-Patchwork-Id: 161535 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 18329B6F86 for ; Sun, 27 May 2012 15:50:38 +1000 (EST) Received: from localhost ([::1]:42649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYW9o-0000dh-B3 for incoming@patchwork.ozlabs.org; Sun, 27 May 2012 01:36:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYW9e-0000RK-Ey for qemu-devel@nongnu.org; Sun, 27 May 2012 01:36:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SYW9c-0000Zg-Lt for qemu-devel@nongnu.org; Sun, 27 May 2012 01:36:38 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:55318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SYW9c-0000ZQ-Cz for qemu-devel@nongnu.org; Sun, 27 May 2012 01:36:36 -0400 Received: by dadv2 with SMTP id v2so3251236dad.4 for ; Sat, 26 May 2012 22:36:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references :content-type; bh=xcMBOicWLJTnebPAMxhi/ef2tEhKpdcZe6GnygMa+OU=; b=hdtiMrt9is2YNiYTZ9oDC7+9RsUVgVHnf16wAPQz9ZPj6qLnHpfrCVAYIJ+WEaO8V8 GGVchOCt4zETPez9Y63KPf1ko5pzwnrfHbK7GItDzcc4V+BDTBfP5vVrRBV1qAtXSCGS zjYPiaJI6PfcJhPvVfzoNThP4pIwkbbBzkb3la/7bDFCMFE1eY7mMfVhESeG67L9XR5e ckIGUagBOcBT617hCTab++7U6knG8jeM7O+SNQWxFaia7qj4cWckNoKw0Z0v5Batl2zo 3Aa0/tn5+MAnwP6YCpLe+UBqTfTQFPfm1GjJUF5klQSSiUy9ilk+m1NGk7frvEZk+QRC LiOQ== Received: by 10.68.223.35 with SMTP id qr3mr14342024pbc.83.1338096994501; Sat, 26 May 2012 22:36:34 -0700 (PDT) Received: from localhost ([122.12.2.38]) by mx.google.com with ESMTPS id tt5sm10617121pbc.12.2012.05.26.22.36.28 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 May 2012 22:36:33 -0700 (PDT) From: Jia Liu To: qemu-devel@nongnu.org Date: Sun, 27 May 2012 13:32:56 +0800 Message-Id: <1338096779-30821-15-git-send-email-proljc@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1338096779-30821-1-git-send-email-proljc@gmail.com> References: <1338096779-30821-1-git-send-email-proljc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.45 Subject: [Qemu-devel] [PATCH v2 14/17] Openrisc: add gdb stub support 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 add gdb stub support for openrisc. Signed-off-by: Jia Liu --- gdbstub.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/gdbstub.c b/gdbstub.c index 6a77a66..98a0d18 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1155,6 +1155,68 @@ static int cpu_gdb_write_register(CPUMIPSState *env, uint8_t *mem_buf, int n) return sizeof(target_ulong); } +#elif defined(TARGET_OPENRISC) + +#define NUM_CORE_REGS (32 + 3) + +static int cpu_gdb_read_register(CPUOpenriscState *env, uint8_t *mem_buf, int n) +{ + if (n < 32) { + GET_REG32(env->gpr[n]); + } else { + switch (n) { + case 32: /* PPC */ + GET_REG32(env->ppc); + break; + + case 33: /* NPC */ + GET_REG32(env->npc); + break; + + case 34: /* SR */ + GET_REG32(env->sr); + break; + + default: + break; + } + } + return 0; +} + +static int cpu_gdb_write_register(CPUOpenriscState *env, + uint8_t *mem_buf, int n) +{ + uint32_t tmp; + + if (n > NUM_CORE_REGS) { + return 0; + } + + tmp = ldl_p(mem_buf); + + if (n < 32) { + env->gpr[n] = tmp; + } else { + switch (n) { + case 32: /* PPC */ + env->ppc = tmp; + break; + + case 33: /* NPC */ + env->npc = tmp; + break; + + case 34: /* SR */ + env->sr = tmp; + break; + + default: + break; + } + } + return 4; +} #elif defined (TARGET_SH4) /* Hint: Use "set architecture sh4" in GDB to see fpu registers */ @@ -1924,6 +1986,8 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) } #elif defined (TARGET_MICROBLAZE) s->c_cpu->sregs[SR_PC] = pc; +#elif defined(TARGET_OPENRISC) + s->c_cpu->pc = pc; #elif defined (TARGET_CRIS) s->c_cpu->pc = pc; #elif defined (TARGET_ALPHA)