system.cc revision 8826
12689Sktlim@umich.edu/*
28703Sandreas.hansson@arm.com * Copyright (c) 2011-2012 ARM Limited
38666SPrakash.Ramrakhyani@arm.com * All rights reserved
48666SPrakash.Ramrakhyani@arm.com *
58666SPrakash.Ramrakhyani@arm.com * The license below extends only to copyright in the software and shall
68666SPrakash.Ramrakhyani@arm.com * not be construed as granting a license to any other intellectual
78666SPrakash.Ramrakhyani@arm.com * property including but not limited to intellectual property relating
88666SPrakash.Ramrakhyani@arm.com * to a hardware implementation of the functionality of the software
98666SPrakash.Ramrakhyani@arm.com * licensed hereunder.  You may use the software subject to the license
108666SPrakash.Ramrakhyani@arm.com * terms below provided that you ensure that this notice is replicated
118666SPrakash.Ramrakhyani@arm.com * unmodified and in its entirety in all distributions of the software,
128666SPrakash.Ramrakhyani@arm.com * modified or unmodified, in source code or in binary form.
138666SPrakash.Ramrakhyani@arm.com *
142689Sktlim@umich.edu * Copyright (c) 2003-2006 The Regents of The University of Michigan
157897Shestness@cs.utexas.edu * Copyright (c) 2011 Regents of the University of California
162689Sktlim@umich.edu * All rights reserved.
172689Sktlim@umich.edu *
182689Sktlim@umich.edu * Redistribution and use in source and binary forms, with or without
192689Sktlim@umich.edu * modification, are permitted provided that the following conditions are
202689Sktlim@umich.edu * met: redistributions of source code must retain the above copyright
212689Sktlim@umich.edu * notice, this list of conditions and the following disclaimer;
222689Sktlim@umich.edu * redistributions in binary form must reproduce the above copyright
232689Sktlim@umich.edu * notice, this list of conditions and the following disclaimer in the
242689Sktlim@umich.edu * documentation and/or other materials provided with the distribution;
252689Sktlim@umich.edu * neither the name of the copyright holders nor the names of its
262689Sktlim@umich.edu * contributors may be used to endorse or promote products derived from
272689Sktlim@umich.edu * this software without specific prior written permission.
282689Sktlim@umich.edu *
292689Sktlim@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
302689Sktlim@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
312689Sktlim@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
322689Sktlim@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
332689Sktlim@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
342689Sktlim@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
352689Sktlim@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
362689Sktlim@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
372689Sktlim@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
382689Sktlim@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
392689Sktlim@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
402689Sktlim@umich.edu *
412689Sktlim@umich.edu * Authors: Steve Reinhardt
422689Sktlim@umich.edu *          Lisa Hsu
432689Sktlim@umich.edu *          Nathan Binkert
442689Sktlim@umich.edu *          Ali Saidi
457897Shestness@cs.utexas.edu *          Rick Strong
462689Sktlim@umich.edu */
472689Sktlim@umich.edu
482521SN/A#include "arch/isa_traits.hh"
493960Sgblack@eecs.umich.edu#include "arch/remote_gdb.hh"
504194Ssaidi@eecs.umich.edu#include "arch/utility.hh"
518769Sgblack@eecs.umich.edu#include "arch/vtophys.hh"
521070SN/A#include "base/loader/object_file.hh"
531070SN/A#include "base/loader/symtab.hh"
549142Ssteve.reinhardt@amd.com#include "base/trace.hh"
552521SN/A#include "config/the_isa.hh"
566658Snate@binkert.org#include "cpu/thread_context.hh"
578229Snate@binkert.org#include "debug/Loader.hh"
588232Snate@binkert.org#include "debug/WorkItems.hh"
598666SPrakash.Ramrakhyani@arm.com#include "kern/kernel_stats.hh"
608769Sgblack@eecs.umich.edu#include "mem/fs_translating_port_proxy.hh"
612522SN/A#include "mem/mem_object.hh"
628769Sgblack@eecs.umich.edu#include "mem/physical.hh"
632037SN/A#include "params/System.hh"
648229Snate@binkert.org#include "sim/byteswap.hh"
658769Sgblack@eecs.umich.edu#include "sim/debug.hh"
6656SN/A#include "sim/full_system.hh"
676658Snate@binkert.org#include "sim/system.hh"
682SN/A
692107SN/Ausing namespace std;
702SN/Ausing namespace TheISA;
712SN/A
722SN/Avector<System *> System::systemList;
732SN/A
742SN/Aint System::numSystemsRunning = 0;
751070SN/A
768703Sandreas.hansson@arm.comSystem::System(Params *p)
778703Sandreas.hansson@arm.com    : MemObject(p), _systemPort("system_port", this),
788826Snilay@cs.wisc.edu      physmem(p->physmem),
792521SN/A      _numContexts(0),
808852Sandreas.hansson@arm.com      pagePtr(0),
818852Sandreas.hansson@arm.com      init_param(p->init_param),
827580SAli.Saidi@arm.com      loadAddrMask(p->load_addr_mask),
837770SAli.Saidi@ARM.com      nextPID(0),
848931Sandreas.hansson@arm.com      memoryMode(p->mem_mode),
857914SBrad.Beckmann@amd.com      workItemsBegin(0),
867914SBrad.Beckmann@amd.com      workItemsEnd(0),
877914SBrad.Beckmann@amd.com      numWorkIds(p->num_work_ids),
888666SPrakash.Ramrakhyani@arm.com      _params(p),
897914SBrad.Beckmann@amd.com      totalNumInsts(0),
908666SPrakash.Ramrakhyani@arm.com      instEventQueue("system instruction-based event queue")
917897Shestness@cs.utexas.edu{
922SN/A    // add self to global system list
931070SN/A    systemList.push_back(this);
941070SN/A
951070SN/A    /** Keep track of all memories we can execute code out of
968769Sgblack@eecs.umich.edu     * in our system
978769Sgblack@eecs.umich.edu     */
988769Sgblack@eecs.umich.edu    for (int x = 0; x < p->memories.size(); x++) {
998769Sgblack@eecs.umich.edu        if (!p->memories[x])
1008666SPrakash.Ramrakhyani@arm.com            continue;
1018832SAli.Saidi@ARM.com        memRanges.push_back(RangeSize(p->memories[x]->start(),
1028832SAli.Saidi@ARM.com                                      p->memories[x]->size()));
1038832SAli.Saidi@ARM.com    }
1048832SAli.Saidi@ARM.com
1058832SAli.Saidi@ARM.com    if (FullSystem) {
1068832SAli.Saidi@ARM.com        kernelSymtab = new SymbolTable;
1078832SAli.Saidi@ARM.com        if (!debugSymbolTable)
1088832SAli.Saidi@ARM.com            debugSymbolTable = new SymbolTable;
1098832SAli.Saidi@ARM.com
1108832SAli.Saidi@ARM.com        /**
1118885SAli.Saidi@ARM.com         * Get a port proxy to memory
1128885SAli.Saidi@ARM.com         */
1138885SAli.Saidi@ARM.com        physProxy = new PortProxy(*getSystemPort());
1149147Snilay@cs.wisc.edu        virtProxy = new FSTranslatingPortProxy(*getSystemPort());
1159147Snilay@cs.wisc.edu    }
1169147Snilay@cs.wisc.edu}
1178885SAli.Saidi@ARM.com
1188885SAli.Saidi@ARM.comSystem::~System()
1198885SAli.Saidi@ARM.com{
1208885SAli.Saidi@ARM.com    delete kernelSymtab;
1218885SAli.Saidi@ARM.com    delete kernel;
1228885SAli.Saidi@ARM.com
1238885SAli.Saidi@ARM.com    for (uint32_t j = 0; j < numWorkIds; j++)
1248885SAli.Saidi@ARM.com        delete workItemStats[j];
1258885SAli.Saidi@ARM.com}
1268885SAli.Saidi@ARM.com
1278885SAli.Saidi@ARM.comvoid
1288885SAli.Saidi@ARM.comSystem::init()
1298885SAli.Saidi@ARM.com{
1308885SAli.Saidi@ARM.com    // check that the system port is connected
1318885SAli.Saidi@ARM.com    if (!_systemPort.isConnected())
1328885SAli.Saidi@ARM.com        panic("System port on %s is not connected.\n", name());
1338885SAli.Saidi@ARM.com}
1348885SAli.Saidi@ARM.com
1358885SAli.Saidi@ARM.comPort*
1368885SAli.Saidi@ARM.comSystem::getPort(const std::string &if_name, int idx)
1378885SAli.Saidi@ARM.com{
1388885SAli.Saidi@ARM.com    // no need to distinguish at the moment (besides checking)
1398885SAli.Saidi@ARM.com    return &_systemPort;
1408885SAli.Saidi@ARM.com}
1418885SAli.Saidi@ARM.com
1428885SAli.Saidi@ARM.comvoid
1438885SAli.Saidi@ARM.comSystem::setMemoryMode(Enums::MemoryMode mode)
1448885SAli.Saidi@ARM.com{
1458885SAli.Saidi@ARM.com    assert(getState() == Drained);
1468885SAli.Saidi@ARM.com    memoryMode = mode;
1478885SAli.Saidi@ARM.com}
1488885SAli.Saidi@ARM.com
1498885SAli.Saidi@ARM.combool System::breakpoint()
1508885SAli.Saidi@ARM.com{
1519053Sdam.sunwoo@arm.com    if (remoteGDB.size())
1529053Sdam.sunwoo@arm.com        return remoteGDB[0]->breakpoint();
1539053Sdam.sunwoo@arm.com    return false;
1542SN/A}
1552SN/A
1562SN/A/**
1572SN/A * Setting rgdb_wait to a positive integer waits for a remote debugger to
1581070SN/A * connect to that context ID before continuing.  This should really
1591070SN/A   be a parameter on the CPU object or something...
1608666SPrakash.Ramrakhyani@arm.com */
1618666SPrakash.Ramrakhyani@arm.comint rgdb_wait = -1;
1628666SPrakash.Ramrakhyani@arm.com
1632SN/Aint
1642SN/ASystem::registerThreadContext(ThreadContext *tc, int assigned)
1658706Sandreas.hansson@arm.com{
1668706Sandreas.hansson@arm.com    int id;
1678706Sandreas.hansson@arm.com    if (assigned == -1) {
1688706Sandreas.hansson@arm.com        for (id = 0; id < threadContexts.size(); id++) {
1698706Sandreas.hansson@arm.com            if (!threadContexts[id])
1708706Sandreas.hansson@arm.com                break;
1718706Sandreas.hansson@arm.com        }
1728706Sandreas.hansson@arm.com
1738922Swilliam.wang@arm.com        if (threadContexts.size() <= id)
1748922Swilliam.wang@arm.com            threadContexts.resize(id + 1);
1758703Sandreas.hansson@arm.com    } else {
1768703Sandreas.hansson@arm.com        if (threadContexts.size() <= assigned)
1778922Swilliam.wang@arm.com            threadContexts.resize(assigned + 1);
1788703Sandreas.hansson@arm.com        id = assigned;
1798703Sandreas.hansson@arm.com    }
1802901Ssaidi@eecs.umich.edu
1814762Snate@binkert.org    if (threadContexts[id])
1822901Ssaidi@eecs.umich.edu        fatal("Cannot have two CPUs with the same id (%d)\n", id);
1832901Ssaidi@eecs.umich.edu
1842901Ssaidi@eecs.umich.edu    threadContexts[id] = tc;
1852901Ssaidi@eecs.umich.edu    _numContexts++;
1862901Ssaidi@eecs.umich.edu
1873960Sgblack@eecs.umich.edu    int port = getRemoteGDBPort();
1883960Sgblack@eecs.umich.edu    if (port) {
1894095Sbinkertn@umich.edu        RemoteGDB *rgdb = new RemoteGDB(this, tc);
1904095Sbinkertn@umich.edu        GDBListener *gdbl = new GDBListener(rgdb, port + id);
1914095Sbinkertn@umich.edu        gdbl->listen();
1923960Sgblack@eecs.umich.edu
1933960Sgblack@eecs.umich.edu        if (rgdb_wait != -1 && rgdb_wait == id)
1947445Ssteve.reinhardt@amd.com            gdbl->accept();
1957445Ssteve.reinhardt@amd.com
1967445Ssteve.reinhardt@amd.com        if (remoteGDB.size() <= id) {
1977445Ssteve.reinhardt@amd.com            remoteGDB.resize(id + 1);
1987445Ssteve.reinhardt@amd.com        }
1997445Ssteve.reinhardt@amd.com
2007445Ssteve.reinhardt@amd.com        remoteGDB[id] = rgdb;
201180SN/A    }
2025718Shsul@eecs.umich.edu
2032SN/A    activeCpus.push_back(false);
2045712Shsul@eecs.umich.edu
2055718Shsul@eecs.umich.edu    return id;
2065718Shsul@eecs.umich.edu}
2075718Shsul@eecs.umich.edu
2085718Shsul@eecs.umich.eduint
2095718Shsul@eecs.umich.eduSystem::numRunningContexts()
2105718Shsul@eecs.umich.edu{
2115718Shsul@eecs.umich.edu    int running = 0;
2125718Shsul@eecs.umich.edu    for (int i = 0; i < _numContexts; ++i) {
2135718Shsul@eecs.umich.edu        if (threadContexts[i]->status() != ThreadContext::Halted)
2145718Shsul@eecs.umich.edu            ++running;
2155718Shsul@eecs.umich.edu    }
2165718Shsul@eecs.umich.edu    return running;
2171806SN/A}
2181806SN/A
2192680Sktlim@umich.eduvoid
2205823Ssaidi@eecs.umich.eduSystem::initState()
2211806SN/A{
2222680Sktlim@umich.edu    int i;
2235714Shsul@eecs.umich.edu    if (FullSystem) {
2241070SN/A        for (i = 0; i < threadContexts.size(); i++)
2255512SMichael.Adler@intel.com            TheISA::startupCPU(threadContexts[i], i);
2267445Ssteve.reinhardt@amd.com        // Moved from the constructor to here since it relies on the
2274095Sbinkertn@umich.edu        // address map being resolved in the interconnect
2285512SMichael.Adler@intel.com        /**
2294095Sbinkertn@umich.edu         * Load the kernel code into memory
2307445Ssteve.reinhardt@amd.com         */
2314095Sbinkertn@umich.edu        if (params()->kernel == "") {
2324095Sbinkertn@umich.edu            inform("No kernel set for full system simulation. "
2331070SN/A                    "Assuming you know what you're doing...\n");
2344095Sbinkertn@umich.edu        } else {
2354095Sbinkertn@umich.edu            // Load kernel code
2364095Sbinkertn@umich.edu            kernel = createObjectFile(params()->kernel);
2374095Sbinkertn@umich.edu            inform("kernel located at: %s", params()->kernel);
2384095Sbinkertn@umich.edu
2391070SN/A            if (kernel == NULL)
2401070SN/A                fatal("Could not load kernel file %s", params()->kernel);
2417914SBrad.Beckmann@amd.com
2427914SBrad.Beckmann@amd.com            // Load program sections into memory
2431806SN/A            kernel->loadSections(physProxy, loadAddrMask);
244180SN/A
24575SN/A            // setup entry points
2466029Ssteve.reinhardt@amd.com            kernelStart = kernel->textBase();
2476029Ssteve.reinhardt@amd.com            kernelEnd = kernel->bssBase() + kernel->bssSize();
2486029Ssteve.reinhardt@amd.com            kernelEntry = kernel->entryPoint();
2496029Ssteve.reinhardt@amd.com
2506029Ssteve.reinhardt@amd.com            // load symbols
2516029Ssteve.reinhardt@amd.com            if (!kernel->loadGlobalSymbols(kernelSymtab))
2526029Ssteve.reinhardt@amd.com                fatal("could not load kernel symbols\n");
2536029Ssteve.reinhardt@amd.com
2546029Ssteve.reinhardt@amd.com            if (!kernel->loadLocalSymbols(kernelSymtab))
2556029Ssteve.reinhardt@amd.com                fatal("could not load kernel local symbols\n");
2566029Ssteve.reinhardt@amd.com
257180SN/A            if (!kernel->loadGlobalSymbols(debugSymbolTable))
2587733SAli.Saidi@ARM.com                fatal("could not load kernel symbols\n");
2591129SN/A
2608806Sgblack@eecs.umich.edu            if (!kernel->loadLocalSymbols(debugSymbolTable))
2618769Sgblack@eecs.umich.edu                fatal("could not load kernel local symbols\n");
2628769Sgblack@eecs.umich.edu
2638769Sgblack@eecs.umich.edu            DPRINTF(Loader, "Kernel start = %#x\n", kernelStart);
2648799Sgblack@eecs.umich.edu            DPRINTF(Loader, "Kernel end   = %#x\n", kernelEnd);
2658799Sgblack@eecs.umich.edu            DPRINTF(Loader, "Kernel entry = %#x\n", kernelEntry);
2668799Sgblack@eecs.umich.edu            DPRINTF(Loader, "Kernel loaded...\n");
2678799Sgblack@eecs.umich.edu        }
2688799Sgblack@eecs.umich.edu    }
2698885SAli.Saidi@ARM.com
2708799Sgblack@eecs.umich.edu    // increment the number of running systms
2718799Sgblack@eecs.umich.edu    numSystemsRunning++;
2728706Sandreas.hansson@arm.com
2738799Sgblack@eecs.umich.edu    activeCpus.clear();
2748799Sgblack@eecs.umich.edu
2758799Sgblack@eecs.umich.edu    if (!FullSystem)
2768799Sgblack@eecs.umich.edu        return;
2778799Sgblack@eecs.umich.edu
2788706Sandreas.hansson@arm.com    for (i = 0; i < threadContexts.size(); i++)
2798706Sandreas.hansson@arm.com        TheISA::startupCPU(threadContexts[i], i);
2808706Sandreas.hansson@arm.com}
2818706Sandreas.hansson@arm.com
2828806Sgblack@eecs.umich.eduvoid
2838806Sgblack@eecs.umich.eduSystem::replaceThreadContext(ThreadContext *tc, int context_id)
2848806Sgblack@eecs.umich.edu{
2858806Sgblack@eecs.umich.edu    if (context_id >= threadContexts.size()) {
2868806Sgblack@eecs.umich.edu        panic("replaceThreadContext: bad id, %d >= %d\n",
2871129SN/A              context_id, threadContexts.size());
2881129SN/A    }
2891129SN/A
2905713Shsul@eecs.umich.edu    threadContexts[context_id] = tc;
291180SN/A    if (context_id < remoteGDB.size())
2925713Shsul@eecs.umich.edu        remoteGDB[context_id]->replaceThreadContext(tc);
2932680Sktlim@umich.edu}
2945713Shsul@eecs.umich.edu
295180SN/AAddr
296180SN/ASystem::allocPhysPages(int npages)
2975713Shsul@eecs.umich.edu{
2985713Shsul@eecs.umich.edu    Addr return_addr = pagePtr << LogVMPageSize;
2995713Shsul@eecs.umich.edu    pagePtr += npages;
3002SN/A    if (pagePtr > physmem->size())
3012SN/A        fatal("Out of memory, please increase size of physical memory.");
3022378SN/A    return return_addr;
3038601Ssteve.reinhardt@amd.com}
3042378SN/A
3057770SAli.Saidi@ARM.comAddr
3068601Ssteve.reinhardt@amd.comSystem::memSize()
3079007Slena@cs.wisc.edu{
3083162Ssaidi@eecs.umich.edu    return physmem->size();
3092378SN/A}
3102378SN/A
3115795Ssaidi@eecs.umich.eduAddr
3125795Ssaidi@eecs.umich.eduSystem::freeMemSize()
3138931Sandreas.hansson@arm.com{
3145795Ssaidi@eecs.umich.edu   return physmem->size() - (pagePtr << LogVMPageSize);
3158931Sandreas.hansson@arm.com}
3165795Ssaidi@eecs.umich.edu
3175795Ssaidi@eecs.umich.edubool
3185795Ssaidi@eecs.umich.eduSystem::isMemory(const Addr addr) const
3198931Sandreas.hansson@arm.com{
3205795Ssaidi@eecs.umich.edu    std::list<Range<Addr> >::const_iterator i;
3218931Sandreas.hansson@arm.com    for (i = memRanges.begin(); i != memRanges.end(); i++) {
3225795Ssaidi@eecs.umich.edu        if (*i == addr)
3235795Ssaidi@eecs.umich.edu            return true;
3248460SAli.Saidi@ARM.com    }
3258931Sandreas.hansson@arm.com    return false;
3268460SAli.Saidi@ARM.com}
3278931Sandreas.hansson@arm.com
3288460SAli.Saidi@ARM.comvoid
3298460SAli.Saidi@ARM.comSystem::resume()
3301070SN/A{
3317897Shestness@cs.utexas.edu    SimObject::resume();
3327897Shestness@cs.utexas.edu    totalNumInsts = 0;
3337897Shestness@cs.utexas.edu}
3347897Shestness@cs.utexas.edu
3357897Shestness@cs.utexas.eduvoid
3367897Shestness@cs.utexas.eduSystem::serialize(ostream &os)
3377897Shestness@cs.utexas.edu{
3381070SN/A    if (FullSystem)
3391070SN/A        kernelSymtab->serialize("kernel_symtab", os);
3408769Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(pagePtr);
3418769Sgblack@eecs.umich.edu    SERIALIZE_SCALAR(nextPID);
3427770SAli.Saidi@ARM.com}
3437770SAli.Saidi@ARM.com
3441070SN/A
3451070SN/Avoid
3461070SN/ASystem::unserialize(Checkpoint *cp, const string &section)
3471070SN/A{
3481070SN/A    if (FullSystem)
3491070SN/A        kernelSymtab->unserialize("kernel_symtab", cp, section);
3508769Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(pagePtr);
3518769Sgblack@eecs.umich.edu    UNSERIALIZE_SCALAR(nextPID);
3527770SAli.Saidi@ARM.com}
3537770SAli.Saidi@ARM.com
3541070SN/Avoid
3552SN/ASystem::regStats()
3562SN/A{
3578666SPrakash.Ramrakhyani@arm.com    for (uint32_t j = 0; j < numWorkIds ; j++) {
3588666SPrakash.Ramrakhyani@arm.com        workItemStats[j] = new Stats::Histogram();
3598666SPrakash.Ramrakhyani@arm.com        stringstream namestr;
3608666SPrakash.Ramrakhyani@arm.com        ccprintf(namestr, "work_item_type%d", j);
3618666SPrakash.Ramrakhyani@arm.com        workItemStats[j]->init(20)
3628666SPrakash.Ramrakhyani@arm.com                         .name(name() + "." + namestr.str())
3638666SPrakash.Ramrakhyani@arm.com                         .desc("Run time stat for" + namestr.str())
3648666SPrakash.Ramrakhyani@arm.com                         .prereq(*workItemStats[j]);
3658666SPrakash.Ramrakhyani@arm.com    }
3668666SPrakash.Ramrakhyani@arm.com}
3678666SPrakash.Ramrakhyani@arm.com
3688666SPrakash.Ramrakhyani@arm.comvoid
3698666SPrakash.Ramrakhyani@arm.comSystem::workItemEnd(uint32_t tid, uint32_t workid)
3708666SPrakash.Ramrakhyani@arm.com{
3718666SPrakash.Ramrakhyani@arm.com    std::pair<uint32_t,uint32_t> p(tid, workid);
3728666SPrakash.Ramrakhyani@arm.com    if (!lastWorkItemStarted.count(p))
3738666SPrakash.Ramrakhyani@arm.com        return;
3748666SPrakash.Ramrakhyani@arm.com
3758666SPrakash.Ramrakhyani@arm.com    Tick samp = curTick() - lastWorkItemStarted[p];
3768666SPrakash.Ramrakhyani@arm.com    DPRINTF(WorkItems, "Work item end: %d\t%d\t%lld\n", tid, workid, samp);
3778666SPrakash.Ramrakhyani@arm.com
3788666SPrakash.Ramrakhyani@arm.com    if (workid >= numWorkIds)
3798666SPrakash.Ramrakhyani@arm.com        fatal("Got workid greater than specified in system configuration\n");
3808666SPrakash.Ramrakhyani@arm.com
3818666SPrakash.Ramrakhyani@arm.com    workItemStats[workid]->sample(samp);
3828666SPrakash.Ramrakhyani@arm.com    lastWorkItemStarted.erase(p);
3838666SPrakash.Ramrakhyani@arm.com}
3848666SPrakash.Ramrakhyani@arm.com
3858666SPrakash.Ramrakhyani@arm.comvoid
3868666SPrakash.Ramrakhyani@arm.comSystem::printSystems()
3878666SPrakash.Ramrakhyani@arm.com{
3882SN/A    vector<System *>::iterator i = systemList.begin();
3892SN/A    vector<System *>::iterator end = systemList.end();
3902SN/A    for (; i != end; ++i) {
3912SN/A        System *sys = *i;
3922SN/A        cerr << "System " << sys->name() << ": " << hex << sys << endl;
3932SN/A    }
3942SN/A}
3952SN/A
3962SN/Avoid
3972SN/AprintSystems()
3982SN/A{
3992SN/A    System::printSystems();
4002SN/A}
4012SN/A
4022SN/Aconst char *System::MemoryModeStrings[3] = {"invalid", "atomic",
4032SN/A    "timing"};
4048832SAli.Saidi@ARM.com
4058832SAli.Saidi@ARM.comSystem *
4068832SAli.Saidi@ARM.comSystemParams::create()
4078832SAli.Saidi@ARM.com{
4089142Ssteve.reinhardt@amd.com    return new System(this);
4098832SAli.Saidi@ARM.com}
4108832SAli.Saidi@ARM.com