summaryrefslogtreecommitdiff
path: root/src/mem/ruby/system
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2013-02-19 05:56:05 -0500
committerAndreas Hansson <andreas.hansson@arm.com>2013-02-19 05:56:05 -0500
commit0622f30961fc32b967bb1ef784afc5a205b16f6e (patch)
treeb6b57cf049b7fc7e49cc65a735af7508862b9c24 /src/mem/ruby/system
parentf69d431ede9b815ea4b63a2d20237ed3e79df169 (diff)
downloadgem5-0622f30961fc32b967bb1ef784afc5a205b16f6e.tar.xz
mem: Add predecessor to SenderState base class
This patch adds a predecessor field to the SenderState base class to make the process of linking them up more uniform, and enable a traversal of the stack without knowing the specific type of the subclasses. There are a number of simplifications done as part of changing the SenderState, particularly in the RubyTest.
Diffstat (limited to 'src/mem/ruby/system')
-rw-r--r--src/mem/ruby/system/RubyPort.cc11
-rw-r--r--src/mem/ruby/system/RubyPort.hh4
-rw-r--r--src/mem/ruby/system/Sequencer.cc8
3 files changed, 10 insertions, 13 deletions
diff --git a/src/mem/ruby/system/RubyPort.cc b/src/mem/ruby/system/RubyPort.cc
index 2f1cc622d..5e9e8cdd4 100644
--- a/src/mem/ruby/system/RubyPort.cc
+++ b/src/mem/ruby/system/RubyPort.cc
@@ -151,12 +151,9 @@ RubyPort::PioPort::recvTimingResp(PacketPtr pkt)
// First we must retrieve the request port from the sender State
RubyPort::SenderState *senderState =
- safe_cast<RubyPort::SenderState *>(pkt->senderState);
+ safe_cast<RubyPort::SenderState *>(pkt->popSenderState());
M5Port *port = senderState->port;
assert(port != NULL);
-
- // pop the sender state from the packet
- pkt->senderState = senderState->saved;
delete senderState;
port->sendTimingResp(pkt);
@@ -187,7 +184,7 @@ RubyPort::M5Port::recvTimingReq(PacketPtr pkt)
// Save the port in the sender state object to be used later to
// route the response
- pkt->senderState = new SenderState(this, pkt->senderState);
+ pkt->pushSenderState(new SenderState(this));
// Check for pio requests and directly send them to the dedicated
// pio port.
@@ -230,7 +227,7 @@ RubyPort::M5Port::recvTimingReq(PacketPtr pkt)
pkt->getAddr(), RequestStatus_to_string(requestStatus));
SenderState* senderState = safe_cast<SenderState*>(pkt->senderState);
- pkt->senderState = senderState->saved;
+ pkt->senderState = senderState->predecessor;
delete senderState;
return false;
}
@@ -305,7 +302,7 @@ RubyPort::ruby_hit_callback(PacketPtr pkt)
assert(port != NULL);
// pop the sender state from the packet
- pkt->senderState = senderState->saved;
+ pkt->senderState = senderState->predecessor;
delete senderState;
port->hitCallback(pkt);
diff --git a/src/mem/ruby/system/RubyPort.hh b/src/mem/ruby/system/RubyPort.hh
index cec356edb..3c61eb522 100644
--- a/src/mem/ruby/system/RubyPort.hh
+++ b/src/mem/ruby/system/RubyPort.hh
@@ -113,10 +113,8 @@ class RubyPort : public MemObject
struct SenderState : public Packet::SenderState
{
M5Port* port;
- Packet::SenderState *saved;
- SenderState(M5Port* _port, Packet::SenderState *sender_state = NULL)
- : port(_port), saved(sender_state)
+ SenderState(M5Port* _port) : port(_port)
{}
};
diff --git a/src/mem/ruby/system/Sequencer.cc b/src/mem/ruby/system/Sequencer.cc
index 1cdd6d806..f00f8407a 100644
--- a/src/mem/ruby/system/Sequencer.cc
+++ b/src/mem/ruby/system/Sequencer.cc
@@ -530,11 +530,13 @@ Sequencer::hitCallback(SequencerRequest* srequest,
// Note: RubyPort will access it's sender state before the
// RubyTester.
if (m_usingRubyTester) {
- RubyPort::SenderState *requestSenderState =
+ RubyPort::SenderState *reqSenderState =
safe_cast<RubyPort::SenderState*>(pkt->senderState);
+ // @todo This is a dangerous assumption on nothing else
+ // modifying the senderState
RubyTester::SenderState* testerSenderState =
- safe_cast<RubyTester::SenderState*>(requestSenderState->saved);
- testerSenderState->subBlock->mergeFrom(data);
+ safe_cast<RubyTester::SenderState*>(reqSenderState->predecessor);
+ testerSenderState->subBlock.mergeFrom(data);
}
delete srequest;