gem5 v24.0.0.0
Loading...
Searching...
No Matches
sc_process_handle.hh
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#ifndef __SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__
29#define __SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__
30
31#include <exception>
32#include <vector>
33
35#include "messages.hh"
36#include "sc_object.hh"
37
38namespace sc_gem5
39{
40
41class Process;
42
44{
45 virtual void call() = 0;
47};
48
49template <typename T>
51{
52 typedef void (T::*TFunc)();
53 T *t;
55
57
58 void call() override { (t->*func)(); }
59};
60
62{
63 virtual void throw_it() = 0;
64};
65
66template <typename T>
68{
69 const T &t;
70 ExceptionWrapper(const T &t) : t(t) {}
71
72 void throw_it() { throw t; }
73};
74
75void throw_it_wrapper(Process *p, ExceptionWrapperBase &exc, bool inc_kids);
76
77} // namespace sc_gem5
78
79namespace sc_core
80{
81
82class sc_event;
83
91
93{
95 SC_INCLUDE_DESCENDANTS
96};
97
98class sc_unwind_exception : public std::exception
99{
100 public:
101 virtual const char *what() const throw();
102 virtual bool is_reset() const;
103
104 // Nonstandard.
105 // These should be protected, but I think this is to enable catch by
106 // value.
107 public:
109 virtual ~sc_unwind_exception() throw();
110
111 protected:
114};
115
116// Deprecated
117// An incomplete version of sc_process_b to satisfy the tests.
119{
120 public:
121 sc_process_b(const char *name) : sc_object(name), file(nullptr), lineno(0)
122 {}
123 sc_process_b() : sc_object(), file(nullptr), lineno(0) {}
124
125 const char *file;
127};
128
129// Nonstandard
130void sc_set_location(const char *file, int lineno);
131
132// Deprecated
134static inline sc_process_b *
139
140// Deprecated/nonstandard
148
150{
151 private:
153
154 public:
157 explicit sc_process_handle(sc_object *);
159
160 // These non-standard operators provide access to the data structure which
161 // actually tracks the process within gem5. By making them operators, we
162 // can minimize the symbols added to the class namespace.
163 operator ::sc_gem5::Process * () const { return _gem5_process; }
166 {
167 _gem5_process = p;
168 return *this;
169 }
170
171 bool valid() const;
172
174 bool operator == (const sc_process_handle &) const;
175 bool operator != (const sc_process_handle &) const;
176 bool operator < (const sc_process_handle &) const;
177 void swap(sc_process_handle &);
178
179 const char *name() const;
185 bool dynamic() const;
186 bool terminated() const;
187 const sc_event &terminated_event() const;
188
189 void suspend(sc_descendent_inclusion_info include_descendants=
190 SC_NO_DESCENDANTS);
191 void resume(sc_descendent_inclusion_info include_descendants=
192 SC_NO_DESCENDANTS);
193 void disable(sc_descendent_inclusion_info include_descendants=
194 SC_NO_DESCENDANTS);
195 void enable(sc_descendent_inclusion_info include_descendants=
196 SC_NO_DESCENDANTS);
197 void kill(sc_descendent_inclusion_info include_descendants=
198 SC_NO_DESCENDANTS);
199 void reset(sc_descendent_inclusion_info include_descendants=
200 SC_NO_DESCENDANTS);
201 bool is_unwinding();
202 const sc_event &reset_event() const;
203
204 void sync_reset_on(sc_descendent_inclusion_info include_descendants=
205 SC_NO_DESCENDANTS);
206 void sync_reset_off(sc_descendent_inclusion_info include_descendants=
207 SC_NO_DESCENDANTS);
208
209 template <typename T>
210 void
211 throw_it(const T &user_defined_exception,
212 sc_descendent_inclusion_info include_descendants=
213 SC_NO_DESCENDANTS)
214 {
215 if (!_gem5_process) {
216 SC_REPORT_WARNING(SC_ID_EMPTY_PROCESS_HANDLE_, "throw_it()");
217 return;
218 }
219 ::sc_gem5::ExceptionWrapper<T> exc(user_defined_exception);
221 include_descendants == SC_INCLUDE_DESCENDANTS);
222 }
223};
224
225sc_process_handle sc_get_current_process_handle();
226bool sc_is_unwinding();
227
228// Nonstandard
229// See Accellera's kernel/sim_context.cpp for an explanation of what this is
230// supposed to do. It essentially selects what happens during certain
231// undefined situations.
233
234} // namespace sc_core
235
236#endif //__SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__
const char * name() const
Definition sc_object.cc:44
sc_process_b(const char *name)
bool operator<(const sc_process_handle &) const
sc_object * get_parent_object() const
void sync_reset_on(sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
const std::vector< sc_event * > & get_child_events() const
void throw_it(const T &user_defined_exception, sc_descendent_inclusion_info include_descendants=SC_NO_DESCENDANTS)
const sc_event & terminated_event() const
::sc_gem5::Process * _gem5_process
bool operator==(const sc_process_handle &) const
sc_process_handle & operator=(::sc_gem5::Process *p)
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 const char * what() const
STL vector class.
Definition stl.hh:37
static sc_process_b * sc_get_current_process_b()
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()
const sc_curr_proc_info * sc_curr_proc_handle
bool sc_is_unwinding()
bool sc_allow_process_control_corners
void throw_it_wrapper(Process *p, ExceptionWrapperBase &exc, bool inc_kids)
Definition process.cc:419
#define SC_REPORT_WARNING(msg_type, msg)

Generated on Tue Jun 18 2024 16:24:06 for gem5 by doxygen 1.11.0