From patchwork Wed Aug 29 01:50:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963199 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 420TBL0grbz9s4Z for ; Wed, 29 Aug 2018 11:51:38 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ILp8sLdK"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 420TBK42LlzF1p8 for ; Wed, 29 Aug 2018 11:51:37 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ILp8sLdK"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::633; helo=mail-pl1-x633.google.com; envelope-from=rashmica.g@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ILp8sLdK"; dkim-atps=neutral Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 420T9y1nl2zF1RN for ; Wed, 29 Aug 2018 11:51:18 +1000 (AEST) Received: by mail-pl1-x633.google.com with SMTP id ba4-v6so1542444plb.11 for ; Tue, 28 Aug 2018 18:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q8BWP/WhERPFHoyqsXLybbU/6D/ZCuaoFQG5Pfd1UZA=; b=ILp8sLdKylWiLSKVHS4lljZMsIRpcQsWnfkLh+DZDyV0Xx4APGrGmdTP6xLBWIhilb HhjJxuADbRRYePbLLnHNrRcoN2ipq/fXKkhEDyayIjzg4bWpF3ko0UElH2WlL/MJqugs FW0Zg3lrIQDD8fC2oHALVtqCf13wPXP9Iq4uxGivNmtAfawFhdj4BcirUh4dCmGW9atU HYjnreSb3kc48NkSjtQirxBHV9dSktHVxFQOqF2ygxGcspW3hetaH1t8Q4qXFaNPbxi3 A045HLQ+vKW5jOND5aXjvayK1wEA8cjnM0qrdER5maYiF999bOk3rhjtpeoMSuoKPXhj N/bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q8BWP/WhERPFHoyqsXLybbU/6D/ZCuaoFQG5Pfd1UZA=; b=BO+drDbtN1od41JzeckhuP6GmE5/219qMQ0yGDuYpjAthxa57KoyEVlYer0jC6nxEg gaTgaIMGHurnjPISuP0YSqPA3y4lzFqwFdSb/VuM+8ffaPT2ZKKqREOt+J+Zd47LFI05 bNkrvjPwyUr/LU8dn2Z16Sh9z18i7cKkxnFRnRS1cdNBeNosszCQklu8CdtJSrBydK5U JaAI5Kx17FCIf8XpeQCoiXPYgN2tjIDJNPCkmOo1Ph0ukHGxwDlC8TofulZmbVKziBQ7 U5dwV2D+TW4sHMez3nIcUaBZAbM2VW8Qcf2lbIH1CVjvBzPICxzHS+EY/SlrGGqrmZmA xAZQ== X-Gm-Message-State: APzg51CfyqcQunpIqLYXLyKoAjdAfrJLCyzm6EXFPvavSa/Nqi6Hk8LF vvNAuxm2mppASlHicLGsqB3D/QLc X-Google-Smtp-Source: ANB0VdZdLgv3Gb5+GyskLPNsEpsfs7GaIuwaVL5syQ/mnL0y+FAEJHNJ7zaQJQ2ndUnVrlaUXbMQNw== X-Received: by 2002:a17:902:a716:: with SMTP id w22-v6mr3930003plq.334.1535507476098; Tue, 28 Aug 2018 18:51:16 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:15 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:35 +1000 Message-Id: <20180829015047.7355-8-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 07/19] pdbg: Add getcr and putcr options X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- src/main.c | 6 +++++- src/reg.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 5d840ef..ff3ee2b 100644 --- a/src/main.c +++ b/src/main.c @@ -86,7 +86,8 @@ extern struct optcmd_cmd optcmd_getnia, optcmd_putnia, optcmd_getmsr, optcmd_putmsr, optcmd_getring, optcmd_start, optcmd_stop, optcmd_step, optcmd_threadstatus, optcmd_sreset, optcmd_regs, optcmd_probe, - optcmd_getmem, optcmd_putmem, optcmd_getxer, optcmd_putxer; + optcmd_getmem, optcmd_putmem, optcmd_getxer, optcmd_putxer, + optcmd_getcr, optcmd_putcr; static struct optcmd_cmd *cmds[] = { &optcmd_getscom, &optcmd_putscom, &optcmd_getcfam, &optcmd_putcfam, @@ -95,6 +96,7 @@ static struct optcmd_cmd *cmds[] = { &optcmd_getring, &optcmd_start, &optcmd_stop, &optcmd_step, &optcmd_threadstatus, &optcmd_sreset, &optcmd_regs, &optcmd_probe, &optcmd_getmem, &optcmd_putmem, &optcmd_getxer, &optcmd_putxer, + &optcmd_getcr, &optcmd_putcr, }; /* Purely for printing usage text. We could integrate printing argument and flag @@ -114,6 +116,8 @@ static struct action actions[] = { { "putspr", " ", "Write Special Purpose Register (SPR)" }, { "getmsr", "", "Get Machine State Register (MSR)" }, { "putmsr", "", "Write Machine State Register (MSR)" }, + { "getcr", "", "Get Condition Register (CR)" }, + { "putcr", "", "Write Condition Register (CR)" }, { "getxer", "", "Get Fixed Point Exception Register (XER)" }, { "putxer", "", "Write Fixed Point Exception Register (XER)" }, { "getring", " ", "Read a ring. Length must be correct" }, diff --git a/src/reg.c b/src/reg.c index 3864316..fcf6f4c 100644 --- a/src/reg.c +++ b/src/reg.c @@ -24,6 +24,7 @@ #include "main.h" #include "optcmd.h" +#define REG_CR -5 #define REG_XER -4 #define REG_MEM -3 #define REG_MSR -2 @@ -45,6 +46,8 @@ static void print_proc_reg(struct pdbg_target *target, uint64_t reg, uint64_t va printf("nia: "); else if (reg == REG_XER) printf("xer: "); + else if (reg == REG_CR) + printf("cr: "); else if (reg > REG_R31) printf("spr%03" PRIu64 ": ", reg - REG_R31); else if (reg >= 0 && reg <= 31) @@ -68,6 +71,8 @@ static int putprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, rc = ram_putnia(target, *value); else if (*reg == REG_XER) rc = ram_putxer(target, *value); + else if (*reg == REG_CR) + rc = ram_putcr(target, *value); else if (*reg > REG_R31) rc = ram_putspr(target, *reg - REG_R31, *value); else if (*reg >= 0 && *reg <= 31) @@ -89,6 +94,8 @@ static int getprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, rc = ram_getnia(target, &value); else if (*reg == REG_XER) rc = ram_getxer(target, &value); + else if (*reg == REG_CR) + rc = ram_getcr(target, (uint32_t *)&value); else if (*reg > REG_R31) rc = ram_getspr(target, *reg - REG_R31, &value); else if (*reg >= 0 && *reg <= 31) @@ -169,3 +176,18 @@ static int putxer(uint64_t data) return for_each_target("thread", putprocreg, ®, &d); } OPTCMD_DEFINE_CMD_WITH_ARGS(putxer, putxer, (DATA)); + +static int getcr(void) +{ + uint64_t cr = REG_CR; + return for_each_target("thread", getprocreg, &cr, NULL); +} +OPTCMD_DEFINE_CMD(getcr, getcr); + +static int putcr(uint32_t data) +{ + uint64_t cr = REG_CR; + uint64_t d = data; + return for_each_target("thread", putprocreg, &cr, &d); +} +OPTCMD_DEFINE_CMD_WITH_ARGS(putcr, putcr, (DATA32));