ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
65namespace etiss
66{
67
68namespace RETURNCODE
69{
74extern std::map<etiss::int32, const char *> &getErrorMessages();
79extern std::map<etiss::int32, const char *> &getErrorNames();
80
81extern int32_t setTemporary(const std::string &msg);
82
83} // namespace RETURNCODE
84
85} // namespace etiss
86
87#endif
88
91extern 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
164defineReturnCode(NOERROR, 0, "No error.");
165defineReturnCode(GENERALERROR, -1, "General error.");
166defineReturnCode(RELOADBLOCKS, -2, "Clear cached translated blocks.");
167defineReturnCode(RELOADCURRENTBLOCK, -3, "Clear the cached block that returned this code.");
168// defineReturnCode(RELOADRANGE,-4,"clear cached translated blocks in a range")
169defineReturnCode(DBUS_READ_ERROR, -5, "Data bus read error.");
170defineReturnCode(DBUS_WRITE_ERROR, -6, "Data bus write error.");
171defineReturnCode(IBUS_READ_ERROR, -7, "Instruction bus read error.");
172defineReturnCode(IBUS_WRITE_ERROR, -8, "Instruction bus write error.");
173defineReturnCode(INTERRUPT, -9, "Signal an interrupt.");
174defineReturnCode(RESET, -10, "Reset signal.");
175defineReturnCode(ILLEGALINSTRUCTION, -11, "Illegal instruction.");
176defineReturnCode(ILLEGALJUMP, -12, "Illegal jump address.");
177defineReturnCode(INSTR_PAGEFAULT, -13, "Instruction page fault.");
178defineReturnCode(LOAD_PAGEFAULT, -14, "Load page fault.");
179defineReturnCode(STORE_PAGEFAULT, -15, "Store page fault.");
180defineReturnCode(GDBNOERROR, -16,
181 "Has the same effect as NOERROR but allows exiting a block where NOERROR "
182 "would have continued block execution.");
183defineReturnCode(SYSCALL, -17, "System call");
184defineReturnCode(PAGEFAULT, -18, "Virtual memory tranlation fault.");
185defineReturnCode(BREAKPOINT, -19, "Break point.");
186defineReturnCode(CPUFINISHED, 1 << 31,
187 "Finished cpu execution. This is the proper way to exit from "
188 "etiss::CPUCore::execute.");
189defineReturnCode(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).");
192defineReturnCode(JITERROR, -32, "Error in JIT.");
193defineReturnCode(JITCOMPILATIONERROR, -33, "Error in JIT compilation.");
194defineReturnCode(ARCHERROR, -34, "Error in architecture.");
195defineReturnCode(EMULATIONNOTSUPPORTED, -35, "Emulation is not supported.");
196defineReturnCode(INVALIDSYSTEM, -36,
197 "An ETISS_System structure doesn't contain "
198 "the neccessary function pointers.");
199defineReturnCode(TEMPORARY0, -128, "");
200defineReturnCode(TEMPORARY1, -129, "");
201defineReturnCode(TEMPORARY2, -130, "");
202defineReturnCode(TEMPORARY3, -131, "");
203defineReturnCode(TEMPORARY4, -132, "");
204defineReturnCode(TEMPORARY5, -133, "");
205defineReturnCode(TEMPORARY6, -134, "");
206defineReturnCode(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.
#define defineReturnCode(NAME, VALUE, MSG)
define RETURNCODE definition template for easy use with c and c++
Definition ReturnCode.h:154
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition Benchmark.h:53