diff options
author | Andrew Waterman <andrew@sifive.com> | 2022-03-17 15:43:03 -0700 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2022-03-17 15:43:03 -0700 |
commit | 562d66b814e1abc07304f4277a514bf6ac947c9a (patch) | |
tree | 3dd8488d454e6f3d2f798e757063701881ae1160 /riscv/trap.h | |
parent | 24b962dec17e78d74e4040f572b429e57eb7ee8b (diff) | |
download | spike-562d66b814e1abc07304f4277a514bf6ac947c9a.zip spike-562d66b814e1abc07304f4277a514bf6ac947c9a.tar.gz spike-562d66b814e1abc07304f4277a514bf6ac947c9a.tar.bz2 |
Inline trap_t methods so they can be used in fesvr code
Diffstat (limited to 'riscv/trap.h')
-rw-r--r-- | riscv/trap.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/riscv/trap.h b/riscv/trap.h index 5ae7806..1cd62e1 100644 --- a/riscv/trap.h +++ b/riscv/trap.h @@ -4,7 +4,7 @@ #define _RISCV_TRAP_H #include "decode.h" -#include <stdlib.h> +#include <cstdio> struct state_t; @@ -12,7 +12,6 @@ class trap_t { public: trap_t(reg_t which) : which(which) {} - virtual const char* name(); virtual bool has_gva() { return false; } virtual bool has_tval() { return false; } virtual reg_t get_tval() { return 0; } @@ -21,6 +20,14 @@ class trap_t virtual bool has_tinst() { return false; } virtual reg_t get_tinst() { return 0; } reg_t cause() { return which; } + + virtual const char* name() + { + const char* fmt = uint8_t(which) == which ? "trap #%u" : "interrupt #%u"; + sprintf(_name, fmt, uint8_t(which)); + return _name; + } + private: char _name[16]; reg_t which; |