gem5  v20.1.0.0
sc_process_handle.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Google, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include "systemc/core/process.hh"
34 
35 namespace sc_core
36 {
37 
38 const char *
40 {
41  return _isReset ? "RESET" : "KILL";
42 }
43 
44 bool
46 {
47  return _isReset;
48 }
49 
52  _isReset(e._isReset)
53 {}
55 
56 
57 void
58 sc_set_location(const char *file, int lineno)
59 {
61  if (!current)
62  return;
63  current->file = file;
64  current->lineno = lineno;
65 }
66 
67 
68 sc_process_b *
70 {
72 }
73 
74 
75 sc_process_handle::sc_process_handle() : _gem5_process(nullptr) {}
76 
78  _gem5_process(handle._gem5_process)
79 {
80  if (_gem5_process)
82 }
83 
85  _gem5_process(dynamic_cast<::sc_gem5::Process *>(obj))
86 {
87  if (_gem5_process)
89 }
90 
92 {
93  if (_gem5_process)
95 }
96 
97 
98 bool
100 {
101  return _gem5_process != nullptr;
102 }
103 
104 
107 {
108  if (_gem5_process)
110  _gem5_process = handle._gem5_process;
111  if (_gem5_process)
113  return *this;
114 }
115 
116 bool
118 {
119  return _gem5_process && handle._gem5_process &&
120  (_gem5_process == handle._gem5_process);
121 }
122 
123 bool
125 {
126  return !(handle == *this);
127 }
128 
129 bool
131 {
132  return _gem5_process < other._gem5_process;
133 }
134 
135 void
137 {
138  ::sc_gem5::Process *temp = handle._gem5_process;
139  handle._gem5_process = _gem5_process;
140  _gem5_process = temp;
141 }
142 
143 
144 const char *
146 {
147  return _gem5_process ? _gem5_process->name() : "";
148 }
149 
152 {
154 }
155 
158 {
159  static const std::vector<sc_object *> empty;
160  return _gem5_process ? _gem5_process->get_child_objects() : empty;
161 }
162 
165 {
166  static const std::vector<sc_event *> empty;
167  return _gem5_process ? _gem5_process->get_child_events() : empty;
168 }
169 
170 sc_object *
172 {
173  return _gem5_process ? _gem5_process->get_parent_object() : nullptr;
174 }
175 
176 sc_object *
178 {
179  return _gem5_process;
180 }
181 
182 bool
184 {
185  return _gem5_process ? _gem5_process->dynamic() : false;
186 }
187 
188 bool
190 {
191  return _gem5_process ? _gem5_process->terminated() : false;
192 }
193 
194 const sc_event &
196 {
197  if (!_gem5_process) {
198  SC_REPORT_WARNING(SC_ID_EMPTY_PROCESS_HANDLE_, "terminated_event()");
199  static sc_gem5::InternalScEvent non_event;
200  return non_event;
201  }
202  return _gem5_process->terminatedEvent();
203 }
204 
205 
206 void
208 {
209  if (!_gem5_process) {
211  return;
212  }
213  _gem5_process->suspend(include_descendants == SC_INCLUDE_DESCENDANTS);
214 }
215 
216 void
218 {
219  if (!_gem5_process) {
221  return;
222  }
223  _gem5_process->resume(include_descendants == SC_INCLUDE_DESCENDANTS);
224 }
225 
226 void
228 {
229  if (!_gem5_process) {
231  return;
232  }
233  _gem5_process->disable(include_descendants == SC_INCLUDE_DESCENDANTS);
234 }
235 
236 void
238 {
239  if (!_gem5_process) {
241  return;
242  }
243  _gem5_process->enable(include_descendants == SC_INCLUDE_DESCENDANTS);
244 }
245 
246 void
248 {
249  if (!_gem5_process) {
251  return;
252  }
253  _gem5_process->kill(include_descendants == SC_INCLUDE_DESCENDANTS);
254 }
255 
256 void
258 {
259  if (!_gem5_process) {
261  return;
262  }
263  _gem5_process->reset(include_descendants == SC_INCLUDE_DESCENDANTS);
264 }
265 
266 bool
268 {
269  if (!_gem5_process) {
271  return false;
272  }
273  return _gem5_process->isUnwinding();
274 }
275 
276 const sc_event &
278 {
279  if (!_gem5_process) {
281  static sc_gem5::InternalScEvent non_event;
282  return non_event;
283  }
284  return _gem5_process->resetEvent();
285 }
286 
287 
288 void
290  sc_descendent_inclusion_info include_descendants)
291 {
292  if (!_gem5_process) {
294  return;
295  }
296  _gem5_process->syncResetOn(include_descendants == SC_INCLUDE_DESCENDANTS);
297 }
298 
299 void
301  sc_descendent_inclusion_info include_descendants)
302 {
303  if (!_gem5_process) {
304  SC_REPORT_WARNING(SC_ID_EMPTY_PROCESS_HANDLE_, "sync_reset_off()");
305  return;
306  }
307  _gem5_process->syncResetOff(include_descendants == SC_INCLUDE_DESCENDANTS);
308 }
309 
310 
313 {
314  if (sc_is_running())
315  return sc_process_handle(::sc_gem5::scheduler.current());
316  else
318 }
319 
320 bool
322 {
324 }
325 
327 
328 } // namespace sc_core
sc_core::sc_process_handle::operator=
sc_process_handle & operator=(::sc_gem5::Process *p)
Definition: sc_process_handle.hh:165
sc_core::sc_process_handle::sc_process_handle
sc_process_handle()
Definition: sc_process_handle.cc:75
sc_core::sc_process_handle::is_unwinding
bool is_unwinding()
Definition: sc_process_handle.cc:267
sc_core::sc_process_handle::sync_reset_on
void sync_reset_on(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
Definition: sc_process_handle.cc:289
sc_core::sc_object::get_child_objects
virtual const std::vector< sc_object * > & get_child_objects() const
Definition: sc_object.cc:68
Process
Definition: process.hh:65
sc_core::sc_unwind_exception::~sc_unwind_exception
virtual ~sc_unwind_exception()
Definition: sc_process_handle.cc:54
sc_gem5::Process::terminated
bool terminated() const
Definition: process.hh:71
sc_gem5::Process::resetEvent
::sc_core::sc_event & resetEvent()
Definition: process.hh:101
sc_core::sc_process_handle::swap
void swap(sc_process_handle &)
Definition: sc_process_handle.cc:136
sc_core
Definition: messages.cc:31
sc_core::sc_unwind_exception::_isReset
bool _isReset
Definition: sc_process_handle.hh:112
sc_core::sc_process_handle::kill
void kill(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
Definition: sc_process_handle.cc:247
std::vector
STL vector class.
Definition: stl.hh:37
sc_core::sc_process_handle::get_child_objects
const std::vector< sc_object * > & get_child_objects() const
Definition: sc_process_handle.cc:157
sc_gem5::Process::reset
void reset(bool inc_kids)
Definition: process.cc:169
sc_gem5::Process::incref
void incref()
Definition: process.hh:98
sc_core::sc_process_handle::dynamic
bool dynamic() const
Definition: sc_process_handle.cc:183
sc_core::sc_process_handle::suspend
void suspend(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
Definition: sc_process_handle.cc:207
sc_core::SC_NO_PROC_
@ SC_NO_PROC_
Definition: sc_process_handle.hh:86
sc_core::sc_unwind_exception::sc_unwind_exception
sc_unwind_exception()
Definition: sc_process_handle.cc:50
sc_core::sc_process_handle::operator==
bool operator==(const sc_process_handle &) const
Definition: sc_process_handle.cc:117
sc_gem5::Process::enable
void enable(bool inc_kids)
Definition: process.cc:130
sc_core::sc_process_b::lineno
int lineno
Definition: sc_process_handle.hh:126
sc_core::sc_process_handle::reset
void reset(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
Definition: sc_process_handle.cc:257
sc_core::sc_process_handle::get_parent_object
sc_object * get_parent_object() const
Definition: sc_process_handle.cc:171
sc_core::sc_process_handle::operator!=
bool operator!=(const sc_process_handle &) const
Definition: sc_process_handle.cc:124
sc_core::sc_process_handle::reset_event
const sc_event & reset_event() const
Definition: sc_process_handle.cc:277
sc_gem5::Process::kill
void kill(bool inc_kids)
Definition: process.cc:141
sc_core::sc_process_handle::sync_reset_off
void sync_reset_off(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
Definition: sc_process_handle.cc:300
sc_core::sc_set_location
void sc_set_location(const char *file, int lineno)
Definition: sc_process_handle.cc:58
sc_gem5::InternalScEvent
Definition: sc_event.hh:254
sc_core::sc_process_b
Definition: sc_process_handle.hh:118
sc_core::sc_process_handle::disable
void disable(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
Definition: sc_process_handle.cc:227
sc_core::sc_event
Definition: sc_event.hh:169
sc_core::sc_unwind_exception
Definition: sc_process_handle.hh:98
sc_main.hh
sc_core::sc_unwind_exception::what
virtual const char * what() const
Definition: sc_process_handle.cc:39
sc_core::sc_process_handle::operator<
bool operator<(const sc_process_handle &) const
Definition: sc_process_handle.cc:130
sc_core::sc_process_handle::get_child_events
const std::vector< sc_event * > & get_child_events() const
Definition: sc_process_handle.cc:164
sc_core::sc_object::get_child_events
virtual const std::vector< sc_event * > & get_child_events() const
Definition: sc_object.cc:74
messages.hh
sc_gem5::Process::suspend
void suspend(bool inc_kids)
Definition: process.cc:77
sc_gem5::Process::syncResetOff
void syncResetOff(bool inc_kids)
Definition: process.cc:232
sc_core::sc_descendent_inclusion_info
sc_descendent_inclusion_info
Definition: sc_process_handle.hh:92
sc_core::sc_process_handle::get_process_object
sc_object * get_process_object() const
Definition: sc_process_handle.cc:177
sc_gem5::Process::newest
static Process * newest()
Definition: process.hh:123
sc_gem5::Process
Definition: process.hh:62
sc_core::sc_object
Definition: sc_object.hh:50
process.hh
sc_core::sc_process_handle::resume
void resume(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
Definition: sc_process_handle.cc:217
sc_core::sc_process_handle::proc_kind
sc_curr_proc_kind proc_kind() const
Definition: sc_process_handle.cc:151
sc_core::sc_process_handle::enable
void enable(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
Definition: sc_process_handle.cc:237
ArmISA::e
Bitfield< 9 > e
Definition: miscregs_types.hh:61
sc_core::SC_INCLUDE_DESCENDANTS
@ SC_INCLUDE_DESCENDANTS
Definition: sc_process_handle.hh:95
sc_gem5::Process::dynamic
bool dynamic() const
Definition: process.hh:68
SC_REPORT_WARNING
#define SC_REPORT_WARNING(msg_type, msg)
Definition: sc_report_handler.hh:123
sc_core::sc_process_handle::~sc_process_handle
~sc_process_handle()
Definition: sc_process_handle.cc:91
sc_gem5::Process::syncResetOn
void syncResetOn(bool inc_kids)
Definition: process.cc:223
sc_report_handler.hh
sc_core::sc_process_handle::terminated
bool terminated() const
Definition: sc_process_handle.cc:189
sc_core::sc_get_curr_process_handle
sc_process_b * sc_get_curr_process_handle()
Definition: sc_process_handle.cc:69
sc_process_handle.hh
sc_gem5::Scheduler::current
Process * current()
Definition: scheduler.hh:170
sc_core::sc_is_unwinding
bool sc_is_unwinding()
Definition: sc_process_handle.cc:321
sc_core::sc_process_b::file
const char * file
Definition: sc_process_handle.hh:125
sc_core::sc_process_handle
Definition: sc_process_handle.hh:149
sc_core::sc_process_handle::valid
bool valid() const
Definition: sc_process_handle.cc:99
sc_core::sc_object::name
const char * name() const
Definition: sc_object.cc:44
sc_gem5::Process::decref
void decref()
Definition: process.hh:99
sc_gem5::Process::isUnwinding
bool isUnwinding() const
Definition: process.hh:69
sc_gem5::Process::disable
void disable(bool inc_kids)
Definition: process.cc:112
sc_gem5::Process::terminatedEvent
::sc_core::sc_event & terminatedEvent()
Definition: process.hh:102
sc_gem5::Process::procKind
virtual ::sc_core::sc_curr_proc_kind procKind() const =0
sc_gem5
Definition: sc_clock.cc:42
sc_core::sc_allow_process_control_corners
bool sc_allow_process_control_corners
Definition: sc_process_handle.cc:326
sc_core::sc_process_handle::terminated_event
const sc_event & terminated_event() const
Definition: sc_process_handle.cc:195
sc_core::SC_ID_EMPTY_PROCESS_HANDLE_
const char SC_ID_EMPTY_PROCESS_HANDLE_[]
Definition: messages.cc:154
sc_core::sc_unwind_exception::is_reset
virtual bool is_reset() const
Definition: sc_process_handle.cc:45
sc_gem5::scheduler
Scheduler scheduler
Definition: scheduler.cc:489
sc_core::sc_process_handle::name
const char * name() const
Definition: sc_process_handle.cc:145
sc_core::sc_get_current_process_handle
sc_process_handle sc_get_current_process_handle()
Definition: sc_process_handle.cc:312
scheduler.hh
sc_gem5::Process::resume
void resume(bool inc_kids)
Definition: process.cc:98
sc_core::sc_object::get_parent_object
sc_object * get_parent_object() const
Definition: sc_object.cc:80
sc_core::sc_curr_proc_kind
sc_curr_proc_kind
Definition: sc_process_handle.hh:84
sc_core::sc_is_running
bool sc_is_running()
Definition: sc_main.cc:142
sc_core::sc_process_handle::_gem5_process
::sc_gem5::Process * _gem5_process
Definition: sc_process_handle.hh:152

Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17