Skip to content

Commit 2659802

Browse files
committed
riscv_debug: Fixed the vendor ID decode in riscv_hart_read_ids() to adjust for BMD's representation of JEP-106 codes
1 parent d7aea23 commit 2659802

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/target/riscv_debug.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102

103103
#define RV_ISA_EXTENSIONS_MASK 0x03ffffffU
104104

105+
#define RV_VENDOR_JEP106_CONT_MASK 0x7fffff80U
106+
#define RV_VENDOR_JEP106_CODE_MASK 0x7fU
107+
105108
#define RV_DCSR_STEP 0x00000004U
106109
#define RV_DCSR_CAUSE_MASK 0x000001c0U
107110
#define RV_DCSR_STEPIE 0x00000800U
@@ -303,7 +306,12 @@ static uint8_t riscv_isa_address_width(const uint32_t isa)
303306

304307
static void riscv_hart_read_ids(riscv_hart_s *const hart)
305308
{
309+
/* Read out the vendor ID */
306310
riscv_csr_read(hart, RV_VENDOR_ID | RV_CSR_FORCE_32_BIT, &hart->vendorid);
311+
/* Adjust the value to fit our view of JEP-106 codes */
312+
hart->vendorid =
313+
((hart->vendorid & RV_VENDOR_JEP106_CONT_MASK) << 1U) | (hart->vendorid & RV_VENDOR_JEP106_CODE_MASK);
314+
/* Depending on the bus width, read out the other IDs suitably */
307315
if (hart->access_width == 32U) {
308316
riscv_csr_read(hart, RV_ARCH_ID, &hart->archid);
309317
riscv_csr_read(hart, RV_IMPL_ID, &hart->implid);

0 commit comments

Comments
 (0)