From patchwork Fri Jun 22 04:51:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 933103 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 41BmPp6l4Gz9s47 for ; Fri, 22 Jun 2018 14:51:58 +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="RuSoOHRb"; 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 41BmPp54mxzF0x8 for ; Fri, 22 Jun 2018 14:51:58 +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="RuSoOHRb"; 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:c00::232; helo=mail-pf0-x232.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="RuSoOHRb"; dkim-atps=neutral Received: from mail-pf0-x232.google.com (mail-pf0-x232.google.com [IPv6:2607:f8b0:400e:c00::232]) (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 41BmPk1LN6zF0Vt for ; Fri, 22 Jun 2018 14:51:54 +1000 (AEST) Received: by mail-pf0-x232.google.com with SMTP id b17-v6so2611007pfi.0 for ; Thu, 21 Jun 2018 21:51:53 -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=mkNp5ky7nS+uCHZEOxmpG0Ii9H5oYV5cdprvBOKB10U=; b=RuSoOHRbHnqiZv+odKGExqJOyJLbfInzR4tfDTJ9Xbh9KLlQsTDnh4G62CghrE0jiy y7di679bJ7vrcGSZVyUfPojOEaYe0dhafLYp6FMAGdlz5QZb6KmQGpSqjO9LNPYMYA/A EwtvVyaES4+mJd/R5I+oULa8e0RR6aqWxmqv88jTIlGSIVReQnbYZYKWdu7512IHq3xV JQZ+BfDLmmmpVCXPGe2lgeN7Dwqmvn0E0NMEZ+cOX0P97hDBlRujSvbK2Xn276xoKbAm 5/x6oBkINM5RTBelCxzOyNgaB5opy8tW6TsJRLatOoivqBIXTwxP4vhEQj8F84MpFq5s CwXg== 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=mkNp5ky7nS+uCHZEOxmpG0Ii9H5oYV5cdprvBOKB10U=; b=FnFedf+OsKQDYaq/WfrDE7rKyHhvdIQLmTCde7prREYcKns88uBIZyxzylBB54acvY AOc7Q37DnNJ4xqGY3OpcDf+WZ2oygFCQOm31Y+ZU9NmEqwSmP++uYw05+VF7lB7FMBEQ P5Sd/xka37ARk1YxyLAcySH+wK5bS36IXi1VhGa50x74jRqjDqUeg42wKYEbzDfpQH6t w7VHAHcVQd6U9YVnkCN3WcRCyzjpg7XCOCjkVEWuHrNme0Kg8r3zkD4dKCiJosGDCTjR z2XumY4PP5Fk3d+9TdOgrpoE04Q6pAaA4gp1EMYGYsB9h6anvncWRcmXl9D8LUYF1TuR O/tw== X-Gm-Message-State: APt69E35pTbS1OM30RVlha2LYnEkqlgCzU0xk+zFeU+VUYXHfT2De1iB 8QUKiTk8tjO5jXeMwV4vUomYqw== X-Google-Smtp-Source: ADUXVKJ5vPOBd7IMFPSLVZb/JT4dERu2Nf4TJggVgHmz0hYFV9KnW8/rnnO4c4AxKgMA70c37dNg6Q== X-Received: by 2002:a63:3348:: with SMTP id z69-v6mr30511pgz.171.1529643112150; Thu, 21 Jun 2018 21:51:52 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Jun 2018 21:51:51 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 22 Jun 2018 14:51:11 +1000 Message-Id: <20180622045116.12059-4-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 3/8] pdbg: Add getxer & putxer commands 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 | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 1cfaca7..ce218d5 100644 --- a/src/main.c +++ b/src/main.c @@ -84,7 +84,7 @@ 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_getmem, optcmd_putmem, optcmd_getxer, optcmd_putxer; static struct optcmd_cmd *cmds[] = { &optcmd_getscom, &optcmd_putscom, &optcmd_getcfam, &optcmd_putcfam, @@ -92,7 +92,7 @@ static struct optcmd_cmd *cmds[] = { &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_getmem, &optcmd_putmem, &optcmd_getxer, &optcmd_putxer, }; /* Purely for printing usage text. We could integrate printing argument and flag @@ -112,6 +112,8 @@ static struct action actions[] = { { "putspr", " ", "Write Special Purpose Register (SPR)" }, { "getmsr", "", "Get Machine State Register (MSR)" }, { "putmsr", "", "Write Machine State Register (MSR)" }, + { "getxer", "", "Get Fixed Point Exception Register (XER)" }, + { "putxer", "", "Write Fixed Point Exception Register (XER)" }, { "getring", " ", "Read a ring. Length must be correct" }, { "start", "", "Start thread" }, { "step", "", "Set a thread instructions" }, diff --git a/src/reg.c b/src/reg.c index aa77a8a..dbef0ef 100644 --- a/src/reg.c +++ b/src/reg.c @@ -18,12 +18,14 @@ #include #include #include +#include #include #include "main.h" #include "optcmd.h" +#define REG_XER -4 #define REG_MEM -3 #define REG_MSR -2 #define REG_NIA -1 @@ -42,6 +44,8 @@ static void print_proc_reg(struct pdbg_target *target, uint64_t reg, uint64_t va printf("msr: "); else if (reg == REG_NIA) printf("nia: "); + else if (reg == REG_XER) + printf("xer: "); else if (reg > REG_R31) printf("spr%03" PRIu64 ": ", reg - REG_R31); else if (reg >= 0 && reg <= 31) @@ -63,6 +67,8 @@ static int putprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, rc = ram_putmsr(target, *value); else if (*reg == REG_NIA) rc = ram_putnia(target, *value); + else if (*reg == REG_XER) + rc = ram_putxer(target, *value); else if (*reg > REG_R31) rc = ram_putspr(target, *reg - REG_R31, *value); else if (*reg >= 0 && *reg <= 31) @@ -82,6 +88,8 @@ static int getprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg, rc = ram_getmsr(target, &value); else if (*reg == REG_NIA) rc = ram_getnia(target, &value); + else if (*reg == REG_XER) + rc = ram_getxer(target, (uint32_t *)&value); else if (*reg > REG_R31) rc = ram_getspr(target, *reg - REG_R31, &value); else if (*reg >= 0 && *reg <= 31) @@ -147,3 +155,18 @@ static int putmsr(uint64_t data) return for_each_target("thread", putprocreg, ®, &data); } OPTCMD_DEFINE_CMD_WITH_ARGS(putmsr, putmsr, (DATA)); + +static int getxer(void) +{ + uint64_t reg = REG_XER; + return for_each_target("thread", getprocreg, ®, NULL); +} +OPTCMD_DEFINE_CMD(getxer, getxer); + +static int putxer(uint32_t data) +{ + uint64_t reg = REG_XER; + uint64_t d = data; + return for_each_target("thread", putprocreg, ®, &d); +} +OPTCMD_DEFINE_CMD_WITH_ARGS(putxer, putxer, (DATA32));