RubyRequest.cc revision 9572:13ae8000f771
16145Snate@binkert.org#include <iostream>
26145Snate@binkert.org
36145Snate@binkert.org#include "mem/ruby/slicc_interface/RubyRequest.hh"
46145Snate@binkert.org
56145Snate@binkert.orgusing namespace std;
66145Snate@binkert.org
76145Snate@binkert.orgvoid
86145Snate@binkert.orgRubyRequest::print(ostream& out) const
96145Snate@binkert.org{
106145Snate@binkert.org  out << "[RubyRequest: ";
116145Snate@binkert.org  out << "LineAddress = " << m_LineAddress << " ";
126145Snate@binkert.org  out << "PhysicalAddress = " << m_PhysicalAddress << " ";
136145Snate@binkert.org  out << "Type = " << m_Type << " ";
146145Snate@binkert.org  out << "ProgramCounter = " << m_ProgramCounter << " ";
156145Snate@binkert.org  out << "AccessMode = " << m_AccessMode << " ";
166145Snate@binkert.org  out << "Size = " << m_Size << " ";
176145Snate@binkert.org  out << "Prefetch = " << m_Prefetch << " ";
186145Snate@binkert.org//  out << "Time = " << getTime() << " ";
196145Snate@binkert.org  out << "]";
206145Snate@binkert.org}
216145Snate@binkert.org
226145Snate@binkert.orgbool
236145Snate@binkert.orgRubyRequest::functionalRead(Packet *pkt)
246145Snate@binkert.org{
256145Snate@binkert.org    // This needs a little explanation. Initially I thought that this
266145Snate@binkert.org    // message should be read. But the way the memtester works for now,
276145Snate@binkert.org    // we should not be reading this message as memtester updates the
286145Snate@binkert.org    // functional memory only after a write has actually taken place.
296145Snate@binkert.org    return false;
306145Snate@binkert.org}
316145Snate@binkert.org
326145Snate@binkert.orgbool
336145Snate@binkert.orgRubyRequest::functionalWrite(Packet *pkt)
346145Snate@binkert.org{
356145Snate@binkert.org    // This needs a little explanation. I am not sure if this message
366145Snate@binkert.org    // should be written. Essentially the question is how are writes
376145Snate@binkert.org    // ordered. I am assuming that if a functional write is issued after
386145Snate@binkert.org    // a timing write to the same address, then the functional write
396145Snate@binkert.org    // has to overwrite the data for the timing request, even if the
406145Snate@binkert.org    // timing request has still not been ordered globally.
416145Snate@binkert.org
426145Snate@binkert.org    Addr wBase = pkt->getAddr();
436145Snate@binkert.org    Addr wTail = wBase + pkt->getSize();
446145Snate@binkert.org    Addr mBase = m_PhysicalAddress.getAddress();
457002Snate@binkert.org    Addr mTail = mBase + m_Size;
467002Snate@binkert.org
477002Snate@binkert.org    uint8_t * pktData = pkt->getPtr<uint8_t>(true);
487002Snate@binkert.org
497048Snate@binkert.org    Addr cBase = std::max(wBase, mBase);
507048Snate@binkert.org    Addr cTail = std::min(wTail, mTail);
517048Snate@binkert.org
527048Snate@binkert.org    for (Addr i = cBase; i < cTail; ++i) {
537048Snate@binkert.org        data[i - mBase] = pktData[i - wBase];
547048Snate@binkert.org    }
557048Snate@binkert.org
567048Snate@binkert.org    return cBase < cTail;
577048Snate@binkert.org}
586154Snate@binkert.org