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
InjectorAddress.cpp
Go to the documentation of this file.
1/*
2
3 @copyright
4
5 <pre>
6
7 Copyright 2018 Infineon Technologies AG
8
9 This file is part of ETISS tool, see <https://github.com/tum-ei-eda/etiss>.
10
11 The initial version of this software has been created with the funding support by the German Federal
12 Ministry of Education and Research (BMBF) in the project EffektiV under grant 01IS13022.
13
14 Redistribution and use in source and binary forms, with or without modification, are permitted
15 provided that the following conditions are met:
16
17 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
18 the following disclaimer.
19
20 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
21 and the following disclaimer in the documentation and/or other materials provided with the distribution.
22
23 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse
24 or promote products derived from this software without specific prior written permission.
25
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
27 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
28 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
29 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 POSSIBILITY OF SUCH DAMAGE.
34
35 </pre>
36
37 @author Chair of Electronic Design Automation, TUM
38
39 @version 0.1
40
41*/
42
43#ifndef NO_ETISS
46#else
47#include "fault/Injector.h"
49#endif
50
51namespace etiss
52{
53namespace fault
54{
55
57{
58 etiss::log(etiss::VERBOSE, "Called etiss::fault::InjectorAddress::InjectorAddress()");
59 path_ = ":";
60 iptr_ = 0;
61}
62InjectorAddress::InjectorAddress(const std::string &address)
63{
64 etiss::log(etiss::VERBOSE, "Called etiss::fault::InjectorAddress::InjectorAddress(address=" + address + ")");
65 path_ = address;
66 iptr_ = 0;
67}
69{
71 "Called etiss::fault::InjectorAddress::InjectorAddress(InjectorAddress=" + cpy.toString() + ")");
72 *this = cpy;
73}
75{
77 "Called etiss::fault::InjectorAddress::operator=(InjectorAddress=" + cpy.toString() + ")");
78 path_ = cpy.path_;
79 iptr_ = cpy.iptr_;
80 return *this;
81}
82
83#if CXX0X_UP_SUPPORTED
84
86{
87 etiss::log(etiss::VERBOSE, "Called etiss::fault::InjectorAddress::InjectorAddress(InjectorAddress && ia)");
88 operator=(ia);
89}
90InjectorAddress &InjectorAddress::operator=(InjectorAddress &&ia)
91{
92 etiss::log(etiss::VERBOSE, "Called etiss::fault::InjectorAddress::operator=(InjectorAddress && ia)");
93 operator=((const InjectorAddress &)ia);
94 return *this;
95}
96
97#endif
98
99const std::string &InjectorAddress::getInjectorPath() const
100{
101 return path_;
102}
104{
105
106 if (!iptr_)
107 {
109 if (!iptr_)
110 {
111#ifdef NO_ETISS
112 std::cout << "etiss::fault::InjectorAddress::getInjector(): Injector not found for path_=" << path_
113 << std::endl;
114#else
115 etiss::log(etiss::ERROR, std::string("etiss::fault::InjectorAddress::getInjector():") +
116 std::string(" Injector not found for path_= ") + path_);
117#endif
118 }
119 }
120 return iptr_;
121}
122
124{
125 return (bool)iptr_;
126}
127
128#if ETISS_FAULT_XML
129namespace xml
130{
131
132template <>
133bool parse<etiss::fault::InjectorAddress>(pugi::xml_node node, etiss::fault::InjectorAddress &dst, Diagnostics &diag)
134{
135 etiss::log(etiss::VERBOSE, std::string("Called etiss::fault::xml::parse<etiss::fault::") +
136 "InjectorAddress>(node, InjectorAddress&=" + dst.toString() + ", Diagnostics&)");
137 std::string val;
138 if (!parse<std::string>(node, val, diag))
139 {
140 return false;
141 }
142 setCoreName(val);
143 dst = InjectorAddress(val);
144 return true;
145}
146template <>
147bool write<etiss::fault::InjectorAddress>(pugi::xml_node node, const etiss::fault::InjectorAddress &src,
148 Diagnostics &diag)
149{
150 etiss::log(etiss::VERBOSE, std::string("Called etiss::fault::xml::write<etiss::fault::") +
151 "InjectorAddress>(node, InjectorAddress&=" + src.toString() + ", Diagnostics&)");
152 return write<std::string>(node, src.getInjectorPath(), diag);
153}
154
155template <>
156bool parse<etiss::fault::InjectorAddress *>(pugi::xml_node node, etiss::fault::InjectorAddress *&dst, Diagnostics &diag)
157{
158 etiss::log(etiss::VERBOSE, std::string("Called etiss::fault::xml::parse<etiss::fault::") +
159 "InjectorAddress*>(node, InjectorAddress*&=" + dst->toString() + ", Diagnostics&)");
160 InjectorAddress val;
161 if (!parse<etiss::fault::InjectorAddress>(node, val, diag))
162 {
163 dst = 0;
164 return false;
165 }
166 dst = new InjectorAddress(val);
167 return true;
168}
169template <>
170bool write<const etiss::fault::InjectorAddress *>(pugi::xml_node node, const etiss::fault::InjectorAddress *const &src,
171 Diagnostics &diag)
172{
173 etiss::log(etiss::VERBOSE, std::string("Called etiss::fault::xml::write<etiss::fault::") +
174 "InjectorAddress*>(node, InjectorAddress*&=" + src->toString() + ", Diagnostics&)");
175 if (!src)
176 return false;
177 return write(node, *src, diag);
178}
179
180} // namespace xml
181#endif
182
183} // namespace fault
184
185} // namespace etiss
contains a simple class that represents and resolves injector addresses as used by triggers (
contains the fault injector interface class.
InjectorAddress & operator=(const InjectorAddress &)
const std::string & getInjectorPath() const
bool isResolved() const
> Calls Injector::get (implemented in VirtualStruct) to resolve path_ and get iptr_
const Injector_ptr & getInjector() const
Injector_ptr iptr_
Contains the pointer to the Injector.
std::string path_
Contains the VirtualStruct as string where the Injector refers to.
static ptr get(const std::string &injectorPath)
void setCoreName(std::string &str)
Definition XML.cpp:62
std::shared_ptr< Injector > Injector_ptr
Definition Defs.h:86
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition Benchmark.h:53
@ VERBOSE
Definition Misc.h:130
@ ERROR
Definition Misc.h:127
void log(Verbosity level, std::string msg)
write log message at the given level.
Definition Misc.cpp:125