Skip to contentSkip to conversation

PPC: dump DCRs from monitor

RFC PATCH In review François Revol 2 participants 5 messages Aug 29, 2012 – Aug 30, 2012

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 PPC: dump DCRs from monitor

Hi,
I noticed the DCRs weren't shown with the registers or another command, and tried to add one to dump them to help debugging my sam460ex target. This first version doesn't list the names since they aren't registered as such.
I tried adding a name arg to ppc_dcr_register, and a #define to get it from the index, but it seems some code uses a loop to register them, so it gives a dump like:
DCR[SDRAM0_CFGDATA 11] 00000000
DCR[dcr_base + i c0] 00000000
DCR[dcr_base + i c1] 00000000
Any suggestion?
BTW, they aren't saved in state dumps, are they?

François.

cpu-all.h +0 -0
index 5e07d28..a34ae25 100644
@@ -372,6 +372,8 @@ void cpu_dump_state(CPUArchState *env, FILE *f,

fprintf_function cpu_fprintf,

                     int flags);
 void cpu_dump_statistics(CPUArchState *env, FILE *f, fprintf_function
cpu_fprintf,
                          int flags);

+void ppc_dump_dcr(CPUArchState *env, FILE *f, fprintf_function cpu_fprintf,
+ int flags);

void QEMU_NORETURN cpu_abort(CPUArchState *env, const char *fmt, ...)

     GCC_FMT_ATTR(2, 3);
hw/ppc.c +0 -0
index 98546de..74b82b7 100644
@@ -1120,6 +1120,27 @@ int ppc_dcr_init (CPUPPCState *env, int

(*read_error)(int dcrn),

     return 0;

}

+void ppc_dump_dcr (CPUPPCState *env, FILE*f, fprintf_function cpu_fprintf,
+ int flags)
+{

+    ppc_dcr_t *dcr_env;
+    ppc_dcrn_t *dcr;
+    int dcrn;

+
+ dcr_env = env->dcr_env;
+ if (dcr_env == NULL)
+ return;
+
+ for (dcrn = 0; dcrn < DCRN_NB; dcrn++) {
+ dcr = &dcr_env->dcrn[dcrn];
+ if (dcr->dcr_read == NULL)
+ continue;
+
+ cpu_fprintf(f, "DCR[%02x] %08x\n", dcrn,
+ dcr->dcr_read(dcr->opaque, dcrn));
+ }
+}
+
/*****************************************************************************/ /* Debug port */
void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val)

monitor.c +17 -0
index b17b1bb..b7a2a4b 100644
@@ -936,6 +936,14 @@ static void do_info_cpu_stats(Monitor *mon)
     env = mon_get_cpu();
     cpu_dump_statistics(env, (FILE *)mon, &monitor_fprintf, 0);
 }
+
+static void do_info_dcr(Monitor *mon)
+{
+    CPUArchState *env;
+
+    env = mon_get_cpu();
+    ppc_dump_dcr(env, (FILE*)mon, (fprintf_function)monitor_printf, 0);
+}
 #endif
 
 static void do_trace_print_events(Monitor *mon)
@@ -2768,6 +2776,15 @@ static mon_cmd_t info_cmds[] = {
         .mhandler.info = tlb_info,
     },
 #endif
+#if defined(TARGET_PPC)
+    {
+        .name       = "dcr",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show device control registers",
+        .mhandler.info = do_info_dcr,
+    },
+#endif
 #if defined(TARGET_I386)
     {
         .name       = "mem",
#1 lore raw
Quoted 5 lines · François Revol

Hi,
I noticed the DCRs weren't shown with the registers or another command, and tried to add one to dump them to help debugging my sam460ex target. This first version doesn't list the names since they aren't registered as such.

Quoted 8 lines

I tried adding a name arg to ppc_dcr_register, and a #define to get it from the index, but it seems some code uses a loop to register them, so it gives a dump like:
DCR[SDRAM0_CFGDATA 11] 00000000
DCR[dcr_base + i c0] 00000000
DCR[dcr_base + i c1] 00000000
Any suggestion?
BTW, they aren't saved in state dumps, are they?

Are they accessible through the monitor's p command? Would be good to implement there too if not.

Alex

Quoted 86 lines

François.

cpu-all.h +0 -0
index 5e07d28..a34ae25 100644
@@ -372,6 +372,8 @@ void cpu_dump_state(CPUArchState *env, FILE *f,
 fprintf_function cpu_fprintf,
                    int flags);

void cpu_dump_statistics(CPUArchState *env, FILE *f, fprintf_function cpu_fprintf,

                         int flags);
cpu-all.h +2 -0
+void ppc_dump_dcr(CPUArchState *env, FILE *f, fprintf_function cpu_fprintf,
+                  int flags);

void QEMU_NORETURN cpu_abort(CPUArchState *env, const char *fmt, ...)

    GCC_FMT_ATTR(2, 3);
hw/ppc.c +21 -0
index 98546de..74b82b7 100644
@@ -1120,6 +1120,27 @@ int ppc_dcr_init (CPUPPCState *env, int
 (*read_error)(int dcrn),
    return 0;
 }
 
+void ppc_dump_dcr (CPUPPCState *env, FILE*f, fprintf_function cpu_fprintf,
+                   int flags)
+{
+    ppc_dcr_t *dcr_env;
+    ppc_dcrn_t *dcr;
+    int dcrn;
+
+    dcr_env = env->dcr_env;
+    if (dcr_env == NULL)
+        return;
+
+    for (dcrn = 0; dcrn < DCRN_NB; dcrn++) {
+        dcr = &dcr_env->dcrn[dcrn];
+        if (dcr->dcr_read == NULL)
+            continue;
+
+        cpu_fprintf(f, "DCR[%02x] %08x\n", dcrn,
+                    dcr->dcr_read(dcr->opaque, dcrn));
+    }
+}
+
 /*****************************************************************************/
 /* Debug port */

void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val)

monitor.c +17 -0
index b17b1bb..b7a2a4b 100644
@@ -936,6 +936,14 @@ static void do_info_cpu_stats(Monitor *mon)
    env = mon_get_cpu();
    cpu_dump_statistics(env, (FILE *)mon, &monitor_fprintf, 0);
 }
+
+static void do_info_dcr(Monitor *mon)
+{
+    CPUArchState *env;
+
+    env = mon_get_cpu();
+    ppc_dump_dcr(env, (FILE*)mon, (fprintf_function)monitor_printf, 0);
+}
 #endif
 
 static void do_trace_print_events(Monitor *mon)
@@ -2768,6 +2776,15 @@ static mon_cmd_t info_cmds[] = {
        .mhandler.info = tlb_info,
    },
 #endif
+#if defined(TARGET_PPC)
+    {
+        .name       = "dcr",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show device control registers",
+        .mhandler.info = do_info_dcr,
+    },
+#endif
 #if defined(TARGET_I386)
    {
        .name       = "mem",
#2 lore raw
Quoted 18 lines · Alexander Graf
Quoted 5 lines · François Revol

Hi,
I noticed the DCRs weren't shown with the registers or another command, and tried to add one to dump them to help debugging my sam460ex target. This first version doesn't list the names since they aren't registered as such.

Quoted 8 lines

I tried adding a name arg to ppc_dcr_register, and a #define to get it from the index, but it seems some code uses a loop to register them, so it gives a dump like:
DCR[SDRAM0_CFGDATA 11] 00000000
DCR[dcr_base + i c0] 00000000
DCR[dcr_base + i c1] 00000000
Any suggestion?
BTW, they aren't saved in state dumps, are they?

Quoted 1 line

Are they accessible through the monitor's p command? Would be good to implement there too if not.

I don't think so, which syntax would you use anyway? $dcr[n] ?

François.

#3 lore raw
Quoted 19 lines · François Revol
Quoted 18 lines · Alexander Graf
Quoted 13 lines · François Revol

Hi,
I noticed the DCRs weren't shown with the registers or another command, and tried to add one to dump them to help debugging my sam460ex target. This first version doesn't list the names since they aren't registered as such.
I tried adding a name arg to ppc_dcr_register, and a #define to get it from the index, but it seems some code uses a loop to register them, so it gives a dump like:
DCR[SDRAM0_CFGDATA 11] 00000000
DCR[dcr_base + i c0] 00000000
DCR[dcr_base + i c1] 00000000
Any suggestion?
BTW, they aren't saved in state dumps, are they?

Quoted 3 lines
Quoted 1 line

Are they accessible through the monitor's p command? Would be good to implement there too if not.

I don't think so, which syntax would you use anyway? $dcr[n] ?

Sure, why not? Is that possible with the register parsing code? I don't know that one too well, but it's probably the best fit for you, right?

Alex

Quoted 3 lines

François.

#4 lore raw
Quoted 6 lines · Alexander Graf
Quoted 3 lines
Quoted 1 line

Are they accessible through the monitor's p command? Would be good to implement there too if not.

I don't think so, which syntax would you use anyway? $dcr[n] ?

Sure, why not? Is that possible with the register parsing code? I don't know that one too well, but it's probably the best fit for you, right?

Except I don't know the parsing code well enough to not waste time digging it...
For now the full dump is enough to me, I suppose if someone wants more he can also send a patch ;-)

We could also add logging to the read/write calls to see the ordering. For now I just added some printf in my code just like in ppc405*.

François.