@@ -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", "<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" },
@@ -18,12 +18,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <debug.h>
#include <libpdbg.h>
#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));
Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com> --- src/main.c | 6 ++++-- src/reg.c | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-)