diff options
Diffstat (limited to 'fesvr/htif.h')
-rw-r--r-- | fesvr/htif.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/fesvr/htif.h b/fesvr/htif.h index 44a3b12..66a626d 100644 --- a/fesvr/htif.h +++ b/fesvr/htif.h @@ -6,9 +6,11 @@ #include "memif.h" #include "syscall.h" #include "device.h" +#include "byteorder.h" #include <string.h> #include <map> #include <vector> +#include <assert.h> class htif_t : public chunked_memif_t { @@ -27,6 +29,30 @@ class htif_t : public chunked_memif_t virtual memif_t& memif() { return mem; } + template<typename T> inline T from_target(T n) const + { +#ifdef RISCV_ENABLE_DUAL_ENDIAN + memif_endianness_t endianness = get_target_endianness(); + assert(endianness == memif_endianness_little || endianness == memif_endianness_big); + + return endianness == memif_endianness_big? from_be(n) : from_le(n); +#else + return from_le(n); +#endif + } + + template<typename T> inline T to_target(T n) const + { +#ifdef RISCV_ENABLE_DUAL_ENDIAN + memif_endianness_t endianness = get_target_endianness(); + assert(endianness == memif_endianness_little || endianness == memif_endianness_big); + + return endianness == memif_endianness_big? to_be(n) : to_le(n); +#else + return to_le(n); +#endif + } + protected: virtual void reset() = 0; |