gem5  v22.1.0.0
amba_from_tlm_bridge.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2019 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 
29 
30 #include "params/AmbaFromTlmBridge64.hh"
31 #include "pv_userpayload_extension.h"
33 
34 namespace gem5
35 {
36 
37 GEM5_DEPRECATED_NAMESPACE(FastModel, fastmodel);
38 namespace fastmodel
39 {
40 
42  amba_pv::amba_pv_from_tlm_bridge<64>(name),
43  targetProxy("target_proxy"),
44  initiatorProxy("initiator_proxy"),
45  tlmWrapper(targetProxy, std::string(name) + ".tlm", -1),
46  ambaWrapper(amba_pv_m, std::string(name) + ".amba", -1)
47 {
48  targetProxy.register_b_transport(this, &AmbaFromTlmBridge64::bTransport);
49  targetProxy.register_get_direct_mem_ptr(
51  targetProxy.register_transport_dbg(this, &AmbaFromTlmBridge64::transportDbg);
52  initiatorProxy.register_invalidate_direct_mem_ptr(
54  initiatorProxy(tlm_s);
55 }
56 
57 Port &
58 AmbaFromTlmBridge64::gem5_getPort(const std::string &if_name, int idx)
59 {
60  if (if_name == "tlm") {
61  return tlmWrapper;
62  } else if (if_name == "amba") {
63  return ambaWrapper;
64  } else {
65  return amba_pv::amba_pv_from_tlm_bridge<64>::gem5_getPort(
66  if_name, idx);
67  }
68 }
69 
70 void
71 AmbaFromTlmBridge64::bTransport(amba_pv::amba_pv_transaction &trans,
73 {
74  syncControlExtension(trans);
75  return initiatorProxy->b_transport(trans, t);
76 }
77 
78 bool
79 AmbaFromTlmBridge64::getDirectMemPtr(amba_pv::amba_pv_transaction &trans,
80  tlm::tlm_dmi &dmi_data)
81 {
82  return initiatorProxy->get_direct_mem_ptr(trans, dmi_data);
83 }
84 
85 unsigned int
86 AmbaFromTlmBridge64::transportDbg(amba_pv::amba_pv_transaction &trans)
87 {
88  syncControlExtension(trans);
89  return initiatorProxy->transport_dbg(trans);
90 }
91 
92 void
94  sc_dt::uint64 end_range)
95 {
96  targetProxy->invalidate_direct_mem_ptr(start_range, end_range);
97 }
98 
99 void
100 AmbaFromTlmBridge64::syncControlExtension(amba_pv::amba_pv_transaction &trans)
101 {
102  Gem5SystemC::ControlExtension *control_ex = nullptr;
103  trans.get_extension(control_ex);
104  if (!control_ex) {
105  return;
106  }
107 
108  amba_pv::amba_pv_extension *amba_ex = nullptr;
109  trans.get_extension(amba_ex);
110  if (!amba_ex) {
111  return;
112  }
113 
114  amba_ex->set_privileged(control_ex->isPrivileged());
115  amba_ex->set_non_secure(!control_ex->isSecure());
116  amba_ex->set_instruction(control_ex->isInstruction());
117 }
118 
119 } // namespace fastmodel
120 
122 AmbaFromTlmBridge64Params::create() const
123 {
124  return new fastmodel::AmbaFromTlmBridge64(name.c_str());
125 }
126 
127 } // namespace gem5
bool isInstruction() const
Definition: sc_ext.cc:243
Ports are used to interface objects to each other.
Definition: port.hh:62
AmbaFromTlmBridge64(const sc_core::sc_module_name &name)
void bTransport(amba_pv::amba_pv_transaction &trans, sc_core::sc_time &t)
tlm_utils::simple_initiator_socket< AmbaFromTlmBridge64, 64, tlm::tlm_base_protocol_types > initiatorProxy
void syncControlExtension(amba_pv::amba_pv_transaction &trans)
void invalidateDirectMemPtr(sc_dt::uint64 start_range, sc_dt::uint64 end_range)
tlm_utils::simple_target_socket< AmbaFromTlmBridge64, 64, tlm::tlm_base_protocol_types > targetProxy
gem5::Port & gem5_getPort(const std::string &if_name, int idx=-1) override
bool getDirectMemPtr(amba_pv::amba_pv_transaction &trans, tlm::tlm_dmi &dmi_data)
sc_gem5::TlmTargetWrapper< 64 > tlmWrapper
unsigned int transportDbg(amba_pv::amba_pv_transaction &trans)
Bitfield< 51 > t
Definition: pagetable.hh:56
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
uint64_t uint64
Definition: sc_nbdefs.hh:172
Overload hash function for BasicBlockRange type.
Definition: misc.hh:2826
const std::string & name()
Definition: trace.cc:49

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