diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-02-24 11:43:53 -0500 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-02-24 11:43:53 -0500 |
commit | 1031b824b975cec999c37cabc8c05c485a4ae5ca (patch) | |
tree | 18af5987accd59781642001849908ddb486d069a /src/dev/copy_engine.cc | |
parent | 9f07d2ce7ecf435b9a1946f15fb3491bb4636637 (diff) | |
download | gem5-1031b824b975cec999c37cabc8c05c485a4ae5ca.tar.xz |
MEM: Move port creation to the memory object(s) construction
This patch moves all port creation from the getPort method to be
consistently done in the MemObject's constructor. This is possible
thanks to the Swig interface passing the length of the vector ports.
Previously there was a mix of: 1) creating the ports as members (at
object construction time) and using getPort for the name resolution,
or 2) dynamically creating the ports in the getPort call. This is now
uniform. Furthermore, objects that would not be complete without a
port have these ports as members rather than having pointers to
dynamically allocated ports.
This patch also enables an elaboration-time enumeration of all the
ports in the system which can be used to determine the masterId.
Diffstat (limited to 'src/dev/copy_engine.cc')
-rw-r--r-- | src/dev/copy_engine.cc | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/dev/copy_engine.cc b/src/dev/copy_engine.cc index a3958127b..7b17a86a3 100644 --- a/src/dev/copy_engine.cc +++ b/src/dev/copy_engine.cc @@ -77,7 +77,9 @@ CopyEngine::CopyEngine(const Params *p) CopyEngine::CopyEngineChannel::CopyEngineChannel(CopyEngine *_ce, int cid) - : cePort(NULL), ce(_ce), channelId(cid), busy(false), underReset(false), + : cePort(_ce, _ce->sys, _ce->params()->min_backoff_delay, + _ce->params()->max_backoff_delay), + ce(_ce), channelId(cid), busy(false), underReset(false), refreshNext(false), latBeforeBegin(ce->params()->latBeforeBegin), latAfterCompletion(ce->params()->latAfterCompletion), completionDataReg(0), nextState(Idle), drainEvent(NULL), @@ -106,7 +108,6 @@ CopyEngine::CopyEngineChannel::~CopyEngineChannel() { delete curDmaDesc; delete [] copyBuffer; - delete cePort; } Port * @@ -123,10 +124,7 @@ CopyEngine::getPort(const std::string &if_name, int idx) Port * CopyEngine::CopyEngineChannel::getPort() { - assert(cePort == NULL); - cePort = new DmaPort(ce, ce->sys, ce->params()->min_backoff_delay, - ce->params()->max_backoff_delay); - return cePort; + return &cePort; } void @@ -451,9 +449,9 @@ CopyEngine::CopyEngineChannel::fetchDescriptor(Addr address) DPRINTF(DMACopyEngine, "dmaAction: %#x, %d bytes, to addr %#x\n", ce->platform->pciToDma(address), sizeof(DmaDesc), curDmaDesc); - cePort->dmaAction(MemCmd::ReadReq, ce->platform->pciToDma(address), - sizeof(DmaDesc), &fetchCompleteEvent, (uint8_t*)curDmaDesc, - latBeforeBegin); + cePort.dmaAction(MemCmd::ReadReq, ce->platform->pciToDma(address), + sizeof(DmaDesc), &fetchCompleteEvent, + (uint8_t*)curDmaDesc, latBeforeBegin); lastDescriptorAddr = address; } @@ -495,8 +493,8 @@ CopyEngine::CopyEngineChannel::readCopyBytes() DPRINTF(DMACopyEngine, "Reading %d bytes from buffer to memory location %#x(%#x)\n", curDmaDesc->len, curDmaDesc->dest, ce->platform->pciToDma(curDmaDesc->src)); - cePort->dmaAction(MemCmd::ReadReq, ce->platform->pciToDma(curDmaDesc->src), - curDmaDesc->len, &readCompleteEvent, copyBuffer, 0); + cePort.dmaAction(MemCmd::ReadReq, ce->platform->pciToDma(curDmaDesc->src), + curDmaDesc->len, &readCompleteEvent, copyBuffer, 0); } void @@ -517,8 +515,8 @@ CopyEngine::CopyEngineChannel::writeCopyBytes() curDmaDesc->len, curDmaDesc->dest, ce->platform->pciToDma(curDmaDesc->dest)); - cePort->dmaAction(MemCmd::WriteReq, ce->platform->pciToDma(curDmaDesc->dest), - curDmaDesc->len, &writeCompleteEvent, copyBuffer, 0); + cePort.dmaAction(MemCmd::WriteReq, ce->platform->pciToDma(curDmaDesc->dest), + curDmaDesc->len, &writeCompleteEvent, copyBuffer, 0); ce->bytesCopied[channelId] += curDmaDesc->len; ce->copiesProcessed[channelId]++; @@ -586,9 +584,10 @@ CopyEngine::CopyEngineChannel::writeCompletionStatus() completionDataReg, cr.completionAddr, ce->platform->pciToDma(cr.completionAddr)); - cePort->dmaAction(MemCmd::WriteReq, ce->platform->pciToDma(cr.completionAddr), - sizeof(completionDataReg), &statusCompleteEvent, - (uint8_t*)&completionDataReg, latAfterCompletion); + cePort.dmaAction(MemCmd::WriteReq, + ce->platform->pciToDma(cr.completionAddr), + sizeof(completionDataReg), &statusCompleteEvent, + (uint8_t*)&completionDataReg, latAfterCompletion); } void @@ -604,9 +603,10 @@ CopyEngine::CopyEngineChannel::fetchNextAddr(Addr address) anBegin("FetchNextAddr"); DPRINTF(DMACopyEngine, "Fetching next address...\n"); busy = true; - cePort->dmaAction(MemCmd::ReadReq, ce->platform->pciToDma(address + - offsetof(DmaDesc, next)), sizeof(Addr), &addrCompleteEvent, - (uint8_t*)curDmaDesc + offsetof(DmaDesc, next), 0); + cePort.dmaAction(MemCmd::ReadReq, + ce->platform->pciToDma(address + offsetof(DmaDesc, next)), + sizeof(Addr), &addrCompleteEvent, + (uint8_t*)curDmaDesc + offsetof(DmaDesc, next), 0); } void @@ -648,7 +648,7 @@ CopyEngine::CopyEngineChannel::drain(Event *de) if (nextState == Idle || ce->getState() != SimObject::Running) return 0; unsigned int count = 1; - count += cePort->drain(de); + count += cePort.drain(de); DPRINTF(DMACopyEngine, "unable to drain, returning %d\n", count); drainEvent = de; @@ -659,7 +659,7 @@ unsigned int CopyEngine::drain(Event *de) { unsigned int count; - count = pioPort->drain(de) + dmaPort->drain(de) + configPort->drain(de); + count = pioPort.drain(de) + dmaPort.drain(de) + configPort.drain(de); for (int x = 0;x < chan.size(); x++) count += chan[x]->drain(de); |