66 #include "params/Gem5ToTlmBridge32.hh" 67 #include "params/Gem5ToTlmBridge64.hh" 96 unsigned int size = packet->
getSize();
97 unsigned char *
data = packet->
getPtr<
unsigned char>();
106 }
else if (packet->
isRead()) {
108 }
else if (packet->
isWrite()) {
121 template <
unsigned int BITWIDTH>
131 blockingRequest =
nullptr;
134 if (needToSendRequestRetry) {
135 needToSendRequestRetry =
false;
141 auto packet = extension.getPacket();
145 bool need_retry =
false;
153 if (extension.isPipeThrough()) {
154 if (packet->isResponse()) {
155 need_retry = !
bsp.sendTimingResp(packet);
157 }
else if (packet->needsResponse()) {
158 packet->makeResponse();
159 need_retry = !
bsp.sendTimingResp(packet);
163 blockingResponse = &trans;
169 socket->nb_transport_fw(trans, fw_phase, delay);
177 template <
unsigned int BITWIDTH>
186 auto it = backdoorMap.contains(r);
187 if (it != backdoorMap.end())
192 if (!socket->get_direct_mem_ptr(trans, dmi_data))
197 AddrRange dmi_r(dmi_data.get_start_address(), dmi_data.get_end_address());
200 backdoor->
readable(dmi_data.is_read_allowed());
201 backdoor->writeable(dmi_data.is_write_allowed());
203 backdoorMap.insert(dmi_r, backdoor);
209 template <
unsigned int BITWIDTH>
214 "Should not see packets where cache is responding");
223 socket->b_transport(*trans, delay);
231 return delay.
value();
234 template <
unsigned int BITWIDTH>
240 "Should not see packets where cache is responding");
249 socket->b_transport(*trans, delay);
251 if (trans->is_dmi_allowed())
252 backdoor = getBackdoor(*trans);
256 backdoor = getBackdoor(*trans);
264 return delay.value();
267 template <
unsigned int BITWIDTH>
273 "unimplemented func.: recvFunctionalSnoop");
277 template <
unsigned int BITWIDTH>
282 "Should not see packets where cache is responding");
290 if (blockingRequest) {
291 needToSendRequestRetry =
true;
339 status = socket->nb_transport_fw(*trans, phase, delay);
344 blockingRequest = trans;
348 auto cb = [
this, trans, phase]() { pec(*trans, phase); };
360 template <
unsigned int BITWIDTH>
366 "unimplemented func.: recvTimingSnoopResp");
370 template <
unsigned int BITWIDTH>
374 panic(
"tryTiming(PacketPtr) isn't implemented.");
377 template <
unsigned int BITWIDTH>
385 blockingResponse =
nullptr;
389 bool need_retry = !
bsp.sendTimingResp(packet);
395 socket->nb_transport_fw(*trans, phase, delay);
401 template <
unsigned int BITWIDTH>
409 unsigned int bytes = socket->transport_dbg(*trans);
410 if (bytes != trans->get_data_length()) {
412 "debug transport was not completed");
418 template <
unsigned int BITWIDTH>
423 auto cb = [
this, &trans, phase]() { pec(trans, phase); };
429 template <
unsigned int BITWIDTH>
437 auto it = backdoorMap.intersects(r);
438 if (it == backdoorMap.end())
441 it->second->invalidate();
443 backdoorMap.erase(it);
447 template <
unsigned int BITWIDTH>
451 socket(
"tlm_socket"),
454 needToSendRequestRetry(false), blockingResponse(nullptr),
455 addrRanges(params->addr_ranges.begin(), params->addr_ranges.end())
459 template <
unsigned int BITWIDTH>
463 if (if_name ==
"gem5")
465 else if (if_name ==
"tlm")
471 template <
unsigned int BITWIDTH>
478 socket.register_invalidate_direct_mem_ptr(
486 Gem5ToTlmBridge32Params::create()
493 Gem5ToTlmBridge64Params::create()
#define panic(...)
This implements a cprintf based panic() function.
static Gem5Extension & getExtension(const tlm::tlm_generic_payload *payload)
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor)
void set_streaming_width(const unsigned int streaming_width)
void sendRangeChange() const
Called by the owner to send a range change.
tlm_utils::simple_initiator_socket< Gem5ToTlmBridge< BITWIDTH >, BITWIDTH > socket
const std::string & name()
const PortID InvalidPortID
Gem5ToTlmBridgeBaseParams Params
MemBackdoorPtr getBackdoor(tlm::tlm_generic_payload &trans)
bool recvTimingReq(PacketPtr packet)
bool cacheResponding() const
tlm::tlm_generic_payload * packet2payload(PacketPtr packet)
Convert a gem5 packet to a TLM payload by copying all the relevant information to new tlm payload...
void recvFunctional(PacketPtr packet)
const char * name() const
Overload hash function for BasicBlockRange type.
sc_dt::uint64 get_address() const
T * getPtr()
get a pointer to the data ptr.
bool tryTiming(PacketPtr packet)
void before_end_of_elaboration() override
void pec(tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase)
void set_address(const sc_dt::uint64 address)
RequestPtr req
A pointer to the original request.
static sc_time from_value(sc_dt::uint64)
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
bool recvTimingSnoopResp(PacketPtr packet)
void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, sc_dt::uint64 end_range)
Tick curTick()
The current simulated tick.
sc_dt::uint64 value() const
bool needsResponse() const
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
uint64_t Tick
Tick count type.
unsigned int get_data_length() const
void set_data_ptr(unsigned char *data)
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
Gem5ToTlmBridge(Params *p, const sc_core::sc_module_name &mn)
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
The request should not cause a memory access.
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
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...
virtual ::Port & gem5_getPort(const std::string &if_name, int idx=-1)
::Port & gem5_getPort(const std::string &if_name, int idx=-1) override
void set_command(const tlm_command command)
sc_gem5::TlmInitiatorWrapper< BITWIDTH > wrapper
T * set_auto_extension(T *ext)
#define SC_REPORT_FATAL(msg_type, msg)
void set_data_length(const unsigned int length)
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
void recvFunctionalSnoop(PacketPtr packet)
Tick recvAtomic(PacketPtr packet)
tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload &trans, tlm::tlm_phase &phase, sc_core::sc_time &t)
virtual void before_end_of_elaboration()