From patchwork Thu Jul 23 05:26:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1334420 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BC16n2cvKz9sRk for ; Thu, 23 Jul 2020 15:27:13 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=DvqApc/E; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BC16m63cwzDr83 for ; Thu, 23 Jul 2020 15:27:12 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BC16R09JSzDr7N for ; Thu, 23 Jul 2020 15:26:55 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=DvqApc/E; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4BC16Q4kC0z9sRW; Thu, 23 Jul 2020 15:26:54 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1595482014; bh=lQtnBH63ES/MouJ7wBFPDMQzOa19n0UZ3XtWkIX3K74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DvqApc/EkjhKvYMVQDdEkcQOOfJ+emkui6nSc8WGiL98NDUDkNAJjni1tORaMBGfh 4IAQPk5bXozW9Ss6Cp2PGA1MYxVju+RYCSXm7cgYbrv6hUSbDVUojoElAUf91ZLgIe aXItcc9DPmNuurrBpw5qrqHVf/rDjuuASglUEEBQd4PlLZZisDYPynAzP/L7t0M1I+ eV7BzW/JxvgzNj0URBAasXdfU5j4U5f8tY34EiNVoor5U28+CwNpfja+2yQO37zyRI aiBfWsmNlwXNksczQLKMoKf/zG34KtivB/Yr/j9UpPAglHPU6pWu6mNLkdcojVcOBZ sZD3ftDA59Zqw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 23 Jul 2020 15:26:38 +1000 Message-Id: <20200723052641.561009-2-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200723052641.561009-1-amitay@ozlabs.org> References: <20200723052641.561009-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 1/4] libpdbg: Use spr specific procedures if defined X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 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: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- libpdbg/thread.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/libpdbg/thread.c b/libpdbg/thread.c index e8fb0c0..7ef0bf8 100644 --- a/libpdbg/thread.c +++ b/libpdbg/thread.c @@ -18,6 +18,7 @@ #include "libpdbg.h" #include "hwunit.h" #include "debug.h" +#include "sprs.h" struct thread_state thread_status(struct pdbg_target *target) { @@ -334,6 +335,28 @@ int thread_getspr(struct pdbg_target *target, int spr, uint64_t *value) thread = target_to_thread(target); + if (spr == SPR_MSR) { + if (thread->getmsr) + return thread->getmsr(thread, value); + } else if (spr == SPR_NIA) { + if (thread->getnia) + return thread->getnia(thread, value); + } else if (spr == SPR_XER) { + if (thread->getxer) + return thread->getxer(thread, value); + } else if (spr == SPR_CR) { + if (thread->getcr) { + uint32_t u32; + int rc; + + rc = thread->getcr(thread, &u32); + if (rc == 0) + *value = u32; + + return rc; + } + } + if (!thread->getspr) { PR_ERROR("getspr() not imeplemented for the target\n"); return -1; @@ -353,6 +376,20 @@ int thread_putspr(struct pdbg_target *target, int spr, uint64_t value) thread = target_to_thread(target); + if (spr == SPR_MSR) { + if (thread->putmsr) + return thread->putmsr(thread, value); + } else if (spr == SPR_NIA) { + if (thread->putnia) + return thread->putnia(thread, value); + } else if (spr == SPR_XER) { + if (thread->putxer) + return thread->putxer(thread, value); + } else if (spr == SPR_CR) { + if (thread->putcr) + return thread->putcr(thread, (uint32_t)value); + } + if (!thread->putspr) { PR_ERROR("putspr() not imeplemented for the target\n"); return -1; From patchwork Thu Jul 23 05:26:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1334421 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BC16r0MxXz9sRf for ; Thu, 23 Jul 2020 15:27:16 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=Gjkx2XeT; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BC16q6nlszDr7l for ; Thu, 23 Jul 2020 15:27:15 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BC16R2gtCzDr7P for ; Thu, 23 Jul 2020 15:26:55 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=Gjkx2XeT; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4BC16R0Tbdz9sRf; Thu, 23 Jul 2020 15:26:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1595482015; bh=5Nf7+3Im8KP49f6/hR3zezh4+nc+2xSJXwobUeIcVAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gjkx2XeTkMLzpwQnw0HWR6cGjqsLdO4U/WQvIKOPC5IEpFfJI/mpCeGSu4ssZDLr5 c6+ChlcdLQ1sXoBSMSm1wxBCHnXewzyav6JsCy8TOUk/G8QYpezAM/2z9m1p+vcPTq EiNVVqacvJBBkK/o8ozMh3p6gWLVXY/4yJKoUf/I6+RZSqC476YvAAwI1aDDphBhCp 4FTm2e1OS+aElejAAjFDe4+yGvJ62EDzZicNT5HB8KYrE9o/orGVJRHJJH2XRC2shU PUOfAazZUJZ04/BxllkaQuadg/J1HDK6zjj4mY78svafkViMXaoUJ4hwrObF8six4H vxlR1sbsU1KTQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 23 Jul 2020 15:26:39 +1000 Message-Id: <20200723052641.561009-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200723052641.561009-1-amitay@ozlabs.org> References: <20200723052641.561009-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 2/4] libpdbg: Add apis to convert between spr name and id X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 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: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- Makefile.am | 1 + libpdbg/libpdbg.h | 18 +++++ libpdbg/sprs.c | 200 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 219 insertions(+) create mode 100644 libpdbg/sprs.c diff --git a/Makefile.am b/Makefile.am index dce09ab..4253a0b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -182,6 +182,7 @@ libpdbg_la_SOURCES = \ libpdbg/p9_scom_addr.h \ libpdbg/sbefifo.c \ libpdbg/sprs.h \ + libpdbg/sprs.c \ libpdbg/target.c \ libpdbg/target.h \ libpdbg/thread.c diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 180a609..71d1de4 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -1067,6 +1067,24 @@ int thread_sreset_all(void); */ struct thread_state thread_status(struct pdbg_target *target); +/** + * @brief Get SPR id from name + * + * @param[in] name SPR name + * + * @return spr id or -1 if not found + */ +int pdbg_spr_by_name(const char *name); + +/** + * @brief Get SPR name from id + * + * @param[in] spr SPR id + * + * @return spr name or NULL if not found + */ +const char *pdbg_spr_by_id(int spr); + int getring(struct pdbg_target *chiplet_target, uint64_t ring_addr, uint64_t ring_len, uint32_t result[]); /** diff --git a/libpdbg/sprs.c b/libpdbg/sprs.c new file mode 100644 index 0000000..0d42ef1 --- /dev/null +++ b/libpdbg/sprs.c @@ -0,0 +1,200 @@ +/* Copyright 2020 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "libpdbg.h" +#include "sprs.h" + +static struct { + const char *spr_name; + int spr_id; +} spr_map[] = { + { "XER", SPR_XER }, + { "DSCR_RU", SPR_DSCR_RU }, + { "LR", SPR_LR }, + { "CTR", SPR_CTR }, + { "UAMR", SPR_UAMR }, + { "DSCR", SPR_DSCR }, + { "DSISR", SPR_DSISR }, + { "DAR", SPR_DAR }, + { "DEC", SPR_DEC }, + { "SDR1", SPR_SDR1 }, + { "SRR0", SPR_SRR0 }, + { "SRR1", SPR_SRR1 }, + { "CFAR", SPR_CFAR }, + { "AMR", SPR_AMR }, + { "PIDR", SPR_PIDR }, + { "IAMR", SPR_IAMR }, + { "TFHAR", SPR_TFHAR }, + { "TFIAR", SPR_TFIAR }, + { "TEXASR", SPR_TEXASR }, + { "TEXASRU", SPR_TEXASRU }, + { "CTRL_RU", SPR_CTRL_RU }, + { "TIDR", SPR_TIDR }, + { "CTRL", SPR_CTRL }, + { "FSCR", SPR_FSCR }, + { "UAMOR", SPR_UAMOR }, + { "GSR", SPR_GSR }, + { "PSPB", SPR_PSPB }, + { "DPDES", SPR_DPDES }, + { "DAWR0", SPR_DAWR0 }, + { "RPR", SPR_RPR }, + { "CIABR", SPR_CIABR }, + { "DAWRX0", SPR_DAWRX0 }, + { "HFSCR", SPR_HFSCR }, + { "VRSAVE", SPR_VRSAVE }, + { "SPRG3_RU", SPR_SPRG3_RU }, + { "TB", SPR_TB }, + { "TBU_RU", SPR_TBU_RU }, + { "SPRG0", SPR_SPRG0 }, + { "SPRG1", SPR_SPRG1 }, + { "SPRG2", SPR_SPRG2 }, + { "SPRG3", SPR_SPRG3 }, + { "SPRC", SPR_SPRC }, + { "SPRD", SPR_SPRD }, + { "CIR", SPR_CIR }, + { "TBL", SPR_TBL }, + { "TBU", SPR_TBU }, + { "TBU40", SPR_TBU40 }, + { "PVR", SPR_PVR }, + { "HSPRG0", SPR_HSPRG0 }, + { "HSPRG1", SPR_HSPRG1 }, + { "HDSISR", SPR_HDSISR }, + { "HDAR", SPR_HDAR }, + { "SPURR", SPR_SPURR }, + { "PURR", SPR_PURR }, + { "HDEC", SPR_HDEC }, + { "HRMOR", SPR_HRMOR }, + { "HSRR0", SPR_HSRR0 }, + { "HSRR1", SPR_HSRR1 }, + { "TFMR", SPR_TFMR }, + { "LPCR", SPR_LPCR }, + { "LPIDR", SPR_LPIDR }, + { "HMER", SPR_HMER }, + { "HMEER", SPR_HMEER }, + { "PCR", SPR_PCR }, + { "HEIR", SPR_HEIR }, + { "AMOR", SPR_AMOR }, + { "TIR", SPR_TIR }, + { "PTCR", SPR_PTCR }, + { "USPRG0", SPR_USPRG0 }, + { "USPRG1", SPR_USPRG1 }, + { "UDAR", SPR_UDAR }, + { "SEIDR", SPR_SEIDR }, + { "URMOR", SPR_URMOR }, + { "USRR0", SPR_USRR0 }, + { "USRR1", SPR_USRR1 }, + { "UEIR", SPR_UEIR }, + { "ACMCR", SPR_ACMCR }, + { "SMFCTRL", SPR_SMFCTRL }, + { "SIER_RU", SPR_SIER_RU }, + { "MMCR2_RU", SPR_MMCR2_RU }, + { "MMCRA_RU", SPR_MMCRA_RU }, + { "PMC1_RU", SPR_PMC1_RU }, + { "PMC2_RU", SPR_PMC2_RU }, + { "PMC3_RU", SPR_PMC3_RU }, + { "PMC4_RU", SPR_PMC4_RU }, + { "PMC5_RU", SPR_PMC5_RU }, + { "PMC6_RU", SPR_PMC6_RU }, + { "MMCR0_RU", SPR_MMCR0_RU }, + { "SIAR_RU", SPR_SIAR_RU }, + { "SDAR_RU", SPR_SDAR_RU }, + { "MMCR1_RU", SPR_MMCR1_RU }, + { "SIER", SPR_SIER }, + { "MMCR2", SPR_MMCR2 }, + { "MMCRA", SPR_MMCRA }, + { "PMC1", SPR_PMC1 }, + { "PMC2", SPR_PMC2 }, + { "PMC3", SPR_PMC3 }, + { "PMC4", SPR_PMC4 }, + { "PMC5", SPR_PMC5 }, + { "PMC6", SPR_PMC6 }, + { "MMCR0", SPR_MMCR0 }, + { "SIAR", SPR_SIAR }, + { "SDAR", SPR_SDAR }, + { "MMCR1", SPR_MMCR1 }, + { "IMC", SPR_IMC }, + { "BESCRS", SPR_BESCRS }, + { "BESCRSU", SPR_BESCRSU }, + { "BESCRR", SPR_BESCRR }, + { "BESCRRU", SPR_BESCRRU }, + { "EBBHR", SPR_EBBHR }, + { "EBBRR", SPR_EBBRR }, + { "BESCR", SPR_BESCR }, + { "LMRR", SPR_LMRR }, + { "LMSER", SPR_LMSER }, + { "TAR", SPR_TAR }, + { "ASDR", SPR_ASDR }, + { "PSSCR_SU", SPR_PSSCR_SU }, + { "IC", SPR_IC }, + { "VTB", SPR_VTB }, + { "LDBAR", SPR_LDBAR }, + { "MMCRC", SPR_MMCRC }, + { "PMSR", SPR_PMSR }, + { "PMMAR", SPR_PMMAR }, + { "PSSCR", SPR_PSSCR }, + { "L2QOSR", SPR_L2QOSR }, + { "WORC", SPR_WORC }, + { "TRIG0", SPR_TRIG0 }, + { "TRIG1", SPR_TRIG1 }, + { "TRIG2", SPR_TRIG2 }, + { "PMCR", SPR_PMCR }, + { "RWMR", SPR_RWMR }, + { "WORT", SPR_WORT }, + { "PPR", SPR_PPR }, + { "PPR32", SPR_PPR32 }, + { "TSCR", SPR_TSCR }, + { "TTR", SPR_TTR }, + { "TRACE", SPR_TRACE }, + { "HID", SPR_HID }, + { "PIR", SPR_PIR }, + { "NIA", SPR_NIA }, + { "MSR", SPR_MSR }, + { "CR", SPR_CR }, + { "FPSCR", SPR_FPSCR }, + { "VSCR", SPR_VSCR }, + { "SLBE", SPR_SLBE }, + { "SLBV", SPR_SLBV }, + { NULL, -1 }, +}; + +int pdbg_spr_by_name(const char *name) +{ + int i; + + for (i = 0; spr_map[i].spr_name != NULL; i++) { + if (!strcasecmp(spr_map[i].spr_name, name)) { + return spr_map[i].spr_id; + } + } + + return -1; +} + +const char *pdbg_spr_by_id(int spr) +{ + int i; + + for (i = 0; spr_map[i].spr_name != NULL; i++) { + if (spr_map[i].spr_id == spr) { + return spr_map[i].spr_name; + } + } + + return NULL; +} From patchwork Thu Jul 23 05:26:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1334412 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BC16Y2G6hz9sRW for ; Thu, 23 Jul 2020 15:27:01 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=cFfSHIkN; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BC16Y0ld8zDr7g for ; Thu, 23 Jul 2020 15:27:01 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BC16R6fGDzDr7Q for ; Thu, 23 Jul 2020 15:26:55 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=cFfSHIkN; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4BC16R2wrjz9sRk; Thu, 23 Jul 2020 15:26:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1595482015; bh=ZqCfLupqTiW4MDG7wvrF06Js+lS3zXZKQW06ktqa03k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cFfSHIkNMvIQWnWle87gcvamnafW8VuFcHfJl11rfzq1QZxiWO7q9I081zQDT1poz l5RXHqOQjr8VbEt8+Ru1NlaNgTdb+yYEvaAUAvZZ8nRrST8TF7OpKlVnuDelFVtPpQ bTp2RbRXoYMvzUS6cDI8ktlPnu83iXH1ELl4Jp84Q9n1bv4eGgGlMWKyPDimABkIMO aV61jHJylZCzyDUxR6Ns/x3qUVI7I0zTrHvHv5IG8SRdbnR7vu6N4+1jxaffP1Na7c Ua8d9+ziIub278uAhB1l2eOCCqKLJ2yEo0fMjLKNseTiylu3O/mYIhQRpl1U2/z8tV ndqrmzK9dBuIg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 23 Jul 2020 15:26:40 +1000 Message-Id: <20200723052641.561009-4-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200723052641.561009-1-amitay@ozlabs.org> References: <20200723052641.561009-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 3/4] main: Drop special commands for getting/setting few sprs X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 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: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/main.c | 12 ------------ src/reg.c | 49 ------------------------------------------------- 2 files changed, 61 deletions(-) diff --git a/src/main.c b/src/main.c index 032bcd8..0ed6b92 100644 --- a/src/main.c +++ b/src/main.c @@ -68,23 +68,19 @@ static int probe(void); extern struct optcmd_cmd optcmd_getscom, optcmd_putscom, optcmd_getcfam, optcmd_putcfam, optcmd_getgpr, optcmd_putgpr, optcmd_getspr, optcmd_putspr, - 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_getmemio, optcmd_putmemio, optcmd_getmempba, optcmd_putmempba, - optcmd_getxer, optcmd_putxer, optcmd_getcr, optcmd_putcr, optcmd_gdbserver, optcmd_istep; static struct optcmd_cmd *cmds[] = { &optcmd_getscom, &optcmd_putscom, &optcmd_getcfam, &optcmd_putcfam, &optcmd_getgpr, &optcmd_putgpr, &optcmd_getspr, &optcmd_putspr, - &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_getmemio, &optcmd_putmemio, &optcmd_getmempba, &optcmd_putmempba, - &optcmd_getxer, &optcmd_putxer, &optcmd_getcr, &optcmd_putcr, &optcmd_gdbserver, &optcmd_istep, }; @@ -99,16 +95,8 @@ struct action { static struct action actions[] = { { "getgpr", "", "Read General Purpose Register (GPR)" }, { "putgpr", " ", "Write General Purpose Register (GPR)" }, - { "getnia", "", "Get Next Instruction Address (NIA)" }, - { "putnia", "", "Write Next Instrution Address (NIA)" }, { "getspr", "", "Get Special Purpose Register (SPR)" }, { "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" }, { "start", "", "Start thread" }, { "step", "", "Set a thread instructions" }, diff --git a/src/reg.c b/src/reg.c index cab8d4d..56f5118 100644 --- a/src/reg.c +++ b/src/reg.c @@ -166,18 +166,6 @@ static int putgpr(int gpr, uint64_t data) } OPTCMD_DEFINE_CMD_WITH_ARGS(putgpr, putgpr, (GPR, DATA)); -static int getnia(void) -{ - return getreg(REG_NIA); -} -OPTCMD_DEFINE_CMD(getnia, getnia); - -static int putnia(uint64_t nia) -{ - return putreg(REG_NIA, &nia); -} -OPTCMD_DEFINE_CMD_WITH_ARGS(putnia, putnia, (DATA)); - static int getspr(int spr) { return getreg(spr + REG_R31); @@ -189,40 +177,3 @@ static int putspr(int spr, uint64_t data) return putreg(spr + REG_R31, &data); } OPTCMD_DEFINE_CMD_WITH_ARGS(putspr, putspr, (SPR, DATA)); - -static int getmsr(void) -{ - return getreg(REG_MSR); -} -OPTCMD_DEFINE_CMD(getmsr, getmsr); - -static int putmsr(uint64_t data) -{ - return putreg(REG_MSR, &data); -} -OPTCMD_DEFINE_CMD_WITH_ARGS(putmsr, putmsr, (DATA)); - -static int getxer(void) -{ - return getreg(REG_XER); -} -OPTCMD_DEFINE_CMD(getxer, getxer); - -static int putxer(uint64_t data) -{ - return putreg(REG_XER, &data); -} -OPTCMD_DEFINE_CMD_WITH_ARGS(putxer, putxer, (DATA)); - -static int getcr(void) -{ - return getreg(REG_CR); -} -OPTCMD_DEFINE_CMD(getcr, getcr); - -static int putcr(uint32_t data) -{ - uint64_t u64 = data; - return putreg(REG_CR, &u64); -} -OPTCMD_DEFINE_CMD_WITH_ARGS(putcr, putcr, (DATA32)); From patchwork Thu Jul 23 05:26:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1334418 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BC16k0G2Qz9sRR for ; Thu, 23 Jul 2020 15:27:10 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=nvINFbhg; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BC16j3nJ1zDr7M for ; Thu, 23 Jul 2020 15:27:09 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BC16S0mypzDr7V for ; Thu, 23 Jul 2020 15:26:56 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=nvINFbhg; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4BC16R5xd0z9sSJ; Thu, 23 Jul 2020 15:26:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1595482015; bh=Kwyv//rrKKzSjaSIiTEQ2/3AfX/PEiIfwgoo81lES+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nvINFbhgK30qrd8e1qaPMsRRaWKSOas8M575fi7TMUbnXVMyyuvA+va2uvVaE1Vfv T+ft3LZYrNzHxto5ZmZQPdCKEPmkitjNr54+8C/lUC16zeuDDF7FXhB3Qnl5LSVs8m eBQE1pndRJBCfdxzw/UfsCAW50uMkc3Vfs6zpUwl+pwwK2WL0arsIX9GA+325J9E48 7ANcZQQjln086fRDP4tKZuD1R+R5rOFaLqo0qQ26/e7k3KANTG0NKjLZXa9GsDPxjY FmGVxE3AYoTFA4Ie3xvDkyadwIqvOJibOEojdXuIlO+BffgVh322TNOtbfviArQT+a bgGSeaMRE9mOQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 23 Jul 2020 15:26:41 +1000 Message-Id: <20200723052641.561009-5-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200723052641.561009-1-amitay@ozlabs.org> References: <20200723052641.561009-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 4/4] main: Change (get|put)spr command to use spr names X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 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: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Avoid special convention of sprs with -ve ids. Signed-off-by: Amitay Isaacs --- src/parsers.c | 11 +++---- src/reg.c | 91 +++++++++++++++------------------------------------ 2 files changed, 32 insertions(+), 70 deletions(-) diff --git a/src/parsers.c b/src/parsers.c index 8575784..52fa49d 100644 --- a/src/parsers.c +++ b/src/parsers.c @@ -4,6 +4,8 @@ #include #include +#include "libpdbg.h" + uint64_t *parse_number64(const char *argv) { uint64_t *n = malloc(sizeof(*n)); @@ -98,19 +100,16 @@ int *parse_gpr(const char *argv) return gpr; } -/* Parse an SPR. Currently only supports SPR by numbers but could be extended to - * support names (eg. lr) */ +/* Parse an SPR name (eg. lr) */ int *parse_spr(const char *argv) { int *spr = malloc(sizeof(*spr)); - char *endptr; if (!argv) return NULL; - errno = 0; - *spr = strtoul(argv, &endptr, 0); - if (errno || *endptr != '\0' || *spr > 0x3ff) + *spr = pdbg_spr_by_name(argv); + if (*spr == -1) return NULL; return spr; diff --git a/src/reg.c b/src/reg.c index 56f5118..8f7efd8 100644 --- a/src/reg.c +++ b/src/reg.c @@ -26,14 +26,7 @@ #include "optcmd.h" #include "path.h" -#define REG_CR -5 -#define REG_XER -4 -#define REG_MEM -3 -#define REG_MSR -2 -#define REG_NIA -1 -#define REG_R31 31 - -static void print_proc_reg(struct pdbg_target *target, int reg, uint64_t *value, int rc) +static void print_proc_reg(struct pdbg_target *target, bool is_spr, int reg, uint64_t *value, int rc) { int proc_index, chip_index, thread_index; @@ -42,76 +35,46 @@ static void print_proc_reg(struct pdbg_target *target, int reg, uint64_t *value, proc_index = pdbg_parent_index(target, "pib"); printf("p%d:c%d:t%d: ", proc_index, chip_index, thread_index); - if (reg == REG_MSR) - printf("msr: "); - else if (reg == REG_NIA) - printf("nia: "); - else if (reg == REG_XER) - printf("xer: "); - else if (reg == REG_CR) - printf("cr: "); - else if (reg > REG_R31) - printf("spr%03d: ", reg - REG_R31); - else if (reg >= 0 && reg <= 31) + if (is_spr) + printf("%s: ", pdbg_spr_by_id(reg)); + else printf("gpr%02d: ", reg); - if (rc == 1) { + if (rc == 0) + printf("0x%016" PRIx64 "\n", *value); + else if (rc == 1) printf("Check threadstatus - not all threads on this chiplet are quiesced\n"); - } else if (rc == 2) + else if (rc == 2) printf("Thread in incorrect state\n"); else - printf("0x%016" PRIx64 "\n", *value); + printf("Error in thread access\n"); } -static int putprocreg(struct pdbg_target *target, int reg, uint64_t *value) +static int putprocreg(struct pdbg_target *target, bool is_spr, int reg, uint64_t *value) { - uint32_t u32; int rc; - if (reg == REG_MSR) - rc = thread_putmsr(target, *value); - else if (reg == REG_NIA) - rc = thread_putnia(target, *value); - else if (reg == REG_XER) - rc = thread_putxer(target, *value); - else if (reg == REG_CR) { - u32 = *value; - rc = thread_putcr(target, u32); - } else if (reg > REG_R31) - rc = thread_putspr(target, reg - REG_R31, *value); - else if (reg >= 0 && reg <= 31) - rc = thread_putgpr(target, reg, *value); + if (is_spr) + rc = thread_putspr(target, reg, *value); else - assert(0); + rc = thread_putgpr(target, reg, *value); return rc; } -static int getprocreg(struct pdbg_target *target, uint32_t reg, uint64_t *value) +static int getprocreg(struct pdbg_target *target, bool is_spr, uint32_t reg, uint64_t *value) { - uint32_t u32 = 0; int rc; - if (reg == REG_MSR) - rc = thread_getmsr(target, value); - else if (reg == REG_NIA) - rc = thread_getnia(target, value); - else if (reg == REG_XER) - rc = thread_getxer(target, value); - else if (reg == REG_CR) { - rc = thread_getcr(target, &u32); - *value = u32; - } else if (reg > REG_R31) - rc = thread_getspr(target, reg - REG_R31, value); - else if (reg >= 0 && reg <= 31) - rc = thread_getgpr(target, reg, value); + if (is_spr) + rc = thread_getspr(target, reg, value); else - assert(0); + rc = thread_getgpr(target, reg, value); return rc; } -static int getreg(int reg) +static int getreg(bool is_spr, int reg) { struct pdbg_target *target; int count = 0; @@ -123,8 +86,8 @@ static int getreg(int reg) if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) continue; - rc = getprocreg(target, reg, &value); - print_proc_reg(target, reg, &value, rc); + rc = getprocreg(target, is_spr, reg, &value); + print_proc_reg(target, is_spr, reg, &value, rc); if (!rc) count++; @@ -133,7 +96,7 @@ static int getreg(int reg) return count; } -static int putreg(int reg, uint64_t *value) +static int putreg(bool is_spr, int reg, uint64_t *value) { struct pdbg_target *target; int count = 0; @@ -144,8 +107,8 @@ static int putreg(int reg, uint64_t *value) if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) continue; - rc = putprocreg(target, reg, value); - print_proc_reg(target, reg, value, rc); + rc = putprocreg(target, is_spr, reg, value); + print_proc_reg(target, is_spr, reg, value, rc); if (!rc) count++; @@ -156,24 +119,24 @@ static int putreg(int reg, uint64_t *value) static int getgpr(int gpr) { - return getreg(gpr); + return getreg(false, gpr); } OPTCMD_DEFINE_CMD_WITH_ARGS(getgpr, getgpr, (GPR)); static int putgpr(int gpr, uint64_t data) { - return putreg(gpr, &data); + return putreg(false, gpr, &data); } OPTCMD_DEFINE_CMD_WITH_ARGS(putgpr, putgpr, (GPR, DATA)); static int getspr(int spr) { - return getreg(spr + REG_R31); + return getreg(true, spr); } OPTCMD_DEFINE_CMD_WITH_ARGS(getspr, getspr, (SPR)); static int putspr(int spr, uint64_t data) { - return putreg(spr + REG_R31, &data); + return putreg(true, spr, &data); } OPTCMD_DEFINE_CMD_WITH_ARGS(putspr, putspr, (SPR, DATA));