gem5 v24.0.0.0
Loading...
Searching...
No Matches
instance_specific_extensions_int.h
Go to the documentation of this file.
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19#ifndef __SYSTEMC_EXT_TLM_UTILS_INSTANCE_SPECIFIC_EXTENSIONS_INT_H__
20#define __SYSTEMC_EXT_TLM_UTILS_INSTANCE_SPECIFIC_EXTENSIONS_INT_H__
21
22#include <typeinfo>
23#include <vector>
24
26
27namespace tlm_utils
28{
29
30class ispex_base;
31class instance_specific_extension_accessor;
32class instance_specific_extension_container;
33class instance_specific_extension_carrier;
34class instance_specific_extension_container_pool;
35
36} // namespace tlm_utils
37
38namespace tlm
39{
40
41extern template class tlm_array<tlm_utils::ispex_base *>;
42
43} // namespace tlm
44
45namespace tlm_utils
46{
47
48// The private extension base. Similar to normal extension base, but without
49// clone and free.
51{
52 friend class tlm::tlm_array<ispex_base*>;
53 void free() {} // Needed for explicit tlm_array instantiation.
54
55 public:
56 virtual ~ispex_base() {}
57
58 protected:
59 static unsigned int register_private_extension(const std::type_info &);
60};
61
62// This thing is basically a snippet of the generic_payload.
63// It contains all the extension specific code (the extension API so to speak)
64// the differences are:
65// - it calls back to its owner whenever a real (==non-NULL) extension gets
66// set for the first time.
67// - it calls back to its owner whenever a living (==non-NULL) extension gets
68// cleared.
70{
71 public:
73
74 explicit
76 m_container(container)
77 {}
78
79 template <typename T>
80 T *
82 {
83 return static_cast<T *>(set_extension(T::priv_id, ext));
84 }
85
86 // Non-templatized version with manual index:
87 ispex_base *set_extension(unsigned int index, ispex_base *ext);
88
89 // Check for an extension, ext will be nullptr if not present.
90 template <typename T>
91 void get_extension(T *& ext) const
92 {
93 ext = static_cast<T *>(get_extension(T::priv_id));
94 }
95 // Non-templatized version:
96 ispex_base *get_extension(unsigned int index) const;
97
98 // Clear extension, the argument is needed to find the right index:
99 template <typename T>
100 void clear_extension(const T *)
101 {
102 clear_extension(T::priv_id);
103 }
104
105 // Non-templatized version with manual index
106 void clear_extension(unsigned int index);
107
108 // Make sure the extension array is large enough. Can be called once by
109 // an initiator module (before issuing the first transaction) to make
110 // sure that the extension array is of correct size. This is only needed
111 // if the initiator cannot guarantee that the generic payload object is
112 // allocated after C++ static construction time.
113 void resize_extensions();
114
115 private:
118};
119
120// This thing contains the vector of extensions per accessor
121// which can be really large so this one should be pool allocated.
122// Therefore it keeps a use_count of itself to automatically free itself.
123// - to this end it provides callbacks to the extensions per accessor
124// to increment and decrement the use_count.
157
158// ----------------------------------------------------------------------------
159
160// This class 'hides' all the instance specific extension stuff from the user.
161// They instantiates one of those (e.g. instance_specific_extension_accessor
162// extAcc;) and can then access the private extensions.
163// extAcc(txn).extensionAPIFnCall()
164// where extensionAPIFnCall is set_extension, get_extension,
165// clear_extension,...
167{
168 public:
170
171 // Implementation in instance_specific_extensions.h
172 template <typename T>
173 inline instance_specific_extensions_per_accessor &operator () (T &txn);
174
175 protected:
176 template<typename T>
177 static void release_carrier(
179
180 unsigned int m_index;
181};
182
183} // namespace tlm_utils
184
185#endif /* __SYSTEMC_EXT_TLM_UTILS_INSTANCE_SPECIFIC_EXTENSIONS_INT_H__ */
STL vector class.
Definition stl.hh:37
std::vector< instance_specific_extensions_per_accessor * > m_ispex_per_accessor
void release_fn(instance_specific_extension_carrier *, void *)

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