diff options
author | Nathan Binkert <nate@binkert.org> | 2010-06-10 23:17:06 -0700 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2010-06-10 23:17:06 -0700 |
commit | bc87fa30d72df7db6265be50b2c39dc218076f9f (patch) | |
tree | 9e27c5ec1bbdbee048f2e91fc450d71f47bdf88d /src/mem/ruby/system/DMASequencer.cc | |
parent | aa7888797032bab49b5f0f637c859740497423d8 (diff) | |
download | gem5-bc87fa30d72df7db6265be50b2c39dc218076f9f.tar.xz |
ruby: get rid of RefCnt and Allocator stuff use base/refcnt.hh
This was somewhat tricky because the RefCnt API was somewhat odd. The
biggest confusion was that the the RefCnt object's constructor that
took a TYPE& cloned the object. I created an explicit virtual clone()
function for things that took advantage of this version of the
constructor. I was conservative and used clone() when I was in doubt
of whether or not it was necessary. I still think that there are
probably too many instances of clone(), but hopefully not too many.
I converted several instances of const MsgPtr & to a simple MsgPtr.
If the function wants to avoid the overhead of creating another
reference, then it should just use a regular pointer instead of a ref
counting ptr.
There were a couple of instances where refcounted objects were created
on the stack. This seems pretty dangerous since if you ever
accidentally make a reference to that object with a ref counting
pointer, bad things are bound to happen.
Diffstat (limited to 'src/mem/ruby/system/DMASequencer.cc')
-rw-r--r-- | src/mem/ruby/system/DMASequencer.cc | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/mem/ruby/system/DMASequencer.cc b/src/mem/ruby/system/DMASequencer.cc index 5d9037358..a7f3a8aec 100644 --- a/src/mem/ruby/system/DMASequencer.cc +++ b/src/mem/ruby/system/DMASequencer.cc @@ -82,22 +82,22 @@ DMASequencer::makeRequest(const RubyRequest &request) active_request.bytes_issued = 0; active_request.pkt = request.pkt; - SequencerMsg msg; - msg.getPhysicalAddress() = Address(paddr); - msg.getLineAddress() = line_address(msg.getPhysicalAddress()); - msg.getType() = write ? SequencerRequestType_ST : SequencerRequestType_LD; + SequencerMsg *msg = new SequencerMsg; + msg->getPhysicalAddress() = Address(paddr); + msg->getLineAddress() = line_address(msg->getPhysicalAddress()); + msg->getType() = write ? SequencerRequestType_ST : SequencerRequestType_LD; int offset = paddr & m_data_block_mask; - msg.getLen() = (offset + len) <= RubySystem::getBlockSizeBytes() ? + msg->getLen() = (offset + len) <= RubySystem::getBlockSizeBytes() ? len : RubySystem::getBlockSizeBytes() - offset; if (write) { - msg.getDataBlk().setData(data, offset, msg.getLen()); + msg->getDataBlk().setData(data, offset, msg->getLen()); } assert(m_mandatory_q_ptr != NULL); m_mandatory_q_ptr->enqueue(msg); - active_request.bytes_issued += msg.getLen(); + active_request.bytes_issued += msg->getLen(); return RequestStatus_Issued; } @@ -113,34 +113,34 @@ DMASequencer::issueNext() return; } - SequencerMsg msg; - msg.getPhysicalAddress() = Address(active_request.start_paddr + + SequencerMsg *msg = new SequencerMsg; + msg->getPhysicalAddress() = Address(active_request.start_paddr + active_request.bytes_completed); - assert((msg.getPhysicalAddress().getAddress() & m_data_block_mask) == 0); - msg.getLineAddress() = line_address(msg.getPhysicalAddress()); + assert((msg->getPhysicalAddress().getAddress() & m_data_block_mask) == 0); + msg->getLineAddress() = line_address(msg->getPhysicalAddress()); - msg.getType() = (active_request.write ? SequencerRequestType_ST : + msg->getType() = (active_request.write ? SequencerRequestType_ST : SequencerRequestType_LD); - msg.getLen() = + msg->getLen() = (active_request.len - active_request.bytes_completed < RubySystem::getBlockSizeBytes() ? active_request.len - active_request.bytes_completed : RubySystem::getBlockSizeBytes()); if (active_request.write) { - msg.getDataBlk(). + msg->getDataBlk(). setData(&active_request.data[active_request.bytes_completed], - 0, msg.getLen()); - msg.getType() = SequencerRequestType_ST; + 0, msg->getLen()); + msg->getType() = SequencerRequestType_ST; } else { - msg.getType() = SequencerRequestType_LD; + msg->getType() = SequencerRequestType_LD; } assert(m_mandatory_q_ptr != NULL); m_mandatory_q_ptr->enqueue(msg); - active_request.bytes_issued += msg.getLen(); + active_request.bytes_issued += msg->getLen(); } void |