From 6082f35a5587d110d4bcf2c540d1ffa55db4ab63 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 16 Jun 2017 14:01:08 -0700 Subject: [PATCH] Update debug_defines. Clarify debug output. Update debug_defines from the spec, commit 920ec9a690. Decode dmstatus scans in the debug output. --- src/target/riscv/debug_defines.h | 108 +++++++++++++++++-------------- src/target/riscv/riscv-013.c | 62 +++++++++++++++++- 2 files changed, 118 insertions(+), 52 deletions(-) diff --git a/src/target/riscv/debug_defines.h b/src/target/riscv/debug_defines.h index 2fb541b8e..e5f929105 100644 --- a/src/target/riscv/debug_defines.h +++ b/src/target/riscv/debug_defines.h @@ -84,7 +84,7 @@ /* * 0: Version described in spec version 0.11. * -* 1: Version described in spec version 0.12 (and later?), which +* 1: Version described in spec version 0.13 (and later?), which * reduces the DMI data width to 32 bits. * * Other values are reserved for future use. @@ -110,7 +110,12 @@ /* * When the debugger writes this field, it has the following meaning: * -* 0: Ignore \Fdata. (nop) +* 0: Ignore \Fdata and \Faddress. (nop) +* +* Don't send anything over the DMI during Update-DR. +* This operation should never result in a busy or error response. +* The address and data reported in the following Capture-DR +* are undefined. * * 1: Read from \Faddress. (read) * @@ -151,13 +156,11 @@ /* * 0: There is no external debug support. * -* 1: External debug support exists as it is described in this document. -* -* Other values are reserved for future standards. +* 4: External debug support exists as it is described in this document. */ -#define CSR_DCSR_XDEBUGVER_OFFSET 30 -#define CSR_DCSR_XDEBUGVER_LENGTH 2 -#define CSR_DCSR_XDEBUGVER (0x3 << CSR_DCSR_XDEBUGVER_OFFSET) +#define CSR_DCSR_XDEBUGVER_OFFSET 28 +#define CSR_DCSR_XDEBUGVER_LENGTH 4 +#define CSR_DCSR_XDEBUGVER (0xf << CSR_DCSR_XDEBUGVER_OFFSET) /* * When 1, {\tt ebreak} instructions in Machine Mode enter Debug Mode. */ @@ -230,8 +233,11 @@ #define CSR_DCSR_CAUSE (0x7 << CSR_DCSR_CAUSE_OFFSET) /* * When set and not in Debug Mode, the hart will only execute a single -* instruction, and then enter Debug Mode. Interrupts are disabled -* when this bit is set. +* instruction and then enter Debug Mode. +* Interrupts are disabled when this bit is set. +* If the instruction does not complete due to an exception, +* the hart will immediately enter Debug Mode before executing +* the trap handler, with appropriate exception registers set. */ #define CSR_DCSR_STEP_OFFSET 2 #define CSR_DCSR_STEP_LENGTH 1 @@ -255,16 +261,6 @@ #define CSR_DPC_DPC (((1L< %s", + out_text, in_text); + } } static riscv013_info_t *get_info(const struct target *target) @@ -985,9 +1043,9 @@ static int examine(struct target *target) uint32_t dmcontrol = dmi_read(target, DMI_DMCONTROL); uint32_t dmstatus = dmi_read(target, DMI_DMSTATUS); - if (get_field(dmstatus, DMI_DMSTATUS_VERSIONLO) != 2) { + if (get_field(dmstatus, DMI_DMSTATUS_VERSION) != 2) { LOG_ERROR("OpenOCD only supports Debug Module version 2, not %d " - "(dmstatus=0x%x)", get_field(dmstatus, DMI_DMSTATUS_VERSIONLO), dmstatus); + "(dmstatus=0x%x)", get_field(dmstatus, DMI_DMSTATUS_VERSION), dmstatus); return ERROR_FAIL; }