RubyRequest.cc revision 9302:c2e70a9bc340
1#include <iostream>
2
3#include "mem/ruby/slicc_interface/RubyRequest.hh"
4
5using namespace std;
6
7void
8RubyRequest::print(ostream& out) const
9{
10  out << "[RubyRequest: ";
11  out << "LineAddress = " << m_LineAddress << " ";
12  out << "PhysicalAddress = " << m_PhysicalAddress << " ";
13  out << "Type = " << m_Type << " ";
14  out << "ProgramCounter = " << m_ProgramCounter << " ";
15  out << "AccessMode = " << m_AccessMode << " ";
16  out << "Size = " << m_Size << " ";
17  out << "Prefetch = " << m_Prefetch << " ";
18//  out << "Time = " << getTime() << " ";
19  out << "]";
20}
21
22bool
23RubyRequest::functionalRead(Packet *pkt)
24{
25    // This needs a little explanation. Initially I thought that this
26    // message should be read. But the way the memtester works for now,
27    // we should not be reading this message as memtester updates the
28    // functional memory only after a write has actually taken place.
29    return false;
30}
31
32bool
33RubyRequest::functionalWrite(Packet *pkt)
34{
35    // This needs a little explanation. I am not sure if this message
36    // should be written. Essentially the question is how are writes
37    // ordered. I am assuming that if a functional write is issued after
38    // a timing write to the same address, then the functional write
39    // has to overwrite the data for the timing request, even if the
40    // timing request has still not been ordered globally.
41
42    Address pktLineAddr(pkt->getAddr());
43    pktLineAddr.makeLineAddress();
44
45    if (pktLineAddr == m_LineAddress) {
46        uint8_t *pktData = pkt->getPtr<uint8_t>(true);
47        unsigned int size_in_bytes = pkt->getSize();
48        unsigned startByte = pkt->getAddr() - m_LineAddress.getAddress();
49
50        for (unsigned i = 0; i < size_in_bytes; ++i) {
51            data[i + startByte] = pktData[i];
52        }
53
54        return true;
55    }
56    return false;
57}
58