From patchwork Fri Jun 22 04:51:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 933106 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41BmPz2Q5jz9s47 for ; Fri, 22 Jun 2018 14:52:07 +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="MMdshOuK"; 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 41BmPz0YWnzF0x4 for ; Fri, 22 Jun 2018 14:52:07 +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="MMdshOuK"; 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:400e:c05::22a; helo=mail-pg0-x22a.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="MMdshOuK"; dkim-atps=neutral Received: from mail-pg0-x22a.google.com (mail-pg0-x22a.google.com [IPv6:2607:f8b0:400e:c05::22a]) (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 41BmPr6C02zF0x4 for ; Fri, 22 Jun 2018 14:52:00 +1000 (AEST) Received: by mail-pg0-x22a.google.com with SMTP id d2-v6so2401178pga.13 for ; Thu, 21 Jun 2018 21:52:00 -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=+AjuWzi2KfuOAA3HCKVQYBD0FRZYt9x+AbmyMeLBoCk=; b=MMdshOuKM2VU4axcacIirAHEQCoU2uDEJ67Ga/X21b5i6SMprkkTFKtT914bGtD4Ho nVhJC2kf4dft+Viej1eVZQ10aN2rtYrexuV91taIa73jB/A6oTEqUEeZQOCBt4TbEymj e2Ux+xo3UqzdgzWpUKLtxMpqZPQeW35re9u5syYOuTAElTzUNqbsM/Q9hH//9U9jxapR DElbFMyCCwN53B0wFexuZ0ABZ5DTjcZ0qyWcyGUNecR6nrGM3TuZ8vBX0sPfme+YJ0wR wa3M/t7QlVx+5bUQ39Yi/oOIqnvnMveIKShNOC7YAEFRXKfGEJ18e9tgtg50Rath2vne 5c8w== 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=+AjuWzi2KfuOAA3HCKVQYBD0FRZYt9x+AbmyMeLBoCk=; b=kjJy6YBAVxhYX7aYPhmxrWMrFCibmYtaT+UCGKVgiWm0JsARCcrHaNWorp6SzaaUGv bm5aXWNXuo5Bvp+4ocznPz8AaLFPnouYj8m96NZbyZGswfDcQn8PUfc5p+yeAsHCeaLI 1Ws3nwAsn3THElzwYUknCV8Tph2ImlPUVuz3dV18cgUrMc7tZkSVnaqjBJ5xQOncWAuC TWZdysTc652cn/tYZU5p4whOciGETIE9Z70lFZTaddzXA2JVSz4tbrcVSXxR1reu+ayE Rxnruk1X/al69VXgw3EzF7F7WyGiCZaT5UkD79tPsIwA1VB5SnB95JLTcApkSFiknovy rhTw== X-Gm-Message-State: APt69E2UXKtJIDT4R9mQiyR8Wd8utZfB86uc6JeYI5iDOT+MU+Hkwmjz 9AMXJZ1cVG4Hq3AbT36xURBsug== X-Google-Smtp-Source: ADUXVKI/KO2WhgyUI+qCv+bXqg0uh77i2UxlynEaBAZQxThNnQDwGNxDFJN49Clit36t/s0LBkK86Q== X-Received: by 2002:a65:602c:: with SMTP id p12-v6mr28504pgu.209.1529643118512; Thu, 21 Jun 2018 21:51:58 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id v27-v6sm11874992pfi.23.2018.06.21.21.51.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Jun 2018 21:51:58 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 22 Jun 2018 14:51:14 +1000 Message-Id: <20180622045116.12059-7-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180622045116.12059-1-rashmica.g@gmail.com> References: <20180622045116.12059-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 6/8] pdbg: Add getcr and putcr options X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index ce218d5..33f7edb 100644 --- a/src/main.c +++ b/src/main.c @@ -84,7 +84,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, @@ -93,6 +94,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 @@ -112,6 +114,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 65e8eb4..60705f1 100644 --- a/src/reg.c +++ b/src/reg.c @@ -25,6 +25,7 @@ #include "main.h" #include "optcmd.h" +#define REG_CR -5 #define REG_XER -4 #define REG_MEM -3 #define REG_MSR -2 @@ -46,6 +47,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) @@ -69,6 +72,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) @@ -172,3 +177,18 @@ static int putxer(uint32_t data) return for_each_target("thread", putprocreg, ®, &d); } OPTCMD_DEFINE_CMD_WITH_ARGS(putxer, putxer, (DATA32)); + +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));