63 #include "debug/TlmBridge.hh"
64 #include "params/TlmToGem5Bridge128.hh"
65 #include "params/TlmToGem5Bridge256.hh"
66 #include "params/TlmToGem5Bridge32.hh"
67 #include "params/TlmToGem5Bridge512.hh"
68 #include "params/TlmToGem5Bridge64.hh"
98 extraPayloadToPacketSteps.push_back(std::move(step));
117 if (extension !=
nullptr) {
122 for (
auto &step : extraPayloadToPacketSteps) {
125 return std::make_pair(pkt,
false);
141 req = std::make_shared<Request>(
143 0, 0, std::move(amo_op));
154 return std::make_pair(
nullptr,
false);
157 "received transaction with unsupported "
161 req = std::make_shared<Request>(
170 auto pkt =
new Packet(req, cmd);
174 for (
auto &step : extraPayloadToPacketSteps) {
178 return std::make_pair(pkt,
true);
193 template <
unsigned int BITWIDTH>
200 auto status = socket->nb_transport_bw(trans, phase, delay);
202 "Unexpected status after sending END_REQ");
205 template <
unsigned int BITWIDTH>
213 "Missing gem5 extension when sending BEGIN_RESP");
220 auto status = socket->nb_transport_bw(trans, phase, delay);
225 responseInProgress =
false;
228 responseInProgress =
true;
230 panic(
"Unexpected status after sending BEGIN_RESP");
234 template <
unsigned int BITWIDTH>
245 auto pkt = res.first;
250 bool needsResponse = pkt->needsResponse();
251 if (bmp.sendTimingReq(pkt)) {
253 if (!needsResponse) {
255 sendBeginResp(trans, delay);
260 pendingRequest = &trans;
265 template <
unsigned int BITWIDTH>
271 responseInProgress =
false;
273 if (needToSendRetry) {
275 needToSendRetry =
false;
279 template <
unsigned int BITWIDTH>
286 template <
unsigned int BITWIDTH>
290 socket->invalidate_direct_mem_ptr(
295 template <
unsigned int BITWIDTH>
302 handleBeginReq(trans);
305 handleEndResp(trans);
308 panic(
"unimplemented phase in callback");
312 template <
unsigned int BITWIDTH>
323 if (byteEnable != 0) {
334 peq.notify(trans, phase, delay);
338 template <
unsigned int BITWIDTH>
347 Tick ticks = bmp.sendAtomicBackdoor(pkt, backdoor);
352 panic_if(pkt->needsResponse() && !pkt->isResponse(),
353 "Packet sending failed!\n");
375 template <
unsigned int BITWIDTH>
380 if (pkt !=
nullptr) {
383 bmp.sendFunctional(pkt);
399 template <
unsigned int BITWIDTH>
410 bmp.sendAtomicBackdoor(pkt, backdoor);
426 if (requestedBackdoors.find(backdoor) == requestedBackdoors.end()) {
430 invalidateDmi(backdoor);
433 requestedBackdoors.emplace(backdoor);
449 return backdoor !=
nullptr;
452 template <
unsigned int BITWIDTH>
458 if (responseInProgress) {
460 needToSendRetry =
true;
476 auto *tlmSenderState =
480 auto &trans = tlmSenderState->trans;
483 trans.get_extension(extension);
486 delete tlmSenderState;
490 if (extension ==
nullptr)
493 sendBeginResp(trans, delay);
499 template <
unsigned int BITWIDTH>
509 bool needsResponse = pendingPacket->needsResponse();
510 if (bmp.sendTimingReq(pendingPacket)) {
511 waitForRetry =
false;
512 pendingPacket =
nullptr;
514 auto &trans = *pendingRequest;
516 if (!needsResponse) {
518 sendBeginResp(trans, delay);
522 pendingRequest =
nullptr;
526 template <
unsigned int BITWIDTH>
531 "received address range change but ignored it");
534 template <
unsigned int BITWIDTH>
538 if (if_name ==
"gem5")
540 else if (if_name ==
"tlm")
546 template <
unsigned int BITWIDTH>
550 waitForRetry(false), pendingRequest(nullptr), pendingPacket(nullptr),
551 needToSendRetry(false), responseInProgress(false),
552 bmp(
std::string(
name()) +
"master", *this), socket(
"tlm_socket"),
555 _id(params.
system->getGlobalRequestorId(
556 std::string(
"[systemc].") +
name()))
560 template <
unsigned int BITWIDTH>
572 if (
system->isTimingMode()) {
573 DPRINTF(TlmBridge,
"register non-blocking interface");
574 socket.register_nb_transport_fw(
576 }
else if (
system->isAtomicMode()) {
577 DPRINTF(TlmBridge,
"register blocking interface");
578 socket.register_b_transport(
580 socket.register_get_direct_mem_ptr(
583 panic(
"gem5 operates neither in Timing nor in Atomic mode");
586 socket.register_transport_dbg(
595 gem5::TlmToGem5Bridge32Params::create()
const
602 gem5::TlmToGem5Bridge64Params::create()
const
609 gem5::TlmToGem5Bridge128Params::create()
const
616 gem5::TlmToGem5Bridge256Params::create()
const
623 gem5::TlmToGem5Bridge512Params::create()
const
bool isReturnRequired() const
gem5::AtomicOpFunctor * getAtomicOpFunctor() const
gem5::PacketPtr getPacket()
const AddrRange & range() const
void addInvalidationCallback(CbFunction func)
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void setAddr(Addr _addr)
Update the address of this packet mid-transaction.
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
SenderState * popSenderState()
Pop the top of the state stack and return a pointer to it.
Ports are used to interface objects to each other.
@ ATOMIC_RETURN_OP
The request is an atomic that returns data.
@ ATOMIC_NO_RETURN_OP
The request is an atomic that does not return data.
@ 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)
void before_end_of_elaboration() override
gem5::TlmToGem5BridgeBaseParams Params
void set_granted_access(dmi_access_e a)
void set_dmi_ptr(unsigned char *p)
void set_start_address(sc_dt::uint64 addr)
void set_end_address(sc_dt::uint64 addr)
unsigned char * get_data_ptr() const
void set_dmi_allowed(bool dmi_allowed)
void set_response_status(const tlm_response_status response_status)
unsigned char * get_byte_enable_ptr() const
sc_dt::uint64 get_address() const
void get_extension(T *&ext) const
unsigned int get_streaming_width() const
unsigned int get_data_length() const
tlm_command get_command() const
Addr end() const
Get the end address of the range.
Addr start() const
Get the start address of the range.
std::unique_ptr< AtomicOpFunctor > AtomicOpFunctorPtr
virtual AtomicOpFunctor * clone()=0
#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...
ProbePointArg< PacketInfo > Packet
Packet probe point.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< Request > RequestPtr
const PortID InvalidPortID
uint64_t Tick
Tick count type.
const sc_time SC_ZERO_TIME
void addPayloadToPacketConversionStep(PayloadToPacketConversionStep step)
Notify the Tlm2Gem5 bridge that we need an extra step to properly convert a tlm payload to gem5 packe...
void setPayloadResponse(tlm::tlm_generic_payload &trans, PacketPtr pkt)
std::function< void(gem5::PacketPtr pkt, tlm::tlm_generic_payload &trans)> PayloadToPacketConversionStep
std::pair< PacketPtr, bool > payload2packet(RequestorID _id, tlm::tlm_generic_payload &trans)
Convert a TLM payload to gem5 packet by copying all the relevant information to new packet.
Overload hash function for BasicBlockRange type.
@ TLM_ADDRESS_ERROR_RESPONSE
@ TLM_BURST_ERROR_RESPONSE
@ TLM_BYTE_ENABLE_ERROR_RESPONSE
@ TLM_COMMAND_ERROR_RESPONSE
#define SC_REPORT_FATAL(msg_type, msg)
A virtual base opaque structure used to hold state associated with the packet (e.g....
const std::string & name()