110086Snilay@cs.wisc.edu/*
210086Snilay@cs.wisc.edu * Copyright (c) 2011 Mark D. Hill and David A. Wood
310086Snilay@cs.wisc.edu * All rights reserved.
410086Snilay@cs.wisc.edu *
510086Snilay@cs.wisc.edu * Redistribution and use in source and binary forms, with or without
610086Snilay@cs.wisc.edu * modification, are permitted provided that the following conditions are
710086Snilay@cs.wisc.edu * met: redistributions of source code must retain the above copyright
810086Snilay@cs.wisc.edu * notice, this list of conditions and the following disclaimer;
910086Snilay@cs.wisc.edu * redistributions in binary form must reproduce the above copyright
1010086Snilay@cs.wisc.edu * notice, this list of conditions and the following disclaimer in the
1110086Snilay@cs.wisc.edu * documentation and/or other materials provided with the distribution;
1210086Snilay@cs.wisc.edu * neither the name of the copyright holders nor the names of its
1310086Snilay@cs.wisc.edu * contributors may be used to endorse or promote products derived from
1410086Snilay@cs.wisc.edu * this software without specific prior written permission.
1510086Snilay@cs.wisc.edu *
1610086Snilay@cs.wisc.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1710086Snilay@cs.wisc.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1810086Snilay@cs.wisc.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1910086Snilay@cs.wisc.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2010086Snilay@cs.wisc.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2110086Snilay@cs.wisc.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2210086Snilay@cs.wisc.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2310086Snilay@cs.wisc.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2410086Snilay@cs.wisc.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2510086Snilay@cs.wisc.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2610086Snilay@cs.wisc.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2710086Snilay@cs.wisc.edu */
2810086Snilay@cs.wisc.edu
2911793Sbrandon.potter@amd.com#include "mem/ruby/slicc_interface/RubyRequest.hh"
3011793Sbrandon.potter@amd.com
318092Snilay@cs.wisc.edu#include <iostream>
328092Snilay@cs.wisc.edu
338092Snilay@cs.wisc.eduusing namespace std;
348092Snilay@cs.wisc.edu
358174Snilay@cs.wisc.eduvoid
368174Snilay@cs.wisc.eduRubyRequest::print(ostream& out) const
378092Snilay@cs.wisc.edu{
388174Snilay@cs.wisc.edu  out << "[RubyRequest: ";
3911118Snilay@cs.wisc.edu  out << hex << "LineAddress = 0x" << m_LineAddress << dec << " ";
4011118Snilay@cs.wisc.edu  out << hex << "PhysicalAddress = 0x" << m_PhysicalAddress << dec << " ";
418174Snilay@cs.wisc.edu  out << "Type = " << m_Type << " ";
4211118Snilay@cs.wisc.edu  out << hex << "ProgramCounter = 0x" << m_ProgramCounter << dec << " ";
438174Snilay@cs.wisc.edu  out << "AccessMode = " << m_AccessMode << " ";
448174Snilay@cs.wisc.edu  out << "Size = " << m_Size << " ";
458174Snilay@cs.wisc.edu  out << "Prefetch = " << m_Prefetch << " ";
468174Snilay@cs.wisc.edu//  out << "Time = " << getTime() << " ";
478174Snilay@cs.wisc.edu  out << "]";
488092Snilay@cs.wisc.edu}
499302Snilay@cs.wisc.edu
509302Snilay@cs.wisc.edubool
519302Snilay@cs.wisc.eduRubyRequest::functionalRead(Packet *pkt)
529302Snilay@cs.wisc.edu{
539302Snilay@cs.wisc.edu    // This needs a little explanation. Initially I thought that this
549302Snilay@cs.wisc.edu    // message should be read. But the way the memtester works for now,
559302Snilay@cs.wisc.edu    // we should not be reading this message as memtester updates the
569302Snilay@cs.wisc.edu    // functional memory only after a write has actually taken place.
579302Snilay@cs.wisc.edu    return false;
589302Snilay@cs.wisc.edu}
599302Snilay@cs.wisc.edu
609302Snilay@cs.wisc.edubool
619302Snilay@cs.wisc.eduRubyRequest::functionalWrite(Packet *pkt)
629302Snilay@cs.wisc.edu{
639302Snilay@cs.wisc.edu    // This needs a little explanation. I am not sure if this message
649302Snilay@cs.wisc.edu    // should be written. Essentially the question is how are writes
659302Snilay@cs.wisc.edu    // ordered. I am assuming that if a functional write is issued after
669302Snilay@cs.wisc.edu    // a timing write to the same address, then the functional write
679302Snilay@cs.wisc.edu    // has to overwrite the data for the timing request, even if the
689302Snilay@cs.wisc.edu    // timing request has still not been ordered globally.
699302Snilay@cs.wisc.edu
709572Sbah13@duke.edu    Addr wBase = pkt->getAddr();
719572Sbah13@duke.edu    Addr wTail = wBase + pkt->getSize();
7211025Snilay@cs.wisc.edu    Addr mBase = m_PhysicalAddress;
739572Sbah13@duke.edu    Addr mTail = mBase + m_Size;
749302Snilay@cs.wisc.edu
7510563Sandreas.hansson@arm.com    const uint8_t * pktData = pkt->getConstPtr<uint8_t>();
769302Snilay@cs.wisc.edu
779572Sbah13@duke.edu    Addr cBase = std::max(wBase, mBase);
789572Sbah13@duke.edu    Addr cTail = std::min(wTail, mTail);
799302Snilay@cs.wisc.edu
809572Sbah13@duke.edu    for (Addr i = cBase; i < cTail; ++i) {
819572Sbah13@duke.edu        data[i - mBase] = pktData[i - wBase];
829302Snilay@cs.wisc.edu    }
839572Sbah13@duke.edu
849572Sbah13@duke.edu    return cBase < cTail;
859302Snilay@cs.wisc.edu}
86