diff mbox series

[04/19] pdbg: Add getxer & putxer commands

Message ID 20180829015047.7355-5-rashmica.g@gmail.com
State Superseded
Headers show
Series Basic gdbserver for POWER8 | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master

Commit Message

Rashmica Gupta Aug. 29, 2018, 1:50 a.m. UTC
Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com>
---
 src/main.c |  6 ++++--
 src/reg.c  | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/main.c b/src/main.c
index b48c201..5d840ef 100644
--- a/src/main.c
+++ b/src/main.c
@@ -86,7 +86,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,
@@ -94,7 +94,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
@@ -114,6 +114,8 @@  static struct action actions[] = {
 	{ "putspr",  "<spr> <value>", "Write Special Purpose Register (SPR)" },
 	{ "getmsr",  "", "Get Machine State Register (MSR)" },
 	{ "putmsr",  "<value>", "Write Machine State Register (MSR)" },
+	{ "getxer",  "", "Get Fixed Point Exception Register (XER)" },
+	{ "putxer",  "<value>", "Write Fixed Point Exception Register (XER)" },
 	{ "getring", "<addr> <len>", "Read a ring. Length must be correct" },
 	{ "start",   "", "Start thread" },
 	{ "step",    "<count>", "Set a thread <count> instructions" },
diff --git a/src/reg.c b/src/reg.c
index c63f6da..3864316 100644
--- a/src/reg.c
+++ b/src/reg.c
@@ -24,6 +24,7 @@ 
 #include "main.h"
 #include "optcmd.h"
 
+#define REG_XER -4
 #define REG_MEM -3
 #define REG_MSR -2
 #define REG_NIA -1
@@ -42,6 +43,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 +66,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 +87,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, &value);
 	else if (*reg > REG_R31)
 		rc = ram_getspr(target, *reg - REG_R31, &value);
 	else if (*reg >= 0 && *reg <= 31)
@@ -147,3 +154,18 @@  static int putmsr(uint64_t data)
 	return for_each_target("thread", putprocreg, &reg, &data);
 }
 OPTCMD_DEFINE_CMD_WITH_ARGS(putmsr, putmsr, (DATA));
+
+static int getxer(void)
+{
+	uint64_t reg = REG_XER;
+	return for_each_target("thread", getprocreg, &reg, NULL);
+}
+OPTCMD_DEFINE_CMD(getxer, getxer);
+
+static int putxer(uint64_t data)
+{
+	uint64_t reg = REG_XER;
+	uint64_t d = data;
+	return for_each_target("thread", putprocreg, &reg, &d);
+}
+OPTCMD_DEFINE_CMD_WITH_ARGS(putxer, putxer, (DATA));