41#ifndef __DEV_DMA_DEVICE_HH__
42#define __DEV_DMA_DEVICE_HH__
53#include "params/DmaDevice.hh"
117 const std::optional<uint32_t>
sid;
118 const std::optional<uint32_t>
ssid;
125 std::optional<uint32_t> _sid, std::optional<uint32_t> _ssid,
201 std::optional<uint32_t> ssid=0);
209 uint8_t *
data, std::optional<uint32_t> sid,
232 std::optional<uint32_t> sid, std::optional<uint32_t> ssid,
247 std::optional<uint32_t> sid, std::optional<uint32_t> ssid,
262 void init()
override;
282 virtual const std::string
name()
const {
return "DmaCallback"; }
387 unsigned max_req_size,
388 unsigned max_pending,
423 return tryGet(
static_cast<T *
>(&value),
sizeof(T));
434 void get(uint8_t *dst,
size_t len);
441 get(
static_cast<uint8_t *
>(&value),
sizeof(T));
Declaration and inline definition of ChunkGenerator object.
The AddrRangeMap uses an STL map to implement an interval tree for address decoding.
This class takes an arbitrary memory region (address/length pair) and generates a series of appropria...
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Event * getChunkEvent()
Request a chunk event.
void chunkComplete()
Called by DMA engine completion event on each chunk completion.
virtual ~DmaCallback()=default
DrainState drain() override
DmaPort ensures that all oustanding DMA accesses have completed before it finishes draining.
virtual const std::string name() const
virtual void process()=0
Callback function invoked on completion of all chunks.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
void dmaRead(Addr addr, int size, Event *event, uint8_t *data, Tick delay=0)
void dmaRead(Addr addr, int size, Event *event, uint8_t *data, std::optional< uint32_t > sid, std::optional< uint32_t > ssid, Tick delay=0)
void dmaWrite(Addr addr, int size, Event *event, uint8_t *data, std::optional< uint32_t > sid, std::optional< uint32_t > ssid, Tick delay=0)
virtual ~DmaDevice()=default
Addr cacheBlockSize() const
void dmaWrite(Addr addr, int size, Event *event, uint8_t *data, Tick delay=0)
DmaDevice(const Params &p)
const std::optional< uint32_t > defaultSSid
Default substreamId.
ClockedObject *const device
The device that owns this port.
EventFunctionWrapper sendEvent
Event used to schedule a future sending from the transmit list.
System *const sys
The system that device/port are in.
void dmaAction(Packet::Command cmd, Addr addr, int size, Event *event, uint8_t *data, Tick delay, Request::Flags flag=0)
bool sendAtomicBdReq(DmaReqState *state)
Send the next packet from a DMA request in atomic mode, and request and/or use memory backdoors if po...
const std::optional< uint32_t > defaultSid
Default streamId.
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
DmaPort(ClockedObject *dev, System *s, std::optional< uint32_t > sid=0, std::optional< uint32_t > ssid=0)
void trySendTimingReq()
Take the first request on the transmit list and attempt to send a timing packet from it.
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
PacketPtr inRetry
The packet (if any) waiting for a retry to send.
uint32_t pendingCount
Number of outstanding packets the dma port has.
std::deque< DmaReqState * > transmitList
Use a deque as we never do any insertion or removal in the middle.
AddrRangeMap< MemBackdoorPtr, 1 > memBackdoors
void sendDma()
For timing, attempt to send the first item on the transmit list, and if it is successful and there ar...
void handleResp(DmaReqState *state, Addr addr, Addr size, Tick delay=0)
bool retryPending
Whether the other side expects us to wait for a retry.
const RequestorID requestorId
Id for all requests.
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
bool sendAtomicReq(DmaReqState *state)
Send the next packet from a DMA request in atomic mode.
void handleRespPacket(PacketPtr pkt, Tick delay=0)
Handle a response packet by updating the corresponding DMA request state to reflect the bytes receive...
std::vector< uint8_t > _data
const uint8_t * data() const
DmaDoneEvent(DmaReadFifo *_parent, size_t max_size)
size_t requestSize() const
void serialize(CheckpointOut &cp) const override
Serialize an object.
size_t size() const
Get the amount of data stored in the FIFO.
virtual void onIdle()
Last response received callback.
bool tryGet(uint8_t *dst, size_t len)
Try to read data from the FIFO.
void startFill(Addr start, size_t size)
Start filling the FIFO.
DmaReadFifo(DmaPort &port, size_t size, unsigned max_req_size, unsigned max_pending, Request::Flags flags=0)
const Request::Flags reqFlags
Request flags.
virtual void onEndOfBlock()
End of block callback.
void resumeFill()
Try to issue new DMA requests or bypass DMA requests.
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
void unserialize(CheckpointIn &cp) override
Unserialize an object.
std::deque< DmaDoneEventUPtr > freeRequests
void flush()
Flush the FIFO.
void dmaDone()
DMA request done, handle incoming data and issue new request.
bool isActive() const
Is the DMA engine active (i.e., are there still in-flight accesses)?
void stopFill()
Stop the DMA engine.
void resumeFillBypass()
Try to bypass DMA requests in non-caching mode.
bool atEndOfBlock() const
Has the DMA engine sent out the last request for the active block?
const Addr maxReqSize
Maximum request size in bytes.
const size_t fifoSize
Maximum FIFO size in bytes.
void handlePending()
Handle pending requests that have been flagged as done.
void resumeFillTiming()
Try to issue new DMA requests during normal execution.
std::unique_ptr< DmaDoneEvent > DmaDoneEventUPtr
std::deque< DmaDoneEventUPtr > pendingRequests
Event(Priority p=Default_Pri, Flags f=0)
Simple FIFO implementation backed by a circular buffer.
PioDevice(const Params &p)
Ports are used to interface objects to each other.
RequestPort(const std::string &name, SimObject *_owner, PortID id=InvalidPortID)
Request port.
gem5::Flags< FlagsType > Flags
void signalDrainDone() const
Signal that an object is drained.
DrainState
Object drain/handover states.
@ Draining
Draining buffers pending serialization/handover.
@ Drained
Buffers drained, ready for serialization/handover.
Copyright (c) 2024 Arm Limited All rights reserved.
const PortID InvalidPortID
std::ostream CheckpointOut
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
uint64_t Tick
Tick count type.
const Packet::Command cmd
Command for the request.
const std::optional< uint32_t > ssid
const Addr totBytes
Total number of bytes that this transaction involves.
Event * completionEvent
Event to call on the device when this transaction (all packets) complete.
Addr numBytes
Number of bytes that have been acked for this transaction.
const RequestorID id
The requestor ID to use for requests.
const Tick delay
Amount to delay completion of dma by.
ChunkGenerator gen
Object to track what chunks of bytes to send at a time.
uint8_t *const data
Pointer to a buffer for the data.
Event * abortEvent
Event to call on the device when this transaction is aborted.
const std::optional< uint32_t > sid
Stream IDs.
DmaReqState(Packet::Command _cmd, Addr addr, Addr chunk_sz, Addr tb, uint8_t *_data, Request::Flags _flags, RequestorID _id, std::optional< uint32_t > _sid, std::optional< uint32_t > _ssid, Event *ce, Tick _delay, Event *ae=nullptr)
const Request::Flags flags
The flags to use for requests.
bool aborted
Whether this request was aborted.
A virtual base opaque structure used to hold state associated with the packet (e.g....