On 7/4/21 11:43 PM, Kito Cheng wrote:
+static uint32_t get_elf_hwcap(void) +{ + RISCVCPU *cpu = RISCV_CPU(thread_cpu); + uint32_t hwcap = 0; + +#define MISA_BIT(EXT) (1 << (EXT - 'A')) +#define GET_EXT(EXT) \ + do { \ + if (cpu->env.misa & MISA_BIT(EXT)) { \ + hwcap |= MISA_BIT(EXT); \ + } \ + } while (0) + + GET_EXT('I'); + GET_EXT('M'); + GET_EXT('A'); + GET_EXT('F'); + GET_EXT('D'); + GET_EXT('C');
You're not transforming the bits; there's no reason to be so around-the-bush about this. Just use
uint32_t mask = MISA_BIT('I') | ... return cpu->env.misa & mask; r~