ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
ReturnCode.h
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2//
3// This file is part of ETISS. It is licensed under the BSD 3-Clause License; you may not use this file except in
4// compliance with the License. You should have received a copy of the license along with this project. If not, see the
5// LICENSE file.
17#ifndef ETISS_INCLUDE_RETURNCODE_H_
18#define ETISS_INCLUDE_RETURNCODE_H_
19
20#include "etiss/jit/types.h"
21
22#ifdef __cplusplus
23
24#include "etiss/Misc.h" // etiss::log(2)
25#include <map>
26
27namespace etiss
28{
29
30namespace RETURNCODE
31{
36extern std::map<etiss::int32, const char *> &getErrorMessages();
41extern std::map<etiss::int32, const char *> &getErrorNames();
42
43extern int32_t setTemporary(const std::string &msg);
44
45} // namespace RETURNCODE
46
47} // namespace etiss
48
49#endif
50
53extern int32_t etiss_returncode_setTemporary(const char *msg);
54
55#ifndef etiss_toString
56#define etiss__toString_(X) #X
57#define etiss_toString(X) etiss__toString_(X)
58#endif
59#ifndef etiss_merge2
60#define etiss__merge2_(X, Y) X##Y
61#define etiss_merge2(X, Y) etiss__merge2_(X, Y)
62#endif
63
67#ifdef __cplusplus
68#ifdef ETISS_RETURNCODE_REGISTRATION_BODY
69
70#define defineReturnCodeClass_(UNIQUENUMBER, NAME, VALUE, MSG) \
71 static class ReturnCodeRegistration_##UNIQUENUMBER \
72 { \
73 public: \
74 ReturnCodeRegistration_##UNIQUENUMBER() \
75 { \
76 auto entry = etiss::RETURNCODE::getErrorNames().find(VALUE); \
77 if (entry != etiss::RETURNCODE::getErrorNames().end()) \
78 { \
79 if (std::string(entry->second) != etiss_toString(NAME)) \
80 { \
81 std::stringstream ss; \
82 ss << "Duplicated RETURNCODE " << VALUE << ": "; \
83 ss << etiss::RETURNCODE::getErrorNames().find(VALUE)->second << "," << etiss_toString(NAME); \
84 etiss::log(etiss::ERROR, ss.str()); \
85 } \
86 } \
87 etiss::RETURNCODE::getErrorMessages()[VALUE] = MSG; \
88 etiss::RETURNCODE::getErrorNames()[VALUE] = etiss_toString(NAME); \
89 } \
90 } returnCodeRegistration_##UNIQUENUMBER
91
92#define defineReturnCodeClass(UNIQUENUMBER, NAME, VALUE, MSG) defineReturnCodeClass_(UNIQUENUMBER, NAME, VALUE, MSG)
93
94#define defineReturnCode(NAME, VALUE, MSG) \
95 namespace etiss \
96 { \
97 namespace RETURNCODE \
98 { \
99 static const etiss::int32 NAME = VALUE; \
100 } \
101 } \
102 static const etiss_int32 etiss_merge2(ETISS_RETURNCODE_, NAME) = VALUE; \
103 defineReturnCodeClass(__COUNTER__, NAME, VALUE, MSG)
104#else
105#define defineReturnCode(NAME, VALUE, MSG) \
106 namespace etiss \
107 { \
108 namespace RETURNCODE \
109 { \
110 static const etiss::int32 NAME = VALUE; \
111 } \
112 } \
113 static const etiss_int32 ETISS_RETURNCODE_##NAME = VALUE
114#endif
115#else
116#define defineReturnCode(NAME, VALUE, MSG) static const etiss_int32 ETISS_RETURNCODE_##NAME = VALUE
117#endif
118
119// winerror.h defines this.
120#ifdef NOERROR
121#undef NOERROR
122#endif
123
125
126defineReturnCode(NOERROR, 0, "No error.");
127defineReturnCode(GENERALERROR, -1, "General error.");
128defineReturnCode(RELOADBLOCKS, -2, "Clear cached translated blocks.");
129defineReturnCode(RELOADCURRENTBLOCK, -3, "Clear the cached block that returned this code.");
130// defineReturnCode(RELOADRANGE,-4,"clear cached translated blocks in a range")
131defineReturnCode(DBUS_READ_ERROR, -5, "Data bus read error.");
132defineReturnCode(DBUS_WRITE_ERROR, -6, "Data bus write error.");
133defineReturnCode(IBUS_READ_ERROR, -7, "Instruction bus read error.");
134defineReturnCode(IBUS_WRITE_ERROR, -8, "Instruction bus write error.");
135defineReturnCode(INTERRUPT, -9, "Signal an interrupt.");
136defineReturnCode(RESET, -10, "Reset signal.");
137defineReturnCode(ILLEGALINSTRUCTION, -11, "Illegal instruction.");
138defineReturnCode(ILLEGALJUMP, -12, "Illegal jump address.");
139defineReturnCode(INSTR_PAGEFAULT, -13, "Instruction page fault.");
140defineReturnCode(LOAD_PAGEFAULT, -14, "Load page fault.");
141defineReturnCode(STORE_PAGEFAULT, -15, "Store page fault.");
142defineReturnCode(GDBNOERROR, -16,
143 "Has the same effect as NOERROR but allows exiting a block where NOERROR "
144 "would have continued block execution.");
145defineReturnCode(SYSCALL, -17, "System call");
146defineReturnCode(PAGEFAULT, -18, "Virtual memory tranlation fault.");
147defineReturnCode(BREAKPOINT, -19, "Break point.");
148defineReturnCode(CPUFINISHED, 1 << 31,
149 "Finished cpu execution. This is the proper way to exit from "
150 "etiss::CPUCore::execute.");
151defineReturnCode(CPUTERMINATED, 0x80000001,
152 "Terminates cpu execution. this is the proper way to force an "
153 "exit from etiss::CPUCore::execute (e.g. by a debugger).");
154defineReturnCode(JITERROR, -32, "Error in JIT.");
155defineReturnCode(JITCOMPILATIONERROR, -33, "Error in JIT compilation.");
156defineReturnCode(ARCHERROR, -34, "Error in architecture.");
157defineReturnCode(EMULATIONNOTSUPPORTED, -35, "Emulation is not supported.");
158defineReturnCode(INVALIDSYSTEM, -36,
159 "An ETISS_System structure doesn't contain "
160 "the neccessary function pointers.");
161defineReturnCode(TEMPORARY0, -128, "");
162defineReturnCode(TEMPORARY1, -129, "");
163defineReturnCode(TEMPORARY2, -130, "");
164defineReturnCode(TEMPORARY3, -131, "");
165defineReturnCode(TEMPORARY4, -132, "");
166defineReturnCode(TEMPORARY5, -133, "");
167defineReturnCode(TEMPORARY6, -134, "");
168defineReturnCode(TEMPORARY7, -135, "");
169#define ETISS_RETURNCODE_TEMPORARY_COUNT 8
170
171#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:116
forwards: include/jit/*
Definition Benchmark.h:17