From patchwork Thu Jul 2 03:39:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1320960 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49y3l92Yhnz9sRN for ; Thu, 2 Jul 2020 13:40:21 +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=MjT5cM1c; 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 49y3l917NZzDqnc for ; Thu, 2 Jul 2020 13:40:21 +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 49y3kH1CvbzDqlD for ; Thu, 2 Jul 2020 13:39:35 +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=MjT5cM1c; 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 49y3kG6Hbwz9sQt; Thu, 2 Jul 2020 13:39:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1593661175; bh=HR0HDUYKk0U1/OlgILhWF+cY54dTSnJCQpk8USkj4vE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MjT5cM1ce9wV0LUYpe7QwlM3SJ2oYDx8FMObTfMN6wwn0DyDl72/aNy7A/imOz6DH aBlTjqX7R9zcutGjh9+tRv2U8+u2COWIa6eCDzEFeQD2zKMCzjqFKb1EwqyQ4kLSRu Hh6p6l+OueyGxH6tLp3sVkMowYlpTrP81aTKT9R+P+NaI89sOF/cZ+phRthtd20bc2 NRnfPpcXglkWyy3B6LRjGWiCvrIitgDOc4ge6kCsbgWt4z9oYgMOcCYnz98eWDxElZ AwsPHLUhadF49m1/epEnIoGHECdKtmWvtcJ2DUE3JUXtOClewES+47cXMjRSO+9RKf OhTKNi6I7pGsg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 2 Jul 2020 13:39:07 +1000 Message-Id: <20200702033918.708013-9-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200702033918.708013-1-amitay@ozlabs.org> References: <20200702033918.708013-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 08/19] libpdbg: Add thread procedures to get/set FPR 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/hwunit.h | 3 +++ libpdbg/libpdbg.h | 18 ++++++++++++++++++ libpdbg/thread.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/libpdbg/hwunit.h b/libpdbg/hwunit.h index 691689f..ee825bb 100644 --- a/libpdbg/hwunit.h +++ b/libpdbg/hwunit.h @@ -151,6 +151,9 @@ struct thread { int (*getspr)(struct thread *, int, uint64_t *); int (*putspr)(struct thread *, int, uint64_t); + int (*getfpr)(struct thread *, int, uint64_t *); + int (*putfpr)(struct thread *, int, uint64_t); + int (*getmsr)(struct thread *, uint64_t *); int (*putmsr)(struct thread *, uint64_t); diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index a3c90de..180a609 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -946,6 +946,24 @@ int thread_getxer(struct pdbg_target *thread, uint64_t *value); */ int thread_putxer(struct pdbg_target *thread, uint64_t value); +/** + * @brief Set a FPR on a thread + * @param[in] thread the thread target to operate on + * @param[in] fpr the FPR number to set + * @param[in] value value to set FPR to + * @return 0 on success, -1 otherwise + */ +int thread_putfpr(struct pdbg_target *thread, int fpr, uint64_t value); + +/** + * @brief Get a FPR on a thread + * @param[in] thread the thread target to operate on + * @param[in] fpr the FPR number to get + * @param[in] value value of the given FPR + * @return 0 on success, -1 otherwise + */ +int thread_getfpr(struct pdbg_target *thread, int fpr, uint64_t *value); + /** * @brief Get the value of all interesting registers on a thread * @param[in] target the thread target to operate on diff --git a/libpdbg/thread.c b/libpdbg/thread.c index e494dbc..e8fb0c0 100644 --- a/libpdbg/thread.c +++ b/libpdbg/thread.c @@ -361,6 +361,44 @@ int thread_putspr(struct pdbg_target *target, int spr, uint64_t value) return thread->putspr(thread, spr, value); } +int thread_getfpr(struct pdbg_target *target, int fpr, uint64_t *value) +{ + struct thread *thread; + + assert(pdbg_target_is_class(target, "thread")); + + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + return -1; + + thread = target_to_thread(target); + + if (!thread->getfpr) { + PR_ERROR("getfpr() not imeplemented for the target\n"); + return -1; + } + + return thread->getfpr(thread, fpr, value); +} + +int thread_putfpr(struct pdbg_target *target, int fpr, uint64_t value) +{ + struct thread *thread; + + assert(pdbg_target_is_class(target, "thread")); + + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + return -1; + + thread = target_to_thread(target); + + if (!thread->putfpr) { + PR_ERROR("putfpr() not imeplemented for the target\n"); + return -1; + } + + return thread->putfpr(thread, fpr, value); +} + int thread_getmsr(struct pdbg_target *target, uint64_t *value) { struct thread *thread;