@@ -84,7 +84,8 @@ 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_getxer, optcmd_putxer;
+ optcmd_getmem, optcmd_putmem, optcmd_getxer, optcmd_putxer,
+ optcmd_getcr, optcmd_putcr;
static struct optcmd_cmd *cmds[] = {
&optcmd_getscom, &optcmd_putscom, &optcmd_getcfam, &optcmd_putcfam,
@@ -93,6 +94,7 @@ static struct optcmd_cmd *cmds[] = {
&optcmd_getring, &optcmd_start, &optcmd_stop, &optcmd_step,
&optcmd_threadstatus, &optcmd_sreset, &optcmd_regs, &optcmd_probe,
&optcmd_getmem, &optcmd_putmem, &optcmd_getxer, &optcmd_putxer,
+ &optcmd_getcr, &optcmd_putcr,
};
/* Purely for printing usage text. We could integrate printing argument and flag
@@ -112,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)" },
+ { "getcr", "", "Get Condition Register (CR)" },
+ { "putcr", "<value>", "Write Condition Register (CR)" },
{ "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" },
@@ -25,6 +25,7 @@
#include "main.h"
#include "optcmd.h"
+#define REG_CR -5
#define REG_XER -4
#define REG_MEM -3
#define REG_MSR -2
@@ -46,6 +47,8 @@ static void print_proc_reg(struct pdbg_target *target, uint64_t reg, uint64_t va
printf("nia: ");
else if (reg == REG_XER)
printf("xer: ");
+ else if (reg == REG_CR)
+ printf("cr: ");
else if (reg > REG_R31)
printf("spr%03" PRIu64 ": ", reg - REG_R31);
else if (reg >= 0 && reg <= 31)
@@ -69,6 +72,8 @@ static int putprocreg(struct pdbg_target *target, uint32_t index, uint64_t *reg,
rc = ram_putnia(target, *value);
else if (*reg == REG_XER)
rc = ram_putxer(target, *value);
+ else if (*reg == REG_CR)
+ rc = ram_putcr(target, *value);
else if (*reg > REG_R31)
rc = ram_putspr(target, *reg - REG_R31, *value);
else if (*reg >= 0 && *reg <= 31)
@@ -172,3 +177,18 @@ static int putxer(uint32_t data)
return for_each_target("thread", putprocreg, ®, &d);
}
OPTCMD_DEFINE_CMD_WITH_ARGS(putxer, putxer, (DATA32));
+
+static int getcr(void)
+{
+ uint64_t cr = REG_CR;
+ return for_each_target("thread", getprocreg, &cr, NULL);
+}
+OPTCMD_DEFINE_CMD(getcr, getcr);
+
+static int putcr(uint32_t data)
+{
+ uint64_t cr = REG_CR;
+ uint64_t d = data;
+ return for_each_target("thread", putprocreg, &cr, &d);
+}
+OPTCMD_DEFINE_CMD_WITH_ARGS(putcr, putcr, (DATA32));
Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com> --- src/main.c | 6 +++++- src/reg.c | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-)