Commit d97106e9 authored by Alexander Shabarshin's avatar Alexander Shabarshin

some changes

parent 51ffd195
......@@ -334,14 +334,18 @@ int csr_read(uint32_t *pval, uint32_t csr,
{
uint32_t val;
#ifdef DEBUG_EXTRA
printf("csr_read: csr=0x%03x %i\n", csr, will_write);
#endif
if (((csr & 0xc00) == 0xc00) && will_write)
return -1; /* read-only CSR */
if (priv < ((csr >> 8) & 3))
return -1; /* not enough priviledge */
switch(csr) {
case 0xc00: /* ucycle */
case 0xc02: /* uinstret */
case 0xc00: /* cycle */
case 0xc02: /* instret */
{
uint32_t counteren;
if (priv < PRV_M) {
......@@ -357,8 +361,8 @@ int csr_read(uint32_t *pval, uint32_t csr,
}
val = (int64_t)insn_counter;
break;
case 0xc80: /* mcycleh */
case 0xc82: /* minstreth */
case 0xc80: /* cycleh */
case 0xc82: /* instreth */
{
uint32_t counteren;
if (priv < PRV_M) {
......@@ -458,6 +462,11 @@ int csr_read(uint32_t *pval, uint32_t csr,
/* return -1; */
return 0;
}
#ifdef DEBUG_EXTRA
printf("csr_read: csr=0x%03x --> 0x%08x\n", csr, val);
#endif
*pval = val;
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment