Skip to content

Commit

Permalink
riscv_debug: Fixed the vendor ID decode in riscv_hart_read_ids() to a…
Browse files Browse the repository at this point in the history
…djust for BMD's representation of JEP-106 codes
  • Loading branch information
dragonmux committed Jun 6, 2023
1 parent a8e6805 commit c000161
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/target/riscv_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@

#define RV_ISA_EXTENSIONS_MASK 0x03ffffffU

#define RV_VENDOR_JEP106_CONT_MASK 0x7fffff80U
#define RV_VENDOR_JEP106_CODE_MASK 0x7fU

#define RV_DCSR_STEP 0x00000004U
#define RV_DCSR_CAUSE_MASK 0x000001c0U
#define RV_DCSR_STEPIE 0x00000800U
Expand Down Expand Up @@ -303,7 +306,12 @@ static uint8_t riscv_isa_address_width(const uint32_t isa)

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

0 comments on commit c000161

Please sign in to comment.