1/* 2 * Copyright (c) 2011 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include "mem/ruby/slicc_interface/RubyRequest.hh" 30 31#include <iostream> 32 33using namespace std; 34 35void 36RubyRequest::print(ostream& out) const 37{ 38 out << "[RubyRequest: "; 39 out << hex << "LineAddress = 0x" << m_LineAddress << dec << " "; 40 out << hex << "PhysicalAddress = 0x" << m_PhysicalAddress << dec << " "; 41 out << "Type = " << m_Type << " "; 42 out << hex << "ProgramCounter = 0x" << m_ProgramCounter << dec << " "; 43 out << "AccessMode = " << m_AccessMode << " "; 44 out << "Size = " << m_Size << " "; 45 out << "Prefetch = " << m_Prefetch << " "; 46// out << "Time = " << getTime() << " "; 47 out << "]"; 48} 49 50bool 51RubyRequest::functionalRead(Packet *pkt) 52{ 53 // This needs a little explanation. Initially I thought that this 54 // message should be read. But the way the memtester works for now, 55 // we should not be reading this message as memtester updates the 56 // functional memory only after a write has actually taken place. 57 return false; 58} 59 60bool 61RubyRequest::functionalWrite(Packet *pkt) 62{ 63 // This needs a little explanation. I am not sure if this message 64 // should be written. Essentially the question is how are writes 65 // ordered. I am assuming that if a functional write is issued after 66 // a timing write to the same address, then the functional write 67 // has to overwrite the data for the timing request, even if the 68 // timing request has still not been ordered globally. 69 70 Addr wBase = pkt->getAddr(); 71 Addr wTail = wBase + pkt->getSize(); 72 Addr mBase = m_PhysicalAddress; 73 Addr mTail = mBase + m_Size; 74 75 const uint8_t * pktData = pkt->getConstPtr<uint8_t>(); 76 77 Addr cBase = std::max(wBase, mBase); 78 Addr cTail = std::min(wTail, mTail); 79 80 for (Addr i = cBase; i < cTail; ++i) { 81 data[i - mBase] = pktData[i - wBase]; 82 } 83 84 return cBase < cTail; 85} 86