Browse Source

Check for 'U' extension before accessing 'mcounteren' CSR

On 64-bit Rocket with 'DefaultFPGAConfig' (using 'WithNSmallCores'),
the 'U' extension is not supported, and accessing 'mcounteren' would
trigger an 'Illegal Instruction' trap.

Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
pull/163/head
Gabriel L. Somlo 7 years ago
parent
commit
9c20a7744f
  1. 3
      machine/minit.c

3
machine/minit.c

@ -30,7 +30,8 @@ static void mstatus_init()
// Enable user/supervisor use of perf counters
if (supports_extension('S'))
write_csr(scounteren, -1);
write_csr(mcounteren, -1);
if (supports_extension('U'))
write_csr(mcounteren, -1);
// Enable software interrupts
write_csr(mie, MIP_MSIP);

Loading…
Cancel
Save