Go to the documentation of this file.
46 #include "debug/DMA.hh"
47 #include "debug/Drain.hh"
53 uint32_t sid, uint32_t ssid)
55 device(dev), sys(
s), requestorId(
s->getRequestorId(dev)),
57 pendingCount(0), inRetry(
false),
72 DPRINTF(
DMA,
"Received response %s for addr: %#x size: %d nb: %d," \
73 " tot: %d sched %d\n",
91 delay += state->
delay;
109 assert(pkt->
req->isUncacheable() ||
125 panic(
"DMA port of %s not connected to anything!",
name());
135 DPRINTF(Drain,
"DmaPort not drained\n");
149 uint8_t *
data, uint32_t sid, uint32_t ssid,
Tick delay,
163 DPRINTF(
DMA,
"Starting DMA for addr: %#x size: %d sched: %d\n",
addr, size,
166 !gen.
done(); gen.next()) {
168 req = std::make_shared<Request>(
171 req->setStreamId(sid);
172 req->setSubStreamId(ssid);
183 DPRINTF(
DMA,
"--Queuing DMA for addr: %#x size: %d\n", gen.addr(),
236 DPRINTF(
DMA,
"-- Failed, waiting for retry\n");
239 DPRINTF(
DMA,
"TransmitList: %d, inRetry: %d\n",
255 DPRINTF(
DMA,
"Can't send immediately, waiting to send\n");
266 DPRINTF(
DMA,
"Sending DMA for addr: %#x size: %d\n",
267 pkt->
req->getPaddr(), pkt->
req->getSize());
273 panic(
"Unknown memory mode.");
279 if (if_name ==
"dma") {
286 unsigned max_req_size,
287 unsigned max_pending,
289 : maxReqSize(max_req_size), fifoSize(size),
290 reqFlags(flags), port(_port),
292 nextAddr(0), endAddr(0)
350 panic_if(!success,
"Buffer underrun in DmaReadFifo::get()\n");
400 if (fifo_space >= kvm_watermark ||
buffer.
capacity() < kvm_watermark) {
402 const size_t xfer_size = std::min(fifo_space, block_remaining);
406 DPRINTF(
DMA,
"KVM Bypassing startAddr=%#x xfer_size=%#x " \
407 "fifo_space=%#x block_remaining=%#x\n",
408 nextAddr, xfer_size, fifo_space, block_remaining);
419 size_t size_pending(0);
421 size_pending +=
e->requestSize();
432 event->reset(req_size);
436 size_pending += req_size;
462 if (!
event->canceled())
482 : parent(_parent), _done(false), _canceled(false), _data(max_size, 0)
490 setFlags(AutoDelete);
502 assert(
size <= _data.size());
void sendEvent(ThreadContext *tc)
Send an event (SEV) to a specific PE if there isn't already a pending event.
bool tryGet(uint8_t *dst, size_t len)
Try to read data from the FIFO.
std::deque< PacketPtr > transmitList
Use a deque as we never do any insertion or removal in the middle.
bool scheduled() const
Determine if the current event is scheduled.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void startFill(Addr start, size_t size)
Start filling the FIFO.
bool cacheResponding() const
std::unique_ptr< DmaDoneEvent > DmaDoneEventUPtr
bool isTimingMode() const
Is the system in timing mode?
#define UNSERIALIZE_SCALAR(scalar)
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
#define UNSERIALIZE_CONTAINER(member)
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
std::deque< DmaDoneEventUPtr > freeRequests
void queueDma(PacketPtr pkt)
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
void trySendTimingReq()
Take the first packet of the transmit list and attempt to send it as a timing request.
uint64_t Tick
Tick count type.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Addr numBytes
Number of bytes that have been acked for this transaction.
const Tick delay
Amount to delay completion of dma by.
std::shared_ptr< Request > RequestPtr
RequestPtr req
A pointer to the original request.
const RequestorID requestorId
Id for all requests.
const uint32_t defaultSid
Default streamId.
void stopFill()
Stop the DMA engine.
void handlePending()
Handle pending requests that have been flagged as done.
EventFunctionWrapper sendEvent
Event used to schedule a future sending from the transmit list.
ClockedObject *const device
The device that owns this port.
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
const Request::Flags reqFlags
Request flags.
@ Drained
Buffers drained, ready for serialization/handover.
const Addr maxReqSize
Maximum request size in bytes.
Command
List of all commands associated with a packet.
DrainState
Object drain/handover states.
void write(InputIterator in, size_t len)
virtual void onIdle()
Last response received callback.
void read(OutputIterator out, size_t len)
This device is the base class which all devices senstive to an address range inherit from.
void schedule(Event &event, Tick when)
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the responder port by calling its corresponding receive function.
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
void resumeFillFunctional()
Try to bypass DMA requests in KVM execution mode.
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
void handleResp(PacketPtr pkt, Tick delay=0)
Handle a response packet by updating the corresponding DMA request state to reflect the bytes receive...
Ports are used to interface objects to each other.
DmaDevice(const Params *p)
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
bool bypassCaches() const
Should caches be bypassed?
void signalDrainDone() const
Signal that an object is drained.
Buffered DMA engine helper class.
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
const size_t fifoSize
Maximum FIFO size in bytes.
void dmaDone()
DMA request done, handle incoming data and issue new request.
ProbePointArg< PacketInfo > Packet
Packet probe point.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
System *const sys
The system that device/port are in.
bool done() const
Are we done? That is, did the last call to next() advance past the end of the region?
const std::string & name()
#define SERIALIZE_SCALAR(scalar)
RequestPtr dmaAction(Packet::Command cmd, Addr addr, int size, Event *event, uint8_t *data, Tick delay, Request::Flags flag=0)
DmaDoneEvent(DmaReadFifo *_parent, size_t max_size)
void resumeFill()
Try to issue new DMA requests or bypass DMA requests.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
DrainState drainState() const
Return the current drain state of an object.
void resumeFillTiming()
Try to issue new DMA requests during normal execution.
virtual const std::string name() const
Event * completionEvent
Event to call on the device when this transaction (all packets) complete.
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
void unserialize(CheckpointIn &cp) override
Unserialize an object.
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
std::deque< DmaDoneEventUPtr > pendingRequests
virtual void onEndOfBlock()
End of block callback.
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
#define SERIALIZE_CONTAINER(member)
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
uint32_t pendingCount
Number of outstanding packets the dma port has.
bool isConnected() const
Is this port currently connected to a peer?
void sendDma()
For timing, attempt to send the first item on the transmit list, and if it is successful and there ar...
bool atEndOfBlock() const
Has the DMA engine sent out the last request for the active block?
Cycles is a wrapper class for representing cycle counts, i.e.
size_t size() const
Get the amount of data stored in the FIFO.
const Addr totBytes
Total number of bytes that this transaction involves.
std::ostream CheckpointOut
bool isActive() const
Is the DMA engine active (i.e., are there still in-flight accesses)?
This class takes an arbitrary memory region (address/length pair) and generates a series of appropria...
const uint32_t defaultSSid
Default substreamId.
SenderState * senderState
This packet's sender state.
Tick sendAtomic(PacketPtr pkt)
Send an atomic request packet, where the data is moved and the state is updated in zero time,...
DmaPort(ClockedObject *dev, System *s, uint32_t sid=0, uint32_t ssid=0)
unsigned int cacheLineSize() const
Get the cache line size of the system.
bool inRetry
If the port is currently waiting for a retry before it can send whatever it is that it's sending.
void readBlob(Addr addr, void *p, int size) const
Higher level interfaces based on the above.
DmaReadFifo(DmaPort &port, size_t size, unsigned max_req_size, unsigned max_pending, Request::Flags flags=0)
bool isAtomicMode() const
Is the system in atomic mode?
@ Draining
Draining buffers pending serialization/handover.
#define panic(...)
This implements a cprintf based panic() function.
Tick curTick()
The current simulated tick.
Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17