Sequencer.cc revision 8232
16145Snate@binkert.org/*
26145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
36145Snate@binkert.org * All rights reserved.
46145Snate@binkert.org *
56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without
66145Snate@binkert.org * modification, are permitted provided that the following conditions are
76145Snate@binkert.org * met: redistributions of source code must retain the above copyright
86145Snate@binkert.org * notice, this list of conditions and the following disclaimer;
96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright
106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
116145Snate@binkert.org * documentation and/or other materials provided with the distribution;
126145Snate@binkert.org * neither the name of the copyright holders nor the names of its
136145Snate@binkert.org * contributors may be used to endorse or promote products derived from
146145Snate@binkert.org * this software without specific prior written permission.
156145Snate@binkert.org *
166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276145Snate@binkert.org */
286145Snate@binkert.org
298229Snate@binkert.org#include "base/misc.hh"
307056Snate@binkert.org#include "base/str.hh"
317632SBrad.Beckmann@amd.com#include "cpu/testers/rubytest/RubyTester.hh"
328232Snate@binkert.org#include "debug/MemoryAccess.hh"
338232Snate@binkert.org#include "debug/ProtocolTrace.hh"
347039Snate@binkert.org#include "mem/protocol/Protocol.hh"
357039Snate@binkert.org#include "mem/ruby/buffers/MessageBuffer.hh"
367039Snate@binkert.org#include "mem/ruby/common/Global.hh"
377039Snate@binkert.org#include "mem/ruby/common/SubBlock.hh"
387039Snate@binkert.org#include "mem/ruby/profiler/Profiler.hh"
397039Snate@binkert.org#include "mem/ruby/recorder/Tracer.hh"
407039Snate@binkert.org#include "mem/ruby/slicc_interface/AbstractController.hh"
418229Snate@binkert.org#include "mem/ruby/slicc_interface/RubyRequest.hh"
427039Snate@binkert.org#include "mem/ruby/system/CacheMemory.hh"
436154Snate@binkert.org#include "mem/ruby/system/Sequencer.hh"
446154Snate@binkert.org#include "mem/ruby/system/System.hh"
457550SBrad.Beckmann@amd.com#include "mem/packet.hh"
466876Ssteve.reinhardt@amd.com#include "params/RubySequencer.hh"
476876Ssteve.reinhardt@amd.com
487055Snate@binkert.orgusing namespace std;
497055Snate@binkert.org
506876Ssteve.reinhardt@amd.comSequencer *
516876Ssteve.reinhardt@amd.comRubySequencerParams::create()
526285Snate@binkert.org{
536876Ssteve.reinhardt@amd.com    return new Sequencer(this);
546285Snate@binkert.org}
557039Snate@binkert.org
566876Ssteve.reinhardt@amd.comSequencer::Sequencer(const Params *p)
576886SBrad.Beckmann@amd.com    : RubyPort(p), deadlockCheckEvent(this)
586876Ssteve.reinhardt@amd.com{
596876Ssteve.reinhardt@amd.com    m_store_waiting_on_load_cycles = 0;
606876Ssteve.reinhardt@amd.com    m_store_waiting_on_store_cycles = 0;
616876Ssteve.reinhardt@amd.com    m_load_waiting_on_store_cycles = 0;
626876Ssteve.reinhardt@amd.com    m_load_waiting_on_load_cycles = 0;
637039Snate@binkert.org
646876Ssteve.reinhardt@amd.com    m_outstanding_count = 0;
656285Snate@binkert.org
666876Ssteve.reinhardt@amd.com    m_max_outstanding_requests = 0;
676876Ssteve.reinhardt@amd.com    m_deadlock_threshold = 0;
686876Ssteve.reinhardt@amd.com    m_instCache_ptr = NULL;
696876Ssteve.reinhardt@amd.com    m_dataCache_ptr = NULL;
706145Snate@binkert.org
716876Ssteve.reinhardt@amd.com    m_instCache_ptr = p->icache;
726876Ssteve.reinhardt@amd.com    m_dataCache_ptr = p->dcache;
736876Ssteve.reinhardt@amd.com    m_max_outstanding_requests = p->max_outstanding_requests;
746876Ssteve.reinhardt@amd.com    m_deadlock_threshold = p->deadlock_threshold;
756899SBrad.Beckmann@amd.com
766876Ssteve.reinhardt@amd.com    assert(m_max_outstanding_requests > 0);
776876Ssteve.reinhardt@amd.com    assert(m_deadlock_threshold > 0);
786876Ssteve.reinhardt@amd.com    assert(m_instCache_ptr != NULL);
796876Ssteve.reinhardt@amd.com    assert(m_dataCache_ptr != NULL);
808171Stushar@csail.mit.edu
818171Stushar@csail.mit.edu    m_usingNetworkTester = p->using_network_tester;
826145Snate@binkert.org}
836145Snate@binkert.org
847039Snate@binkert.orgSequencer::~Sequencer()
857039Snate@binkert.org{
866145Snate@binkert.org}
876145Snate@binkert.org
887039Snate@binkert.orgvoid
897039Snate@binkert.orgSequencer::wakeup()
907039Snate@binkert.org{
917039Snate@binkert.org    // Check for deadlock of any of the requests
927039Snate@binkert.org    Time current_time = g_eventQueue_ptr->getTime();
936145Snate@binkert.org
947039Snate@binkert.org    // Check across all outstanding requests
957039Snate@binkert.org    int total_outstanding = 0;
966285Snate@binkert.org
977455Snate@binkert.org    RequestTable::iterator read = m_readRequestTable.begin();
987455Snate@binkert.org    RequestTable::iterator read_end = m_readRequestTable.end();
997455Snate@binkert.org    for (; read != read_end; ++read) {
1007455Snate@binkert.org        SequencerRequest* request = read->second;
1017455Snate@binkert.org        if (current_time - request->issue_time < m_deadlock_threshold)
1027455Snate@binkert.org            continue;
1037455Snate@binkert.org
1047805Snilay@cs.wisc.edu        panic("Possible Deadlock detected. Aborting!\n"
1057921SBrad.Beckmann@amd.com             "version: %d request.paddr: 0x%x m_readRequestTable: %d "
1067805Snilay@cs.wisc.edu             "current time: %u issue_time: %d difference: %d\n", m_version,
1078174Snilay@cs.wisc.edu             request->ruby_request.m_PhysicalAddress, m_readRequestTable.size(),
1087805Snilay@cs.wisc.edu             current_time, request->issue_time,
1097805Snilay@cs.wisc.edu             current_time - request->issue_time);
1106145Snate@binkert.org    }
1116145Snate@binkert.org
1127455Snate@binkert.org    RequestTable::iterator write = m_writeRequestTable.begin();
1137455Snate@binkert.org    RequestTable::iterator write_end = m_writeRequestTable.end();
1147455Snate@binkert.org    for (; write != write_end; ++write) {
1157455Snate@binkert.org        SequencerRequest* request = write->second;
1167455Snate@binkert.org        if (current_time - request->issue_time < m_deadlock_threshold)
1177455Snate@binkert.org            continue;
1187455Snate@binkert.org
1197805Snilay@cs.wisc.edu        panic("Possible Deadlock detected. Aborting!\n"
1207921SBrad.Beckmann@amd.com             "version: %d request.paddr: 0x%x m_writeRequestTable: %d "
1217805Snilay@cs.wisc.edu             "current time: %u issue_time: %d difference: %d\n", m_version,
1228174Snilay@cs.wisc.edu             request->ruby_request.m_PhysicalAddress, m_writeRequestTable.size(),
1237805Snilay@cs.wisc.edu             current_time, request->issue_time,
1247805Snilay@cs.wisc.edu             current_time - request->issue_time);
1256145Snate@binkert.org    }
1266285Snate@binkert.org
1277039Snate@binkert.org    total_outstanding += m_writeRequestTable.size();
1287039Snate@binkert.org    total_outstanding += m_readRequestTable.size();
1296145Snate@binkert.org
1307039Snate@binkert.org    assert(m_outstanding_count == total_outstanding);
1317039Snate@binkert.org
1327039Snate@binkert.org    if (m_outstanding_count > 0) {
1337039Snate@binkert.org        // If there are still outstanding requests, keep checking
1347039Snate@binkert.org        schedule(deadlockCheckEvent,
1357039Snate@binkert.org                 m_deadlock_threshold * g_eventQueue_ptr->getClock() +
1367823Ssteve.reinhardt@amd.com                 curTick());
1377039Snate@binkert.org    }
1386145Snate@binkert.org}
1396145Snate@binkert.org
1407039Snate@binkert.orgvoid
1417039Snate@binkert.orgSequencer::printStats(ostream & out) const
1427039Snate@binkert.org{
1437039Snate@binkert.org    out << "Sequencer: " << m_name << endl
1447039Snate@binkert.org        << "  store_waiting_on_load_cycles: "
1457039Snate@binkert.org        << m_store_waiting_on_load_cycles << endl
1467039Snate@binkert.org        << "  store_waiting_on_store_cycles: "
1477039Snate@binkert.org        << m_store_waiting_on_store_cycles << endl
1487039Snate@binkert.org        << "  load_waiting_on_load_cycles: "
1497039Snate@binkert.org        << m_load_waiting_on_load_cycles << endl
1507039Snate@binkert.org        << "  load_waiting_on_store_cycles: "
1517039Snate@binkert.org        << m_load_waiting_on_store_cycles << endl;
1526859Sdrh5@cs.wisc.edu}
1536859Sdrh5@cs.wisc.edu
1547039Snate@binkert.orgvoid
1557039Snate@binkert.orgSequencer::printProgress(ostream& out) const
1567039Snate@binkert.org{
1577039Snate@binkert.org#if 0
1587039Snate@binkert.org    int total_demand = 0;
1597039Snate@binkert.org    out << "Sequencer Stats Version " << m_version << endl;
1607039Snate@binkert.org    out << "Current time = " << g_eventQueue_ptr->getTime() << endl;
1617039Snate@binkert.org    out << "---------------" << endl;
1627039Snate@binkert.org    out << "outstanding requests" << endl;
1636145Snate@binkert.org
1647455Snate@binkert.org    out << "proc " << m_Read
1657455Snate@binkert.org        << " version Requests = " << m_readRequestTable.size() << endl;
1666145Snate@binkert.org
1677039Snate@binkert.org    // print the request table
1687455Snate@binkert.org    RequestTable::iterator read = m_readRequestTable.begin();
1697455Snate@binkert.org    RequestTable::iterator read_end = m_readRequestTable.end();
1707455Snate@binkert.org    for (; read != read_end; ++read) {
1717455Snate@binkert.org        SequencerRequest* request = read->second;
1727039Snate@binkert.org        out << "\tRequest[ " << i << " ] = " << request->type
1737039Snate@binkert.org            << " Address " << rkeys[i]
1747039Snate@binkert.org            << " Posted " << request->issue_time
1757039Snate@binkert.org            << " PF " << PrefetchBit_No << endl;
1766145Snate@binkert.org        total_demand++;
1777039Snate@binkert.org    }
1786145Snate@binkert.org
1797455Snate@binkert.org    out << "proc " << m_version
1807455Snate@binkert.org        << " Write Requests = " << m_writeRequestTable.size << endl;
1816285Snate@binkert.org
1827039Snate@binkert.org    // print the request table
1837455Snate@binkert.org    RequestTable::iterator write = m_writeRequestTable.begin();
1847455Snate@binkert.org    RequestTable::iterator write_end = m_writeRequestTable.end();
1857455Snate@binkert.org    for (; write != write_end; ++write) {
1867455Snate@binkert.org        SequencerRequest* request = write->second;
1877039Snate@binkert.org        out << "\tRequest[ " << i << " ] = " << request.getType()
1887039Snate@binkert.org            << " Address " << wkeys[i]
1897039Snate@binkert.org            << " Posted " << request.getTime()
1907039Snate@binkert.org            << " PF " << request.getPrefetch() << endl;
1917039Snate@binkert.org        if (request.getPrefetch() == PrefetchBit_No) {
1927039Snate@binkert.org            total_demand++;
1937039Snate@binkert.org        }
1947039Snate@binkert.org    }
1957039Snate@binkert.org
1967039Snate@binkert.org    out << endl;
1977039Snate@binkert.org
1987039Snate@binkert.org    out << "Total Number Outstanding: " << m_outstanding_count << endl
1997039Snate@binkert.org        << "Total Number Demand     : " << total_demand << endl
2007039Snate@binkert.org        << "Total Number Prefetches : " << m_outstanding_count - total_demand
2017039Snate@binkert.org        << endl << endl << endl;
2027039Snate@binkert.org#endif
2036145Snate@binkert.org}
2046145Snate@binkert.org
2057039Snate@binkert.orgvoid
2067039Snate@binkert.orgSequencer::printConfig(ostream& out) const
2077039Snate@binkert.org{
2087039Snate@binkert.org    out << "Seqeuncer config: " << m_name << endl
2097039Snate@binkert.org        << "  controller: " << m_controller->getName() << endl
2107039Snate@binkert.org        << "  version: " << m_version << endl
2117039Snate@binkert.org        << "  max_outstanding_requests: " << m_max_outstanding_requests << endl
2127039Snate@binkert.org        << "  deadlock_threshold: " << m_deadlock_threshold << endl;
2136145Snate@binkert.org}
2146145Snate@binkert.org
2156145Snate@binkert.org// Insert the request on the correct request table.  Return true if
2166145Snate@binkert.org// the entry was already present.
2177039Snate@binkert.orgbool
2187039Snate@binkert.orgSequencer::insertRequest(SequencerRequest* request)
2197039Snate@binkert.org{
2207039Snate@binkert.org    int total_outstanding =
2217039Snate@binkert.org        m_writeRequestTable.size() + m_readRequestTable.size();
2226285Snate@binkert.org
2237039Snate@binkert.org    assert(m_outstanding_count == total_outstanding);
2246145Snate@binkert.org
2257039Snate@binkert.org    // See if we should schedule a deadlock check
2267039Snate@binkert.org    if (deadlockCheckEvent.scheduled() == false) {
2277823Ssteve.reinhardt@amd.com        schedule(deadlockCheckEvent, m_deadlock_threshold + curTick());
2287039Snate@binkert.org    }
2296145Snate@binkert.org
2308174Snilay@cs.wisc.edu    Address line_addr(request->ruby_request.m_PhysicalAddress);
2317039Snate@binkert.org    line_addr.makeLineAddress();
2328174Snilay@cs.wisc.edu    if ((request->ruby_request.m_Type == RubyRequestType_ST) ||
2338214SBrad.Beckmann@amd.com        (request->ruby_request.m_Type == RubyRequestType_ATOMIC) ||
2348174Snilay@cs.wisc.edu        (request->ruby_request.m_Type == RubyRequestType_RMW_Read) ||
2358174Snilay@cs.wisc.edu        (request->ruby_request.m_Type == RubyRequestType_RMW_Write) ||
2368174Snilay@cs.wisc.edu        (request->ruby_request.m_Type == RubyRequestType_Load_Linked) ||
2378174Snilay@cs.wisc.edu        (request->ruby_request.m_Type == RubyRequestType_Store_Conditional) ||
2388174Snilay@cs.wisc.edu        (request->ruby_request.m_Type == RubyRequestType_Locked_RMW_Read) ||
2398184Ssomayeh@cs.wisc.edu        (request->ruby_request.m_Type == RubyRequestType_Locked_RMW_Write) ||
2408184Ssomayeh@cs.wisc.edu        (request->ruby_request.m_Type == RubyRequestType_FLUSH)) {
2417455Snate@binkert.org        pair<RequestTable::iterator, bool> r =
2427455Snate@binkert.org            m_writeRequestTable.insert(RequestTable::value_type(line_addr, 0));
2437455Snate@binkert.org        bool success = r.second;
2447455Snate@binkert.org        RequestTable::iterator i = r.first;
2457455Snate@binkert.org        if (!success) {
2467455Snate@binkert.org            i->second = request;
2477039Snate@binkert.org            // return true;
2487039Snate@binkert.org
2497039Snate@binkert.org            // drh5: isn't this an error?  do you lose the initial request?
2507039Snate@binkert.org            assert(0);
2517039Snate@binkert.org        }
2527455Snate@binkert.org        i->second = request;
2537039Snate@binkert.org        m_outstanding_count++;
2547039Snate@binkert.org    } else {
2557455Snate@binkert.org        pair<RequestTable::iterator, bool> r =
2567455Snate@binkert.org            m_readRequestTable.insert(RequestTable::value_type(line_addr, 0));
2577455Snate@binkert.org        bool success = r.second;
2587455Snate@binkert.org        RequestTable::iterator i = r.first;
2597455Snate@binkert.org        if (!success) {
2607455Snate@binkert.org            i->second = request;
2617039Snate@binkert.org            // return true;
2627039Snate@binkert.org
2637039Snate@binkert.org            // drh5: isn't this an error?  do you lose the initial request?
2647039Snate@binkert.org            assert(0);
2657039Snate@binkert.org        }
2667455Snate@binkert.org        i->second = request;
2677039Snate@binkert.org        m_outstanding_count++;
2686145Snate@binkert.org    }
2696145Snate@binkert.org
2707039Snate@binkert.org    g_system_ptr->getProfiler()->sequencerRequests(m_outstanding_count);
2716145Snate@binkert.org
2727039Snate@binkert.org    total_outstanding = m_writeRequestTable.size() + m_readRequestTable.size();
2737039Snate@binkert.org    assert(m_outstanding_count == total_outstanding);
2746145Snate@binkert.org
2757039Snate@binkert.org    return false;
2766145Snate@binkert.org}
2776145Snate@binkert.org
2787039Snate@binkert.orgvoid
2797455Snate@binkert.orgSequencer::markRemoved()
2807455Snate@binkert.org{
2817455Snate@binkert.org    m_outstanding_count--;
2827455Snate@binkert.org    assert(m_outstanding_count ==
2837455Snate@binkert.org           m_writeRequestTable.size() + m_readRequestTable.size());
2847455Snate@binkert.org}
2857455Snate@binkert.org
2867455Snate@binkert.orgvoid
2877039Snate@binkert.orgSequencer::removeRequest(SequencerRequest* srequest)
2887039Snate@binkert.org{
2897039Snate@binkert.org    assert(m_outstanding_count ==
2907039Snate@binkert.org           m_writeRequestTable.size() + m_readRequestTable.size());
2916145Snate@binkert.org
2927039Snate@binkert.org    const RubyRequest & ruby_request = srequest->ruby_request;
2938174Snilay@cs.wisc.edu    Address line_addr(ruby_request.m_PhysicalAddress);
2947039Snate@binkert.org    line_addr.makeLineAddress();
2958174Snilay@cs.wisc.edu    if ((ruby_request.m_Type == RubyRequestType_ST) ||
2968174Snilay@cs.wisc.edu        (ruby_request.m_Type == RubyRequestType_RMW_Read) ||
2978174Snilay@cs.wisc.edu        (ruby_request.m_Type == RubyRequestType_RMW_Write) ||
2988174Snilay@cs.wisc.edu        (ruby_request.m_Type == RubyRequestType_Load_Linked) ||
2998174Snilay@cs.wisc.edu        (ruby_request.m_Type == RubyRequestType_Store_Conditional) ||
3008174Snilay@cs.wisc.edu        (ruby_request.m_Type == RubyRequestType_Locked_RMW_Read) ||
3018174Snilay@cs.wisc.edu        (ruby_request.m_Type == RubyRequestType_Locked_RMW_Write)) {
3027455Snate@binkert.org        m_writeRequestTable.erase(line_addr);
3037039Snate@binkert.org    } else {
3047455Snate@binkert.org        m_readRequestTable.erase(line_addr);
3057039Snate@binkert.org    }
3066285Snate@binkert.org
3077455Snate@binkert.org    markRemoved();
3086145Snate@binkert.org}
3096145Snate@binkert.org
3107560SBrad.Beckmann@amd.combool
3117560SBrad.Beckmann@amd.comSequencer::handleLlsc(const Address& address, SequencerRequest* request)
3127550SBrad.Beckmann@amd.com{
3137560SBrad.Beckmann@amd.com    //
3147560SBrad.Beckmann@amd.com    // The success flag indicates whether the LLSC operation was successful.
3157560SBrad.Beckmann@amd.com    // LL ops will always succeed, but SC may fail if the cache line is no
3167560SBrad.Beckmann@amd.com    // longer locked.
3177560SBrad.Beckmann@amd.com    //
3187560SBrad.Beckmann@amd.com    bool success = true;
3198174Snilay@cs.wisc.edu    if (request->ruby_request.m_Type == RubyRequestType_Store_Conditional) {
3207550SBrad.Beckmann@amd.com        if (!m_dataCache_ptr->isLocked(address, m_version)) {
3217550SBrad.Beckmann@amd.com            //
3227550SBrad.Beckmann@amd.com            // For failed SC requests, indicate the failure to the cpu by
3237550SBrad.Beckmann@amd.com            // setting the extra data to zero.
3247550SBrad.Beckmann@amd.com            //
3257550SBrad.Beckmann@amd.com            request->ruby_request.pkt->req->setExtraData(0);
3267560SBrad.Beckmann@amd.com            success = false;
3277550SBrad.Beckmann@amd.com        } else {
3287550SBrad.Beckmann@amd.com            //
3297550SBrad.Beckmann@amd.com            // For successful SC requests, indicate the success to the cpu by
3307550SBrad.Beckmann@amd.com            // setting the extra data to one.
3317550SBrad.Beckmann@amd.com            //
3327550SBrad.Beckmann@amd.com            request->ruby_request.pkt->req->setExtraData(1);
3337550SBrad.Beckmann@amd.com        }
3347560SBrad.Beckmann@amd.com        //
3357560SBrad.Beckmann@amd.com        // Independent of success, all SC operations must clear the lock
3367560SBrad.Beckmann@amd.com        //
3377550SBrad.Beckmann@amd.com        m_dataCache_ptr->clearLocked(address);
3388174Snilay@cs.wisc.edu    } else if (request->ruby_request.m_Type == RubyRequestType_Load_Linked) {
3397550SBrad.Beckmann@amd.com        //
3407550SBrad.Beckmann@amd.com        // Note: To fully follow Alpha LLSC semantics, should the LL clear any
3417550SBrad.Beckmann@amd.com        // previously locked cache lines?
3427550SBrad.Beckmann@amd.com        //
3437550SBrad.Beckmann@amd.com        m_dataCache_ptr->setLocked(address, m_version);
3448184Ssomayeh@cs.wisc.edu    } else if ((m_dataCache_ptr->isTagPresent(address)) && (m_dataCache_ptr->isLocked(address, m_version))) {
3457550SBrad.Beckmann@amd.com        //
3467550SBrad.Beckmann@amd.com        // Normal writes should clear the locked address
3477550SBrad.Beckmann@amd.com        //
3487550SBrad.Beckmann@amd.com        m_dataCache_ptr->clearLocked(address);
3497550SBrad.Beckmann@amd.com    }
3507560SBrad.Beckmann@amd.com    return success;
3517550SBrad.Beckmann@amd.com}
3527550SBrad.Beckmann@amd.com
3537550SBrad.Beckmann@amd.comvoid
3547039Snate@binkert.orgSequencer::writeCallback(const Address& address, DataBlock& data)
3557039Snate@binkert.org{
3567546SBrad.Beckmann@amd.com    writeCallback(address, GenericMachineType_NULL, data);
3577546SBrad.Beckmann@amd.com}
3587546SBrad.Beckmann@amd.com
3597546SBrad.Beckmann@amd.comvoid
3607546SBrad.Beckmann@amd.comSequencer::writeCallback(const Address& address,
3617546SBrad.Beckmann@amd.com                         GenericMachineType mach,
3627546SBrad.Beckmann@amd.com                         DataBlock& data)
3637546SBrad.Beckmann@amd.com{
3647565SBrad.Beckmann@amd.com    writeCallback(address, mach, data, 0, 0, 0);
3657565SBrad.Beckmann@amd.com}
3667565SBrad.Beckmann@amd.com
3677565SBrad.Beckmann@amd.comvoid
3687565SBrad.Beckmann@amd.comSequencer::writeCallback(const Address& address,
3697565SBrad.Beckmann@amd.com                         GenericMachineType mach,
3707565SBrad.Beckmann@amd.com                         DataBlock& data,
3717565SBrad.Beckmann@amd.com                         Time initialRequestTime,
3727565SBrad.Beckmann@amd.com                         Time forwardRequestTime,
3737565SBrad.Beckmann@amd.com                         Time firstResponseTime)
3747565SBrad.Beckmann@amd.com{
3757039Snate@binkert.org    assert(address == line_address(address));
3767455Snate@binkert.org    assert(m_writeRequestTable.count(line_address(address)));
3776145Snate@binkert.org
3787455Snate@binkert.org    RequestTable::iterator i = m_writeRequestTable.find(address);
3797455Snate@binkert.org    assert(i != m_writeRequestTable.end());
3807455Snate@binkert.org    SequencerRequest* request = i->second;
3816145Snate@binkert.org
3827455Snate@binkert.org    m_writeRequestTable.erase(i);
3837455Snate@binkert.org    markRemoved();
3846846Spdudnik@cs.wisc.edu
3858174Snilay@cs.wisc.edu    assert((request->ruby_request.m_Type == RubyRequestType_ST) ||
3868214SBrad.Beckmann@amd.com           (request->ruby_request.m_Type == RubyRequestType_ATOMIC) ||
3878174Snilay@cs.wisc.edu           (request->ruby_request.m_Type == RubyRequestType_RMW_Read) ||
3888174Snilay@cs.wisc.edu           (request->ruby_request.m_Type == RubyRequestType_RMW_Write) ||
3898174Snilay@cs.wisc.edu           (request->ruby_request.m_Type == RubyRequestType_Load_Linked) ||
3908174Snilay@cs.wisc.edu           (request->ruby_request.m_Type == RubyRequestType_Store_Conditional) ||
3918174Snilay@cs.wisc.edu           (request->ruby_request.m_Type == RubyRequestType_Locked_RMW_Read) ||
3928184Ssomayeh@cs.wisc.edu           (request->ruby_request.m_Type == RubyRequestType_Locked_RMW_Write) ||
3938184Ssomayeh@cs.wisc.edu           (request->ruby_request.m_Type == RubyRequestType_FLUSH));
3948184Ssomayeh@cs.wisc.edu
3956145Snate@binkert.org
3967550SBrad.Beckmann@amd.com    //
3977550SBrad.Beckmann@amd.com    // For Alpha, properly handle LL, SC, and write requests with respect to
3987550SBrad.Beckmann@amd.com    // locked cache blocks.
3997550SBrad.Beckmann@amd.com    //
4008171Stushar@csail.mit.edu    // Not valid for Network_test protocl
4018171Stushar@csail.mit.edu    //
4028171Stushar@csail.mit.edu    bool success = true;
4038171Stushar@csail.mit.edu    if(!m_usingNetworkTester)
4048171Stushar@csail.mit.edu        success = handleLlsc(address, request);
4057550SBrad.Beckmann@amd.com
4068174Snilay@cs.wisc.edu    if (request->ruby_request.m_Type == RubyRequestType_Locked_RMW_Read) {
4077039Snate@binkert.org        m_controller->blockOnQueue(address, m_mandatory_q_ptr);
4088174Snilay@cs.wisc.edu    } else if (request->ruby_request.m_Type == RubyRequestType_Locked_RMW_Write) {
4097039Snate@binkert.org        m_controller->unblock(address);
4107039Snate@binkert.org    }
4116863Sdrh5@cs.wisc.edu
4127565SBrad.Beckmann@amd.com    hitCallback(request, mach, data, success,
4137565SBrad.Beckmann@amd.com                initialRequestTime, forwardRequestTime, firstResponseTime);
4146145Snate@binkert.org}
4156145Snate@binkert.org
4167039Snate@binkert.orgvoid
4177039Snate@binkert.orgSequencer::readCallback(const Address& address, DataBlock& data)
4187039Snate@binkert.org{
4197546SBrad.Beckmann@amd.com    readCallback(address, GenericMachineType_NULL, data);
4207546SBrad.Beckmann@amd.com}
4217546SBrad.Beckmann@amd.com
4227546SBrad.Beckmann@amd.comvoid
4237546SBrad.Beckmann@amd.comSequencer::readCallback(const Address& address,
4247546SBrad.Beckmann@amd.com                        GenericMachineType mach,
4257546SBrad.Beckmann@amd.com                        DataBlock& data)
4267546SBrad.Beckmann@amd.com{
4277565SBrad.Beckmann@amd.com    readCallback(address, mach, data, 0, 0, 0);
4287565SBrad.Beckmann@amd.com}
4297565SBrad.Beckmann@amd.com
4307565SBrad.Beckmann@amd.comvoid
4317565SBrad.Beckmann@amd.comSequencer::readCallback(const Address& address,
4327565SBrad.Beckmann@amd.com                        GenericMachineType mach,
4337565SBrad.Beckmann@amd.com                        DataBlock& data,
4347565SBrad.Beckmann@amd.com                        Time initialRequestTime,
4357565SBrad.Beckmann@amd.com                        Time forwardRequestTime,
4367565SBrad.Beckmann@amd.com                        Time firstResponseTime)
4377565SBrad.Beckmann@amd.com{
4387039Snate@binkert.org    assert(address == line_address(address));
4397455Snate@binkert.org    assert(m_readRequestTable.count(line_address(address)));
4406145Snate@binkert.org
4417455Snate@binkert.org    RequestTable::iterator i = m_readRequestTable.find(address);
4427455Snate@binkert.org    assert(i != m_readRequestTable.end());
4437455Snate@binkert.org    SequencerRequest* request = i->second;
4447455Snate@binkert.org
4457455Snate@binkert.org    m_readRequestTable.erase(i);
4467455Snate@binkert.org    markRemoved();
4476145Snate@binkert.org
4488174Snilay@cs.wisc.edu    assert((request->ruby_request.m_Type == RubyRequestType_LD) ||
4498174Snilay@cs.wisc.edu           (request->ruby_request.m_Type == RubyRequestType_IFETCH));
4506285Snate@binkert.org
4517565SBrad.Beckmann@amd.com    hitCallback(request, mach, data, true,
4527565SBrad.Beckmann@amd.com                initialRequestTime, forwardRequestTime, firstResponseTime);
4536145Snate@binkert.org}
4546145Snate@binkert.org
4557039Snate@binkert.orgvoid
4567546SBrad.Beckmann@amd.comSequencer::hitCallback(SequencerRequest* srequest,
4577546SBrad.Beckmann@amd.com                       GenericMachineType mach,
4587560SBrad.Beckmann@amd.com                       DataBlock& data,
4597565SBrad.Beckmann@amd.com                       bool success,
4607565SBrad.Beckmann@amd.com                       Time initialRequestTime,
4617565SBrad.Beckmann@amd.com                       Time forwardRequestTime,
4627565SBrad.Beckmann@amd.com                       Time firstResponseTime)
4637039Snate@binkert.org{
4647039Snate@binkert.org    const RubyRequest & ruby_request = srequest->ruby_request;
4658174Snilay@cs.wisc.edu    Address request_address(ruby_request.m_PhysicalAddress);
4668174Snilay@cs.wisc.edu    Address request_line_address(ruby_request.m_PhysicalAddress);
4677039Snate@binkert.org    request_line_address.makeLineAddress();
4688174Snilay@cs.wisc.edu    RubyRequestType type = ruby_request.m_Type;
4697039Snate@binkert.org    Time issued_time = srequest->issue_time;
4706145Snate@binkert.org
4717039Snate@binkert.org    // Set this cache entry to the most recently used
4727039Snate@binkert.org    if (type == RubyRequestType_IFETCH) {
4737039Snate@binkert.org        if (m_instCache_ptr->isTagPresent(request_line_address))
4747039Snate@binkert.org            m_instCache_ptr->setMRU(request_line_address);
4757039Snate@binkert.org    } else {
4767039Snate@binkert.org        if (m_dataCache_ptr->isTagPresent(request_line_address))
4777039Snate@binkert.org            m_dataCache_ptr->setMRU(request_line_address);
4787039Snate@binkert.org    }
4796145Snate@binkert.org
4807039Snate@binkert.org    assert(g_eventQueue_ptr->getTime() >= issued_time);
4817039Snate@binkert.org    Time miss_latency = g_eventQueue_ptr->getTime() - issued_time;
4826145Snate@binkert.org
4837039Snate@binkert.org    // Profile the miss latency for all non-zero demand misses
4847039Snate@binkert.org    if (miss_latency != 0) {
4857546SBrad.Beckmann@amd.com        g_system_ptr->getProfiler()->missLatency(miss_latency, type, mach);
4866285Snate@binkert.org
4877565SBrad.Beckmann@amd.com        if (mach == GenericMachineType_L1Cache_wCC) {
4887565SBrad.Beckmann@amd.com            g_system_ptr->getProfiler()->missLatencyWcc(issued_time,
4897565SBrad.Beckmann@amd.com                                                   initialRequestTime,
4907565SBrad.Beckmann@amd.com                                                   forwardRequestTime,
4917565SBrad.Beckmann@amd.com                                                   firstResponseTime,
4927565SBrad.Beckmann@amd.com                                                   g_eventQueue_ptr->getTime());
4937565SBrad.Beckmann@amd.com        }
4947565SBrad.Beckmann@amd.com
4957565SBrad.Beckmann@amd.com        if (mach == GenericMachineType_Directory) {
4967565SBrad.Beckmann@amd.com            g_system_ptr->getProfiler()->missLatencyDir(issued_time,
4977565SBrad.Beckmann@amd.com                                                   initialRequestTime,
4987565SBrad.Beckmann@amd.com                                                   forwardRequestTime,
4997565SBrad.Beckmann@amd.com                                                   firstResponseTime,
5007565SBrad.Beckmann@amd.com                                                   g_eventQueue_ptr->getTime());
5017565SBrad.Beckmann@amd.com        }
5027565SBrad.Beckmann@amd.com
5037832Snate@binkert.org        DPRINTFR(ProtocolTrace, "%7s %3s %10s%20s %6s>%-6s %s %d cycles\n",
5047832Snate@binkert.org            g_eventQueue_ptr->getTime(), m_version, "Seq",
5057832Snate@binkert.org            success ? "Done" : "SC_Failed", "", "",
5068174Snilay@cs.wisc.edu            ruby_request.m_PhysicalAddress, miss_latency);
5076285Snate@binkert.org    }
5087039Snate@binkert.org#if 0
5097039Snate@binkert.org    if (request.getPrefetch() == PrefetchBit_Yes) {
5107039Snate@binkert.org        return; // Ignore the prefetch
5117039Snate@binkert.org    }
5127039Snate@binkert.org#endif
5136285Snate@binkert.org
5147039Snate@binkert.org    // update the data
5157039Snate@binkert.org    if (ruby_request.data != NULL) {
5167039Snate@binkert.org        if ((type == RubyRequestType_LD) ||
5177039Snate@binkert.org            (type == RubyRequestType_IFETCH) ||
5187039Snate@binkert.org            (type == RubyRequestType_RMW_Read) ||
5197908Shestness@cs.utexas.edu            (type == RubyRequestType_Locked_RMW_Read) ||
5207907Shestness@cs.utexas.edu            (type == RubyRequestType_Load_Linked)) {
5217039Snate@binkert.org            memcpy(ruby_request.data,
5228174Snilay@cs.wisc.edu                   data.getData(request_address.getOffset(), ruby_request.m_Size),
5238174Snilay@cs.wisc.edu                   ruby_request.m_Size);
5247039Snate@binkert.org        } else {
5257039Snate@binkert.org            data.setData(ruby_request.data, request_address.getOffset(),
5268174Snilay@cs.wisc.edu                         ruby_request.m_Size);
5277039Snate@binkert.org        }
5286285Snate@binkert.org    } else {
5297039Snate@binkert.org        DPRINTF(MemoryAccess,
5307039Snate@binkert.org                "WARNING.  Data not transfered from Ruby to M5 for type %s\n",
5317039Snate@binkert.org                RubyRequestType_to_string(type));
5327039Snate@binkert.org    }
5337023SBrad.Beckmann@amd.com
5347039Snate@binkert.org    // If using the RubyTester, update the RubyTester sender state's
5357039Snate@binkert.org    // subBlock with the recieved data.  The tester will later access
5367039Snate@binkert.org    // this state.
5377039Snate@binkert.org    // Note: RubyPort will access it's sender state before the
5387039Snate@binkert.org    // RubyTester.
5397039Snate@binkert.org    if (m_usingRubyTester) {
5407039Snate@binkert.org        RubyPort::SenderState *requestSenderState =
5417039Snate@binkert.org            safe_cast<RubyPort::SenderState*>(ruby_request.pkt->senderState);
5427039Snate@binkert.org        RubyTester::SenderState* testerSenderState =
5437039Snate@binkert.org            safe_cast<RubyTester::SenderState*>(requestSenderState->saved);
5447039Snate@binkert.org        testerSenderState->subBlock->mergeFrom(data);
5457039Snate@binkert.org    }
5467023SBrad.Beckmann@amd.com
5477039Snate@binkert.org    ruby_hit_callback(ruby_request.pkt);
5487039Snate@binkert.org    delete srequest;
5496285Snate@binkert.org}
5506285Snate@binkert.org
5516285Snate@binkert.org// Returns true if the sequencer already has a load or store outstanding
5527039Snate@binkert.orgRequestStatus
5537039Snate@binkert.orgSequencer::getRequestStatus(const RubyRequest& request)
5547039Snate@binkert.org{
5557039Snate@binkert.org    bool is_outstanding_store =
5568174Snilay@cs.wisc.edu        !!m_writeRequestTable.count(line_address(request.m_PhysicalAddress));
5577039Snate@binkert.org    bool is_outstanding_load =
5588174Snilay@cs.wisc.edu        !!m_readRequestTable.count(line_address(request.m_PhysicalAddress));
5597039Snate@binkert.org    if (is_outstanding_store) {
5608174Snilay@cs.wisc.edu        if ((request.m_Type == RubyRequestType_LD) ||
5618174Snilay@cs.wisc.edu            (request.m_Type == RubyRequestType_IFETCH) ||
5628174Snilay@cs.wisc.edu            (request.m_Type == RubyRequestType_RMW_Read)) {
5637039Snate@binkert.org            m_store_waiting_on_load_cycles++;
5647039Snate@binkert.org        } else {
5657039Snate@binkert.org            m_store_waiting_on_store_cycles++;
5667039Snate@binkert.org        }
5677039Snate@binkert.org        return RequestStatus_Aliased;
5687039Snate@binkert.org    } else if (is_outstanding_load) {
5698174Snilay@cs.wisc.edu        if ((request.m_Type == RubyRequestType_ST) ||
5708174Snilay@cs.wisc.edu            (request.m_Type == RubyRequestType_RMW_Write)) {
5717039Snate@binkert.org            m_load_waiting_on_store_cycles++;
5727039Snate@binkert.org        } else {
5737039Snate@binkert.org            m_load_waiting_on_load_cycles++;
5747039Snate@binkert.org        }
5757039Snate@binkert.org        return RequestStatus_Aliased;
5766859Sdrh5@cs.wisc.edu    }
5777039Snate@binkert.org
5787039Snate@binkert.org    if (m_outstanding_count >= m_max_outstanding_requests) {
5797039Snate@binkert.org        return RequestStatus_BufferFull;
5806859Sdrh5@cs.wisc.edu    }
5816145Snate@binkert.org
5827039Snate@binkert.org    return RequestStatus_Ready;
5836145Snate@binkert.org}
5846145Snate@binkert.org
5857039Snate@binkert.orgbool
5867039Snate@binkert.orgSequencer::empty() const
5877039Snate@binkert.org{
5887455Snate@binkert.org    return m_writeRequestTable.empty() && m_readRequestTable.empty();
5896145Snate@binkert.org}
5906145Snate@binkert.org
5917039Snate@binkert.orgRequestStatus
5927039Snate@binkert.orgSequencer::makeRequest(const RubyRequest &request)
5937039Snate@binkert.org{
5948174Snilay@cs.wisc.edu    assert(request.m_PhysicalAddress.getOffset() + request.m_Size <=
5957039Snate@binkert.org           RubySystem::getBlockSizeBytes());
5967039Snate@binkert.org    RequestStatus status = getRequestStatus(request);
5977039Snate@binkert.org    if (status != RequestStatus_Ready)
5987039Snate@binkert.org        return status;
5996349Spdudnik@gmail.com
6007039Snate@binkert.org    SequencerRequest *srequest =
6017039Snate@binkert.org        new SequencerRequest(request, g_eventQueue_ptr->getTime());
6026285Snate@binkert.org    bool found = insertRequest(srequest);
6037039Snate@binkert.org    if (found) {
6047039Snate@binkert.org        panic("Sequencer::makeRequest should never be called if the "
6057039Snate@binkert.org              "request is already outstanding\n");
6067039Snate@binkert.org        return RequestStatus_NULL;
6077039Snate@binkert.org    }
6087023SBrad.Beckmann@amd.com
6097039Snate@binkert.org    issueRequest(request);
6106145Snate@binkert.org
6117039Snate@binkert.org    // TODO: issue hardware prefetches here
6127039Snate@binkert.org    return RequestStatus_Issued;
6136145Snate@binkert.org}
6146145Snate@binkert.org
6157039Snate@binkert.orgvoid
6167039Snate@binkert.orgSequencer::issueRequest(const RubyRequest& request)
6177039Snate@binkert.org{
6188174Snilay@cs.wisc.edu    // TODO: Eliminate RubyRequest being copied again.
6198174Snilay@cs.wisc.edu
6208165Snilay@cs.wisc.edu    RubyRequestType ctype;
6218174Snilay@cs.wisc.edu    switch(request.m_Type) {
6227039Snate@binkert.org      case RubyRequestType_IFETCH:
6238165Snilay@cs.wisc.edu        ctype = RubyRequestType_IFETCH;
6247039Snate@binkert.org        break;
6257039Snate@binkert.org      case RubyRequestType_LD:
6268165Snilay@cs.wisc.edu        ctype = RubyRequestType_LD;
6277039Snate@binkert.org        break;
6288184Ssomayeh@cs.wisc.edu      case RubyRequestType_FLUSH:
6298184Ssomayeh@cs.wisc.edu        ctype = RubyRequestType_FLUSH;
6308184Ssomayeh@cs.wisc.edu        break;
6317039Snate@binkert.org      case RubyRequestType_ST:
6327908Shestness@cs.utexas.edu      case RubyRequestType_RMW_Read:
6337908Shestness@cs.utexas.edu      case RubyRequestType_RMW_Write:
6347908Shestness@cs.utexas.edu      //
6357908Shestness@cs.utexas.edu      // x86 locked instructions are translated to store cache coherence
6367908Shestness@cs.utexas.edu      // requests because these requests should always be treated as read
6377908Shestness@cs.utexas.edu      // exclusive operations and should leverage any migratory sharing
6387908Shestness@cs.utexas.edu      // optimization built into the protocol.
6397908Shestness@cs.utexas.edu      //
6407908Shestness@cs.utexas.edu      case RubyRequestType_Locked_RMW_Read:
6417908Shestness@cs.utexas.edu      case RubyRequestType_Locked_RMW_Write:
6428165Snilay@cs.wisc.edu        ctype = RubyRequestType_ST;
6437039Snate@binkert.org        break;
6447908Shestness@cs.utexas.edu      //
6457908Shestness@cs.utexas.edu      // Alpha LL/SC instructions need to be handled carefully by the cache
6467908Shestness@cs.utexas.edu      // coherence protocol to ensure they follow the proper semantics.  In
6477908Shestness@cs.utexas.edu      // particular, by identifying the operations as atomic, the protocol
6487908Shestness@cs.utexas.edu      // should understand that migratory sharing optimizations should not be
6497908Shestness@cs.utexas.edu      // performed (i.e. a load between the LL and SC should not steal away
6507908Shestness@cs.utexas.edu      // exclusive permission).
6517908Shestness@cs.utexas.edu      //
6527907Shestness@cs.utexas.edu      case RubyRequestType_Load_Linked:
6537907Shestness@cs.utexas.edu      case RubyRequestType_Store_Conditional:
6548214SBrad.Beckmann@amd.com      case RubyRequestType_ATOMIC:
6558165Snilay@cs.wisc.edu        ctype = RubyRequestType_ATOMIC;
6567039Snate@binkert.org        break;
6577039Snate@binkert.org      default:
6587039Snate@binkert.org        assert(0);
6597039Snate@binkert.org    }
6606285Snate@binkert.org
6618164Snilay@cs.wisc.edu    RubyAccessMode amtype;
6628174Snilay@cs.wisc.edu    switch(request.m_AccessMode){
6637039Snate@binkert.org      case RubyAccessMode_User:
6648164Snilay@cs.wisc.edu        amtype = RubyAccessMode_User;
6657039Snate@binkert.org        break;
6667039Snate@binkert.org      case RubyAccessMode_Supervisor:
6678164Snilay@cs.wisc.edu        amtype = RubyAccessMode_Supervisor;
6687039Snate@binkert.org        break;
6697039Snate@binkert.org      case RubyAccessMode_Device:
6708164Snilay@cs.wisc.edu        amtype = RubyAccessMode_User;
6717039Snate@binkert.org        break;
6727039Snate@binkert.org      default:
6737039Snate@binkert.org        assert(0);
6747039Snate@binkert.org    }
6756285Snate@binkert.org
6768174Snilay@cs.wisc.edu    Address line_addr(request.m_PhysicalAddress);
6777039Snate@binkert.org    line_addr.makeLineAddress();
6788214SBrad.Beckmann@amd.com    int proc_id = -1;
6798214SBrad.Beckmann@amd.com    if (request.pkt != NULL && request.pkt->req->hasContextId()) {
6808214SBrad.Beckmann@amd.com        proc_id = request.pkt->req->contextId();
6818214SBrad.Beckmann@amd.com    }
6828174Snilay@cs.wisc.edu    RubyRequest *msg = new RubyRequest(request.m_PhysicalAddress.getAddress(),
6838174Snilay@cs.wisc.edu                                       request.data, request.m_Size,
6848174Snilay@cs.wisc.edu                                       request.m_ProgramCounter.getAddress(),
6858174Snilay@cs.wisc.edu                                       ctype, amtype, request.pkt,
6868188SLisa.Hsu@amd.com                                       PrefetchBit_No, proc_id);
6876285Snate@binkert.org
6887832Snate@binkert.org    DPRINTFR(ProtocolTrace, "%7s %3s %10s%20s %6s>%-6s %s %s\n",
6897832Snate@binkert.org        g_eventQueue_ptr->getTime(), m_version, "Seq", "Begin", "", "",
6908174Snilay@cs.wisc.edu        request.m_PhysicalAddress, RubyRequestType_to_string(request.m_Type));
6916285Snate@binkert.org
6927039Snate@binkert.org    Time latency = 0;  // initialzed to an null value
6936285Snate@binkert.org
6948174Snilay@cs.wisc.edu    if (request.m_Type == RubyRequestType_IFETCH)
6957039Snate@binkert.org        latency = m_instCache_ptr->getLatency();
6967039Snate@binkert.org    else
6977039Snate@binkert.org        latency = m_dataCache_ptr->getLatency();
6986285Snate@binkert.org
6997039Snate@binkert.org    // Send the message to the cache controller
7007039Snate@binkert.org    assert(latency > 0);
7016145Snate@binkert.org
7027039Snate@binkert.org    assert(m_mandatory_q_ptr != NULL);
7037039Snate@binkert.org    m_mandatory_q_ptr->enqueue(msg, latency);
7046145Snate@binkert.org}
7056145Snate@binkert.org
7067039Snate@binkert.org#if 0
7077039Snate@binkert.orgbool
7088165Snilay@cs.wisc.eduSequencer::tryCacheAccess(const Address& addr, RubyRequestType type,
7098164Snilay@cs.wisc.edu                          RubyAccessMode access_mode,
7107039Snate@binkert.org                          int size, DataBlock*& data_ptr)
7117039Snate@binkert.org{
7127039Snate@binkert.org    CacheMemory *cache =
7138165Snilay@cs.wisc.edu        (type == RubyRequestType_IFETCH) ? m_instCache_ptr : m_dataCache_ptr;
7147039Snate@binkert.org
7157039Snate@binkert.org    return cache->tryCacheAccess(line_address(addr), type, data_ptr);
7167039Snate@binkert.org}
7177039Snate@binkert.org#endif
7187039Snate@binkert.org
7197455Snate@binkert.orgtemplate <class KEY, class VALUE>
7207455Snate@binkert.orgstd::ostream &
7217455Snate@binkert.orgoperator<<(ostream &out, const m5::hash_map<KEY, VALUE> &map)
7227455Snate@binkert.org{
7237455Snate@binkert.org    typename m5::hash_map<KEY, VALUE>::const_iterator i = map.begin();
7247455Snate@binkert.org    typename m5::hash_map<KEY, VALUE>::const_iterator end = map.end();
7257455Snate@binkert.org
7267455Snate@binkert.org    out << "[";
7277455Snate@binkert.org    for (; i != end; ++i)
7287455Snate@binkert.org        out << " " << i->first << "=" << i->second;
7297455Snate@binkert.org    out << " ]";
7307455Snate@binkert.org
7317455Snate@binkert.org    return out;
7327455Snate@binkert.org}
7337455Snate@binkert.org
7347039Snate@binkert.orgvoid
7357039Snate@binkert.orgSequencer::print(ostream& out) const
7367039Snate@binkert.org{
7377039Snate@binkert.org    out << "[Sequencer: " << m_version
7387039Snate@binkert.org        << ", outstanding requests: " << m_outstanding_count
7397039Snate@binkert.org        << ", read request table: " << m_readRequestTable
7407039Snate@binkert.org        << ", write request table: " << m_writeRequestTable
7417039Snate@binkert.org        << "]";
7427039Snate@binkert.org}
7437039Snate@binkert.org
7447039Snate@binkert.org// this can be called from setState whenever coherence permissions are
7457039Snate@binkert.org// upgraded when invoked, coherence violations will be checked for the
7467039Snate@binkert.org// given block
7477039Snate@binkert.orgvoid
7487039Snate@binkert.orgSequencer::checkCoherence(const Address& addr)
7497039Snate@binkert.org{
7506145Snate@binkert.org#ifdef CHECK_COHERENCE
7517039Snate@binkert.org    g_system_ptr->checkGlobalCoherenceInvariant(addr);
7526145Snate@binkert.org#endif
7536145Snate@binkert.org}
754