This is an automated email from Gerrit.

"Walter J. <walter...@oss.cipunited.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7906

-- gerrit

commit 9bcb310a26bd3e8f74acb789abef9f612697d426
Author: Walter Ji <walter...@oss.cipunited.com>
Date:   Fri Sep 22 13:19:03 2023 +0800

    target/mips32: add mips ejtag command
    
    Add mips32 ejtag_reg command for inspecting ejtag status.
    
    Change-Id: Icd173d3397d568b0c004a8cc3f45518d7b48ce43
    Signed-off-by: Walter Ji <walter...@oss.cipunited.com>

diff --git a/src/target/mips32.c b/src/target/mips32.c
index af2b11d8c7..1c39f6ab5e 100644
--- a/src/target/mips32.c
+++ b/src/target/mips32.c
@@ -2161,6 +2161,70 @@ COMMAND_HANDLER(mips32_handle_cpuinfo_command)
 
        return ERROR_OK;
 }
+
+extern void ejtag_main_print_imp(struct mips_ejtag *ejtag_info);
+extern int mips_ejtag_get_impcode(struct mips_ejtag *ejtag_info);
+
+COMMAND_HANDLER(mips32_handle_ejtag_reg_command)
+{
+       struct target *target = get_current_target(CMD_CTX);
+       struct mips32_common *mips32 = target_to_mips32(target);
+       struct mips_ejtag *ejtag_info = &mips32->ejtag_info;
+
+       uint32_t idcode;
+       uint32_t impcode;
+       uint32_t ejtag_ctrl;
+       uint32_t dcr;
+       int retval;
+
+       retval = mips_ejtag_get_idcode(ejtag_info);
+       idcode = ejtag_info->idcode;
+       retval = mips_ejtag_get_impcode(ejtag_info);
+       impcode = ejtag_info->impcode;
+       mips_ejtag_set_instr(ejtag_info, EJTAG_INST_CONTROL);
+       ejtag_ctrl = ejtag_info->ejtag_ctrl;
+       retval = mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl);
+
+       if (retval != ERROR_OK)
+               LOG_INFO("Encounter an Error");
+
+       LOG_USER("       idcode: 0x%8.8x", idcode);
+       LOG_USER("      impcode: 0x%8.8x", impcode);
+       LOG_USER("ejtag control: 0x%8.8x", ejtag_ctrl);
+
+       ejtag_main_print_imp(ejtag_info);
+
+       /* Display current DCR */
+       retval = target_read_u32(target, EJTAG_DCR, &dcr);
+       LOG_USER("          DCR: 0x%8.8x", dcr);
+
+       if (((dcr >> 22) & 0x1) == 1)
+               LOG_USER("DAS supported");
+
+       if (((dcr >> 18) & 0x1) == 1)
+               LOG_USER("FDC supported");
+
+       if (((dcr >> 17) & 0x1) == 1)
+               LOG_USER("DataBrk supported");
+
+       if (((dcr >> 16) & 0x1) == 1)
+               LOG_USER("InstBrk supported");
+
+       if (((dcr >> 15) & 0x1) == 1)
+               LOG_USER("Inverted Data value supported");
+
+       if (((dcr >> 14) & 0x1) == 1)
+               LOG_USER("Data value stored supported");
+
+       if (((dcr >> 10) & 0x1) == 1)
+               LOG_USER("Complex Breakpoints supported");
+
+       if (((dcr >> 9) & 0x1) == 1)
+               LOG_USER("PC Sampling supported");
+
+       return ERROR_OK;
+}
+
 COMMAND_HANDLER(mips32_handle_scan_delay_command)
 {
        struct target *target = get_current_target(CMD_CTX);
@@ -2206,6 +2270,13 @@ static const struct command_registration 
mips32_exec_command_handlers[] = {
                .help = "display/set scan delay in nano seconds",
                .usage = "[value]",
        },
+       {
+               .name = "ejtag_reg",
+               .handler = mips32_handle_ejtag_reg_command,
+               .mode = COMMAND_ANY,
+               .help = "read ejtag registers",
+               .usage = "",
+       },
        COMMAND_REGISTRATION_DONE
 };
 
diff --git a/src/target/mips_ejtag.c b/src/target/mips_ejtag.c
index 5c92bf9ee3..389461cae6 100644
--- a/src/target/mips_ejtag.c
+++ b/src/target/mips_ejtag.c
@@ -47,7 +47,7 @@ int mips_ejtag_get_idcode(struct mips_ejtag *ejtag_info)
        return mips_ejtag_drscan_32(ejtag_info, &ejtag_info->idcode);
 }
 
-static int mips_ejtag_get_impcode(struct mips_ejtag *ejtag_info)
+int mips_ejtag_get_impcode(struct mips_ejtag *ejtag_info)
 {
        mips_ejtag_set_instr(ejtag_info, EJTAG_INST_IMPCODE);
 
@@ -332,7 +332,7 @@ static void ejtag_v26_print_imp(struct mips_ejtag 
*ejtag_info)
                EJTAG_IMP_HAS(EJTAG_V26_IMP_DINT) ? " DINT" : "");
 }
 
-static void ejtag_main_print_imp(struct mips_ejtag *ejtag_info)
+void ejtag_main_print_imp(struct mips_ejtag *ejtag_info)
 {
        LOG_DEBUG("EJTAG main: features:%s%s%s%s%s",
                EJTAG_IMP_HAS(EJTAG_IMP_ASID8) ? " ASID_8" : "",

-- 

Reply via email to