ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
ReturnCode.h
Go to the documentation of this file.
1 
55 #ifndef ETISS_INCLUDE_RETURNCODE_H_
56 #define ETISS_INCLUDE_RETURNCODE_H_
57 
58 #include "etiss/jit/types.h"
59 
60 #ifdef __cplusplus
61 
62 #include "etiss/Misc.h" // etiss::log(2)
63 #include <map>
64 
65 namespace etiss
66 {
67 
68 namespace RETURNCODE
69 {
74 extern std::map<etiss::int32, const char *> &getErrorMessages();
79 extern std::map<etiss::int32, const char *> &getErrorNames();
80 
81 extern int32_t setTemporary(const std::string &msg);
82 
83 } // namespace RETURNCODE
84 
85 } // namespace etiss
86 
87 #endif
88 
91 extern int32_t etiss_returncode_setTemporary(const char *msg);
92 
93 #ifndef etiss_toString
94 #define etiss__toString_(X) #X
95 #define etiss_toString(X) etiss__toString_(X)
96 #endif
97 #ifndef etiss_merge2
98 #define etiss__merge2_(X, Y) X##Y
99 #define etiss_merge2(X, Y) etiss__merge2_(X, Y)
100 #endif
101 
105 #ifdef __cplusplus
106 #ifdef ETISS_RETURNCODE_REGISTRATION_BODY
107 
108 #define defineReturnCodeClass_(UNIQUENUMBER, NAME, VALUE, MSG) \
109  static class ReturnCodeRegistration_##UNIQUENUMBER \
110  { \
111  public: \
112  ReturnCodeRegistration_##UNIQUENUMBER() \
113  { \
114  auto entry = etiss::RETURNCODE::getErrorNames().find(VALUE); \
115  if (entry != etiss::RETURNCODE::getErrorNames().end()) \
116  { \
117  if (std::string(entry->second) != etiss_toString(NAME)) \
118  { \
119  std::stringstream ss; \
120  ss << "Duplicated RETURNCODE " << VALUE << ": "; \
121  ss << etiss::RETURNCODE::getErrorNames().find(VALUE)->second << "," << etiss_toString(NAME); \
122  etiss::log(etiss::ERROR, ss.str()); \
123  } \
124  } \
125  etiss::RETURNCODE::getErrorMessages()[VALUE] = MSG; \
126  etiss::RETURNCODE::getErrorNames()[VALUE] = etiss_toString(NAME); \
127  } \
128  } returnCodeRegistration_##UNIQUENUMBER
129 
130 #define defineReturnCodeClass(UNIQUENUMBER, NAME, VALUE, MSG) defineReturnCodeClass_(UNIQUENUMBER, NAME, VALUE, MSG)
131 
132 #define defineReturnCode(NAME, VALUE, MSG) \
133  namespace etiss \
134  { \
135  namespace RETURNCODE \
136  { \
137  static const etiss::int32 NAME = VALUE; \
138  } \
139  } \
140  static const etiss_int32 etiss_merge2(ETISS_RETURNCODE_, NAME) = VALUE; \
141  defineReturnCodeClass(__COUNTER__, NAME, VALUE, MSG)
142 #else
143 #define defineReturnCode(NAME, VALUE, MSG) \
144  namespace etiss \
145  { \
146  namespace RETURNCODE \
147  { \
148  static const etiss::int32 NAME = VALUE; \
149  } \
150  } \
151  static const etiss_int32 ETISS_RETURNCODE_##NAME = VALUE
152 #endif
153 #else
154 #define defineReturnCode(NAME, VALUE, MSG) static const etiss_int32 ETISS_RETURNCODE_##NAME = VALUE
155 #endif
156 
157 // winerror.h defines this.
158 #ifdef NOERROR
159 #undef NOERROR
160 #endif
161 
163 
164 defineReturnCode(NOERROR, 0, "No error.");
165 defineReturnCode(GENERALERROR, -1, "General error.");
166 defineReturnCode(RELOADBLOCKS, -2, "Clear cached translated blocks.");
167 defineReturnCode(RELOADCURRENTBLOCK, -3, "Clear the cached block that returned this code.");
168 // defineReturnCode(RELOADRANGE,-4,"clear cached translated blocks in a range")
169 defineReturnCode(DBUS_READ_ERROR, -5, "Data bus read error.");
170 defineReturnCode(DBUS_WRITE_ERROR, -6, "Data bus write error.");
171 defineReturnCode(IBUS_READ_ERROR, -7, "Instruction bus read error.");
172 defineReturnCode(IBUS_WRITE_ERROR, -8, "Instruction bus write error.");
173 defineReturnCode(INTERRUPT, -9, "Signal an interrupt.");
174 defineReturnCode(RESET, -10, "Reset signal.");
175 defineReturnCode(ILLEGALINSTRUCTION, -11, "Illegal instruction.");
176 defineReturnCode(ILLEGALJUMP, -12, "Illegal jump address.");
177 defineReturnCode(INSTR_PAGEFAULT, -13, "Instruction page fault.");
178 defineReturnCode(LOAD_PAGEFAULT, -14, "Load page fault.");
179 defineReturnCode(STORE_PAGEFAULT, -15, "Store page fault.");
180 defineReturnCode(GDBNOERROR, -16,
181  "Has the same effect as NOERROR but allows exiting a block where NOERROR "
182  "would have continued block execution.");
183 defineReturnCode(SYSCALL, -17, "System call");
184 defineReturnCode(PAGEFAULT, -18, "Virtual memory tranlation fault.");
185 defineReturnCode(BREAKPOINT, -19, "Break point.");
186 defineReturnCode(CPUFINISHED, 1 << 31,
187  "Finished cpu execution. This is the proper way to exit from "
188  "etiss::CPUCore::execute.");
189 defineReturnCode(CPUTERMINATED, 0x80000001,
190  "Terminates cpu execution. this is the proper way to force an "
191  "exit from etiss::CPUCore::execute (e.g. by a debugger).");
192 defineReturnCode(JITERROR, -32, "Error in JIT.");
193 defineReturnCode(JITCOMPILATIONERROR, -33, "Error in JIT compilation.");
194 defineReturnCode(ARCHERROR, -34, "Error in architecture.");
195 defineReturnCode(EMULATIONNOTSUPPORTED, -35, "Emulation is not supported.");
196 defineReturnCode(INVALIDSYSTEM, -36,
197  "An ETISS_System structure doesn't contain "
198  "the neccessary function pointers.");
199 defineReturnCode(TEMPORARY0, -128, "");
200 defineReturnCode(TEMPORARY1, -129, "");
201 defineReturnCode(TEMPORARY2, -130, "");
202 defineReturnCode(TEMPORARY3, -131, "");
203 defineReturnCode(TEMPORARY4, -132, "");
204 defineReturnCode(TEMPORARY5, -133, "");
205 defineReturnCode(TEMPORARY6, -134, "");
206 defineReturnCode(TEMPORARY7, -135, "");
207 #define ETISS_RETURNCODE_TEMPORARY_COUNT 8
208 
209 #endif
general configuration and logging
static __inline__ int32_t
Definition: arm_mve.h:51
int32_t etiss_returncode_setTemporary(const char *msg)
sets the message of a temporary return code and returns the returncode.
Definition: ReturnCode.cpp:81
#define defineReturnCode(NAME, VALUE, MSG)
define RETURNCODE definition template for easy use with c and c++
Definition: ReturnCode.h:154
MM_EXPORT const int32_t NOERROR
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition: Benchmark.h:53