63 #include "params/Gem5ToTlmBridge32.hh"
64 #include "params/Gem5ToTlmBridge64.hh"
65 #include "params/Gem5ToTlmBridge128.hh"
66 #include "params/Gem5ToTlmBridge256.hh"
67 #include "params/Gem5ToTlmBridge512.hh"
121 extraPacketToPayloadSteps.push_back(std::move(step));
134 auto *tlmSenderState =
139 if (tlmSenderState !=
nullptr) {
141 trans = &tlmSenderState->trans;
145 for (
auto &step : extraPacketToPayloadSteps) {
146 step(packet, *trans);
159 unsigned int size = packet->
getSize();
160 unsigned char *
data = packet->
getPtr<
unsigned char>();
169 }
else if (packet->
isRead()) {
171 }
else if (packet->
isWrite()) {
183 std::shared_ptr<AtomicOpFunctor>(
184 packet->
req->getAtomicOpFunctor()->clone()),
185 packet->
req->isAtomicReturn());
190 for (
auto &step : extraPacketToPayloadSteps) {
191 step(packet, *trans);
215 template <
unsigned int BITWIDTH>
225 blockingRequest =
nullptr;
228 if (needToSendRequestRetry) {
229 needToSendRequestRetry =
false;
230 bridgeResponsePort.sendRetryReq();
235 auto packet = extension.getPacket();
239 bool need_retry =
false;
245 if (packet->needsResponse()) {
248 if (packet->isResponse()) {
249 need_retry = !bridgeResponsePort.sendTimingResp(packet);
253 blockingResponse = &trans;
259 socket->nb_transport_fw(trans, fw_phase, delay);
267 template <
unsigned int BITWIDTH>
276 auto it = backdoorMap.contains(
r);
277 if (it != backdoorMap.end())
282 if (!socket->get_direct_mem_ptr(trans, dmi_data))
293 backdoorMap.insert(dmi_r, backdoor);
299 template <
unsigned int BITWIDTH>
304 "Should not see packets where cache is responding");
313 socket->b_transport(*trans, delay);
321 return delay.
value();
324 template <
unsigned int BITWIDTH>
330 "Should not see packets where cache is responding");
339 socket->b_transport(*trans, delay);
341 if (trans->is_dmi_allowed())
342 backdoor = getBackdoor(*trans);
346 backdoor = getBackdoor(*trans);
355 return delay.
value();
358 template <
unsigned int BITWIDTH>
364 "unimplemented func.: recvFunctionalSnoop");
368 template <
unsigned int BITWIDTH>
373 "Should not see packets where cache is responding");
381 if (blockingRequest) {
382 needToSendRequestRetry =
true;
430 status = socket->nb_transport_fw(*trans, phase, delay);
435 blockingRequest = trans;
440 blockingRequest = trans;
441 auto cb = [
this, trans, phase]() { pec(*trans, phase); };
454 template <
unsigned int BITWIDTH>
460 "unimplemented func.: recvTimingSnoopResp");
464 template <
unsigned int BITWIDTH>
468 panic(
"tryTiming(PacketPtr) isn't implemented.");
471 template <
unsigned int BITWIDTH>
479 blockingResponse =
nullptr;
483 bool need_retry = !bridgeResponsePort.sendTimingResp(packet);
489 socket->nb_transport_fw(*trans, phase, delay);
495 template <
unsigned int BITWIDTH>
503 unsigned int bytes = socket->transport_dbg(*trans);
504 if (bytes != trans->get_data_length()) {
506 "debug transport was not completed");
512 template <
unsigned int BITWIDTH>
517 auto cb = [
this, &trans, phase]() { pec(trans, phase); };
524 template <
unsigned int BITWIDTH>
532 auto it = backdoorMap.intersects(
r);
533 if (it == backdoorMap.end())
536 it->second->invalidate();
538 backdoorMap.erase(it);
542 template <
unsigned int BITWIDTH>
546 bridgeResponsePort(
std::string(
name()) +
".gem5", *this),
547 socket(
"tlm_socket"),
550 needToSendRequestRetry(false), blockingResponse(nullptr),
551 addrRanges(params.addr_ranges.begin(), params.addr_ranges.end())
555 template <
unsigned int BITWIDTH>
559 if (if_name ==
"gem5")
560 return bridgeResponsePort;
561 else if (if_name ==
"tlm")
567 template <
unsigned int BITWIDTH>
571 bridgeResponsePort.sendRangeChange();
574 socket.register_invalidate_direct_mem_ptr(
582 gem5::Gem5ToTlmBridge32Params::create()
const
589 gem5::Gem5ToTlmBridge64Params::create()
const
596 gem5::Gem5ToTlmBridge128Params::create()
const
603 gem5::Gem5ToTlmBridge256Params::create()
const
610 gem5::Gem5ToTlmBridge512Params::create()
const
static Gem5Extension & getExtension(const tlm::tlm_generic_payload *payload)
gem5::PacketPtr getPacket()
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
T * getPtr()
get a pointer to the data ptr.
bool needsResponse() const
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
T * findNextSenderState() const
Go through the sender state stack and return the first instance that is of type T (as determined by a...
RequestPtr req
A pointer to the original request.
bool cacheResponding() const
Ports are used to interface objects to each other.
@ NO_ACCESS
The request should not cause a memory access.
virtual void before_end_of_elaboration()
virtual gem5::Port & gem5_getPort(const std::string &if_name, int idx=-1)
static sc_time from_value(sc_dt::uint64)
sc_dt::uint64 value() const
void before_end_of_elaboration() override
void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, sc_dt::uint64 end_range)
tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
gem5::Gem5ToTlmBridgeBaseParams Params
gem5::Port & gem5_getPort(const std::string &if_name, int idx=-1) override
unsigned char * get_dmi_ptr() const
sc_dt::uint64 get_start_address() const
sc_dt::uint64 get_end_address() const
bool is_read_allowed() const
bool is_write_allowed() const
void set_data_ptr(unsigned char *data)
void set_address(const sc_dt::uint64 address)
void set_command(const tlm_command command)
sc_dt::uint64 get_address() const
T * set_auto_extension(T *ext)
tlm_response_status get_response_status() const
void set_data_length(const unsigned int length)
unsigned int get_data_length() const
void set_streaming_width(const unsigned int streaming_width)
static const Priority Default_Pri
Default is zero for historical reasons.
#define panic(...)
This implements a cprintf based panic() function.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Tick curTick()
The universal simulation clock.
uint64_t Tick
Tick count type.
const sc_time SC_ZERO_TIME
Gem5SystemC::MemoryManager mm
Instantiate a tlm memory manager that takes care about all the tlm transactions in the system.
void addPacketToPayloadConversionStep(PacketToPayloadConversionStep step)
Notify the Gem5ToTlm bridge that we need an extra step to properly convert a gem5 packet to tlm paylo...
tlm::tlm_generic_payload * packet2payload(PacketPtr packet)
Convert a gem5 packet to TLM payload by copying all the relevant information to new payload.
std::function< void(gem5::PacketPtr pkt, tlm::tlm_generic_payload &trans)> PacketToPayloadConversionStep
static EventBase::Priority getPriorityOfTlmPhase(const tlm::tlm_phase &phase)
Helper function to help set priority of phase change events of tlm transactions.
void setPacketResponse(PacketPtr pkt, tlm::tlm_generic_payload &trans)
Overload hash function for BasicBlockRange type.
@ TLM_COMMAND_ERROR_RESPONSE
#define SC_REPORT_FATAL(msg_type, msg)
const std::string & name()