aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsashimi-yzh <yuzihao@ict.ac.cn>2016-09-10 01:50:54 +0800
committerAndrew Waterman <waterman@eecs.berkeley.edu>2016-09-09 10:50:54 -0700
commit292fb6e737b59178ac1911527e995abd161da329 (patch)
treea637362542ca1e2116a88d12e98212f1cb9f7501
parent08a6142a0413fe9c6aa86ce58a73f169ab030c7e (diff)
downloadpk-292fb6e737b59178ac1911527e995abd161da329.zip
pk-292fb6e737b59178ac1911527e995abd161da329.tar.gz
pk-292fb6e737b59178ac1911527e995abd161da329.tar.bz2
machine, emulation.c: fix the condition of rdtime emulation (#37)
The time counter is enabled with the bit field set in `counteren` CSR.
-rw-r--r--machine/emulation.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/machine/emulation.c b/machine/emulation.c
index ae99908..e574b99 100644
--- a/machine/emulation.c
+++ b/machine/emulation.c
@@ -95,13 +95,13 @@ static inline int emulate_read_csr(int num, uintptr_t mstatus, uintptr_t* result
switch (num)
{
case CSR_TIME:
- if ((counteren >> (CSR_TIME - CSR_CYCLE)) & 1)
+ if (!((counteren >> (CSR_TIME - CSR_CYCLE)) & 1))
return -1;
*result = *mtime;
return 0;
#ifdef __riscv32
case CSR_TIMEH:
- if ((counteren >> (CSR_TIME - CSR_CYCLE)) & 1)
+ if (!((counteren >> (CSR_TIME - CSR_CYCLE)) & 1))
return -1;
*result = *mtime >> 32;
return 0;