[Pdbg] [PATCH 08/19] libpdbg: Add thread procedures to get/set FPR
Amitay Isaacs
amitay at ozlabs.org
Thu Jul 2 13:39:07 AEST 2020
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
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;
--
2.26.2
More information about the Pdbg
mailing list