gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Gabe Black
28  */
29 
30 #include "systemc/core/process.hh"
36 
37 namespace sc_core
38 {
39 
40 const char *
42 {
43  return _isReset ? "RESET" : "KILL";
44 }
45 
46 bool
48 {
49  return _isReset;
50 }
51 
55 {}
57 
58 
59 void
60 sc_set_location(const char *file, int lineno)
61 {
63  if (!current)
64  return;
65  current->file = file;
66  current->lineno = lineno;
67 }
68 
69 
72 {
74 }
75 
76 
77 sc_process_handle::sc_process_handle() : _gem5_process(nullptr) {}
78 
81 {
82  if (_gem5_process)
84 }
85 
87  _gem5_process(dynamic_cast<::sc_gem5::Process *>(obj))
88 {
89  if (_gem5_process)
91 }
92 
94 {
95  if (_gem5_process)
97 }
98 
99 
100 bool
102 {
103  return _gem5_process != nullptr;
104 }
105 
106 
109 {
110  if (_gem5_process)
112  _gem5_process = handle._gem5_process;
113  if (_gem5_process)
115  return *this;
116 }
117 
118 bool
120 {
121  return _gem5_process && handle._gem5_process &&
122  (_gem5_process == handle._gem5_process);
123 }
124 
125 bool
127 {
128  return !(handle == *this);
129 }
130 
131 bool
133 {
134  return _gem5_process < other._gem5_process;
135 }
136 
137 void
139 {
140  ::sc_gem5::Process *temp = handle._gem5_process;
141  handle._gem5_process = _gem5_process;
142  _gem5_process = temp;
143 }
144 
145 
146 const char *
148 {
149  return _gem5_process ? _gem5_process->name() : "";
150 }
151 
154 {
156 }
157 
160 {
161  static const std::vector<sc_object *> empty;
162  return _gem5_process ? _gem5_process->get_child_objects() : empty;
163 }
164 
167 {
168  static const std::vector<sc_event *> empty;
169  return _gem5_process ? _gem5_process->get_child_events() : empty;
170 }
171 
172 sc_object *
174 {
175  return _gem5_process ? _gem5_process->get_parent_object() : nullptr;
176 }
177 
178 sc_object *
180 {
181  return _gem5_process;
182 }
183 
184 bool
186 {
187  return _gem5_process ? _gem5_process->dynamic() : false;
188 }
189 
190 bool
192 {
193  return _gem5_process ? _gem5_process->terminated() : false;
194 }
195 
196 const sc_event &
198 {
199  if (!_gem5_process) {
200  SC_REPORT_WARNING(SC_ID_EMPTY_PROCESS_HANDLE_, "terminated_event()");
201  static sc_gem5::InternalScEvent non_event;
202  return non_event;
203  }
204  return _gem5_process->terminatedEvent();
205 }
206 
207 
208 void
210 {
211  if (!_gem5_process) {
213  return;
214  }
215  _gem5_process->suspend(include_descendants == SC_INCLUDE_DESCENDANTS);
216 }
217 
218 void
220 {
221  if (!_gem5_process) {
223  return;
224  }
225  _gem5_process->resume(include_descendants == SC_INCLUDE_DESCENDANTS);
226 }
227 
228 void
230 {
231  if (!_gem5_process) {
233  return;
234  }
235  _gem5_process->disable(include_descendants == SC_INCLUDE_DESCENDANTS);
236 }
237 
238 void
240 {
241  if (!_gem5_process) {
243  return;
244  }
245  _gem5_process->enable(include_descendants == SC_INCLUDE_DESCENDANTS);
246 }
247 
248 void
250 {
251  if (!_gem5_process) {
253  return;
254  }
255  _gem5_process->kill(include_descendants == SC_INCLUDE_DESCENDANTS);
256 }
257 
258 void
260 {
261  if (!_gem5_process) {
263  return;
264  }
265  _gem5_process->reset(include_descendants == SC_INCLUDE_DESCENDANTS);
266 }
267 
268 bool
270 {
271  if (!_gem5_process) {
273  return false;
274  }
275  return _gem5_process->isUnwinding();
276 }
277 
278 const sc_event &
280 {
281  if (!_gem5_process) {
283  static sc_gem5::InternalScEvent non_event;
284  return non_event;
285  }
286  return _gem5_process->resetEvent();
287 }
288 
289 
290 void
292  sc_descendent_inclusion_info include_descendants)
293 {
294  if (!_gem5_process) {
296  return;
297  }
298  _gem5_process->syncResetOn(include_descendants == SC_INCLUDE_DESCENDANTS);
299 }
300 
301 void
303  sc_descendent_inclusion_info include_descendants)
304 {
305  if (!_gem5_process) {
306  SC_REPORT_WARNING(SC_ID_EMPTY_PROCESS_HANDLE_, "sync_reset_off()");
307  return;
308  }
309  _gem5_process->syncResetOff(include_descendants == SC_INCLUDE_DESCENDANTS);
310 }
311 
312 
315 {
316  if (sc_is_running())
317  return sc_process_handle(::sc_gem5::scheduler.current());
318  else
320 }
321 
322 bool
324 {
326 }
327 
329 
330 } // namespace sc_core
virtual const std::vector< sc_event * > & get_child_events() const
Definition: sc_object.cc:76
bool sc_is_running()
Definition: sc_main.cc:144
sc_object * get_parent_object() const
bool sc_is_unwinding()
const sc_event & reset_event() const
void kill(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
virtual ::sc_core::sc_curr_proc_kind procKind() const =0
bool operator<(const sc_process_handle &) const
const char * name() const
Definition: sc_object.cc:46
void sync_reset_on(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
static Process * newest()
Definition: process.hh:125
#define SC_REPORT_WARNING(msg_type, msg)
STL vector class.
Definition: stl.hh:40
void enable(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
const std::vector< sc_object * > & get_child_objects() const
void enable(bool inc_kids)
Definition: process.cc:132
sc_descendent_inclusion_info
void kill(bool inc_kids)
Definition: process.cc:143
void reset(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
void syncResetOn(bool inc_kids)
Definition: process.cc:225
virtual const std::vector< sc_object * > & get_child_objects() const
Definition: sc_object.cc:70
Process * current()
Definition: scheduler.hh:172
void syncResetOff(bool inc_kids)
Definition: process.cc:234
sc_object * get_parent_object() const
Definition: sc_object.cc:82
void disable(bool inc_kids)
Definition: process.cc:114
void resume(bool inc_kids)
Definition: process.cc:100
sc_curr_proc_kind proc_kind() const
virtual bool is_reset() const
const sc_event & terminated_event() const
Scheduler scheduler
Definition: scheduler.cc:491
bool isUnwinding() const
Definition: process.hh:71
virtual const char * what() const
void suspend(bool inc_kids)
Definition: process.cc:79
const std::vector< sc_event * > & get_child_events() const
void suspend(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
void swap(sc_process_handle &)
::sc_core::sc_event & resetEvent()
Definition: process.hh:103
::sc_core::sc_event & terminatedEvent()
Definition: process.hh:104
sc_process_b * sc_get_curr_process_handle()
Bitfield< 9 > e
sc_object * get_process_object() const
void reset(bool inc_kids)
Definition: process.cc:171
void disable(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
bool terminated() const
Definition: process.hh:73
bool dynamic() const
Definition: process.hh:70
const char SC_ID_EMPTY_PROCESS_HANDLE_[]
Definition: messages.cc:156
sc_process_handle sc_get_current_process_handle()
bool sc_allow_process_control_corners
bool operator!=(const sc_process_handle &) const
sc_process_handle & operator=(::sc_gem5::Process *p)
void sync_reset_off(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
::sc_gem5::Process * _gem5_process
void resume(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
void sc_set_location(const char *file, int lineno)
bool operator==(const sc_process_handle &) const

Generated on Fri Feb 28 2020 16:27:03 for gem5 by doxygen 1.8.13