gem5  v22.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_object * get_parent_object() const
Definition: sc_object.cc:80
virtual const std::vector< sc_event * > & get_child_events() const
Definition: sc_object.cc:74
const char * name() const
Definition: sc_object.cc:44
virtual const std::vector< sc_object * > & get_child_objects() const
Definition: sc_object.cc:68
bool operator<(const sc_process_handle &) const
sc_object * get_parent_object() const
sc_process_handle & operator=(::sc_gem5::Process *p)
void sync_reset_on(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
const std::vector< sc_event * > & get_child_events() const
const sc_event & terminated_event() const
::sc_gem5::Process * _gem5_process
bool operator==(const sc_process_handle &) const
const sc_event & reset_event() const
void sync_reset_off(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
void suspend(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
void swap(sc_process_handle &)
bool operator!=(const sc_process_handle &) const
const std::vector< sc_object * > & get_child_objects() const
void reset(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
void disable(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
void resume(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
void enable(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
void kill(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
sc_curr_proc_kind proc_kind() const
sc_object * get_process_object() const
virtual bool is_reset() const
virtual const char * what() const
void kill(bool inc_kids)
Definition: process.cc:141
void suspend(bool inc_kids)
Definition: process.cc:77
virtual ::sc_core::sc_curr_proc_kind procKind() const =0
void resume(bool inc_kids)
Definition: process.cc:98
void disable(bool inc_kids)
Definition: process.cc:112
bool dynamic() const
Definition: process.hh:68
void syncResetOn(bool inc_kids)
Definition: process.cc:223
::sc_core::sc_event & resetEvent()
Definition: process.hh:101
::sc_core::sc_event & terminatedEvent()
Definition: process.hh:102
bool isUnwinding() const
Definition: process.hh:69
static Process * newest()
Definition: process.hh:123
bool terminated() const
Definition: process.hh:71
void reset(bool inc_kids)
Definition: process.cc:169
void incref()
Definition: process.hh:98
void decref()
Definition: process.hh:99
void syncResetOff(bool inc_kids)
Definition: process.cc:232
void enable(bool inc_kids)
Definition: process.cc:130
Process * current()
Definition: scheduler.hh:185
STL vector class.
Definition: stl.hh:37
Bitfield< 9 > e
Definition: misc_types.hh:65
const char SC_ID_EMPTY_PROCESS_HANDLE_[]
Definition: messages.cc:154
sc_process_b * sc_get_curr_process_handle()
void sc_set_location(const char *file, int lineno)
sc_process_handle sc_get_current_process_handle()
bool sc_is_running()
Definition: sc_main.cc:141
sc_descendent_inclusion_info
@ SC_INCLUDE_DESCENDANTS
bool sc_is_unwinding()
bool sc_allow_process_control_corners
Scheduler scheduler
Definition: scheduler.cc:494
#define SC_REPORT_WARNING(msg_type, msg)

Generated on Wed Dec 21 2022 10:22:40 for gem5 by doxygen 1.9.1