system.cc revision 8706
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"
511070SN/A#include "base/loader/object_file.hh"
521070SN/A#include "base/loader/symtab.hh"
532521SN/A#include "base/trace.hh"
546658Snate@binkert.org#include "config/full_system.hh"
556658Snate@binkert.org#include "config/the_isa.hh"
568229Snate@binkert.org#include "cpu/thread_context.hh"
578232Snate@binkert.org#include "debug/Loader.hh"
588666SPrakash.Ramrakhyani@arm.com#include "debug/WorkItems.hh"
592521SN/A#include "mem/mem_object.hh"
602522SN/A#include "mem/physical.hh"
612037SN/A#include "sim/byteswap.hh"
628229Snate@binkert.org#include "sim/debug.hh"
6356SN/A#include "sim/system.hh"
646658Snate@binkert.org
652378SN/A#if FULL_SYSTEM
662521SN/A#include "arch/vtophys.hh"
672378SN/A#include "kern/kernel_stats.hh"
688706Sandreas.hansson@arm.com#include "mem/fs_translating_port_proxy.hh"
694762Snate@binkert.org#else
704762Snate@binkert.org#include "params/System.hh"
712378SN/A#endif
722SN/A
732SN/Ausing namespace std;
742107SN/Ausing namespace TheISA;
752SN/A
762SN/Avector<System *> System::systemList;
772SN/A
782SN/Aint System::numSystemsRunning = 0;
792SN/A
801070SN/ASystem::System(Params *p)
818703Sandreas.hansson@arm.com    : MemObject(p), _systemPort("system_port", this),
828703Sandreas.hansson@arm.com      physmem(p->physmem),
838703Sandreas.hansson@arm.com      _numContexts(0),
842378SN/A#if FULL_SYSTEM
852521SN/A      init_param(p->init_param),
867580SAli.Saidi@arm.com      loadAddrMask(p->load_addr_mask),
872378SN/A#else
887770SAli.Saidi@ARM.com      pagePtr(0),
897770SAli.Saidi@ARM.com      nextPID(0),
902378SN/A#endif
917914SBrad.Beckmann@amd.com      memoryMode(p->mem_mode),
927914SBrad.Beckmann@amd.com      workItemsBegin(0),
937914SBrad.Beckmann@amd.com      workItemsEnd(0),
948666SPrakash.Ramrakhyani@arm.com      numWorkIds(p->num_work_ids),
957914SBrad.Beckmann@amd.com      _params(p),
968666SPrakash.Ramrakhyani@arm.com      totalNumInsts(0),
977897Shestness@cs.utexas.edu      instEventQueue("system instruction-based event queue")
982SN/A{
991070SN/A    // add self to global system list
1001070SN/A    systemList.push_back(this);
1011070SN/A
1028460SAli.Saidi@ARM.com    /** Keep track of all memories we can execute code out of
1038460SAli.Saidi@ARM.com     * in our system
1048460SAli.Saidi@ARM.com     */
1058460SAli.Saidi@ARM.com    for (int x = 0; x < p->memories.size(); x++) {
1068460SAli.Saidi@ARM.com        if (!p->memories[x])
1078460SAli.Saidi@ARM.com            continue;
1088460SAli.Saidi@ARM.com        memRanges.push_back(RangeSize(p->memories[x]->start(),
1098460SAli.Saidi@ARM.com                                      p->memories[x]->size()));
1108460SAli.Saidi@ARM.com    }
1118460SAli.Saidi@ARM.com
1122378SN/A#if FULL_SYSTEM
1131070SN/A    kernelSymtab = new SymbolTable;
1144838Ssaidi@eecs.umich.edu    if (!debugSymbolTable)
1154838Ssaidi@eecs.umich.edu        debugSymbolTable = new SymbolTable;
1161070SN/A
1172520SN/A    /**
1188706Sandreas.hansson@arm.com     * Get a port proxy to memory
1192520SN/A     */
1208706Sandreas.hansson@arm.com    physProxy = new PortProxy(*getSystemPort());
1218706Sandreas.hansson@arm.com    virtProxy = new FSTranslatingPortProxy(*getSystemPort());
1228706Sandreas.hansson@arm.com#endif
1232SN/A}
1242SN/A
1252SN/ASystem::~System()
1262SN/A{
1272378SN/A#if FULL_SYSTEM
1281070SN/A    delete kernelSymtab;
1291070SN/A    delete kernel;
1302378SN/A#else
1312378SN/A    panic("System::fixFuncEventAddr needs to be rewritten "
1322378SN/A          "to work with syscall emulation");
1332378SN/A#endif // FULL_SYSTEM}
1348666SPrakash.Ramrakhyani@arm.com
1358666SPrakash.Ramrakhyani@arm.com    for (uint32_t j = 0; j < numWorkIds; j++)
1368666SPrakash.Ramrakhyani@arm.com        delete workItemStats[j];
1372SN/A}
1382SN/A
1398706Sandreas.hansson@arm.comvoid
1408706Sandreas.hansson@arm.comSystem::init()
1418706Sandreas.hansson@arm.com{
1428706Sandreas.hansson@arm.com    // check that the system port is connected
1438706Sandreas.hansson@arm.com    if (!_systemPort.isConnected())
1448706Sandreas.hansson@arm.com        panic("System port on %s is not connected.\n", name());
1458706Sandreas.hansson@arm.com}
1468706Sandreas.hansson@arm.com
1478703Sandreas.hansson@arm.comPort*
1488703Sandreas.hansson@arm.comSystem::getPort(const std::string &if_name, int idx)
1498703Sandreas.hansson@arm.com{
1508703Sandreas.hansson@arm.com    // no need to distinguish at the moment (besides checking)
1518703Sandreas.hansson@arm.com    return &_systemPort;
1528703Sandreas.hansson@arm.com}
1538703Sandreas.hansson@arm.com
1542901Ssaidi@eecs.umich.eduvoid
1554762Snate@binkert.orgSystem::setMemoryMode(Enums::MemoryMode mode)
1562901Ssaidi@eecs.umich.edu{
1572901Ssaidi@eecs.umich.edu    assert(getState() == Drained);
1582901Ssaidi@eecs.umich.edu    memoryMode = mode;
1592901Ssaidi@eecs.umich.edu}
1602901Ssaidi@eecs.umich.edu
1613960Sgblack@eecs.umich.edubool System::breakpoint()
1623960Sgblack@eecs.umich.edu{
1634095Sbinkertn@umich.edu    if (remoteGDB.size())
1644095Sbinkertn@umich.edu        return remoteGDB[0]->breakpoint();
1654095Sbinkertn@umich.edu    return false;
1663960Sgblack@eecs.umich.edu}
1673960Sgblack@eecs.umich.edu
1687445Ssteve.reinhardt@amd.com/**
1697445Ssteve.reinhardt@amd.com * Setting rgdb_wait to a positive integer waits for a remote debugger to
1707445Ssteve.reinhardt@amd.com * connect to that context ID before continuing.  This should really
1717445Ssteve.reinhardt@amd.com   be a parameter on the CPU object or something...
1727445Ssteve.reinhardt@amd.com */
1737445Ssteve.reinhardt@amd.comint rgdb_wait = -1;
1747445Ssteve.reinhardt@amd.com
175180SN/Aint
1765718Shsul@eecs.umich.eduSystem::registerThreadContext(ThreadContext *tc, int assigned)
1772SN/A{
1785712Shsul@eecs.umich.edu    int id;
1795718Shsul@eecs.umich.edu    if (assigned == -1) {
1805718Shsul@eecs.umich.edu        for (id = 0; id < threadContexts.size(); id++) {
1815718Shsul@eecs.umich.edu            if (!threadContexts[id])
1825718Shsul@eecs.umich.edu                break;
1835718Shsul@eecs.umich.edu        }
1845718Shsul@eecs.umich.edu
1855718Shsul@eecs.umich.edu        if (threadContexts.size() <= id)
1865718Shsul@eecs.umich.edu            threadContexts.resize(id + 1);
1875718Shsul@eecs.umich.edu    } else {
1885718Shsul@eecs.umich.edu        if (threadContexts.size() <= assigned)
1895718Shsul@eecs.umich.edu            threadContexts.resize(assigned + 1);
1905718Shsul@eecs.umich.edu        id = assigned;
1911806SN/A    }
1921806SN/A
1932680Sktlim@umich.edu    if (threadContexts[id])
1945823Ssaidi@eecs.umich.edu        fatal("Cannot have two CPUs with the same id (%d)\n", id);
1951806SN/A
1962680Sktlim@umich.edu    threadContexts[id] = tc;
1975714Shsul@eecs.umich.edu    _numContexts++;
1981070SN/A
1995512SMichael.Adler@intel.com    int port = getRemoteGDBPort();
2007445Ssteve.reinhardt@amd.com    if (port) {
2014095Sbinkertn@umich.edu        RemoteGDB *rgdb = new RemoteGDB(this, tc);
2025512SMichael.Adler@intel.com        GDBListener *gdbl = new GDBListener(rgdb, port + id);
2034095Sbinkertn@umich.edu        gdbl->listen();
2047445Ssteve.reinhardt@amd.com
2054095Sbinkertn@umich.edu        if (rgdb_wait != -1 && rgdb_wait == id)
2064095Sbinkertn@umich.edu            gdbl->accept();
2071070SN/A
2084095Sbinkertn@umich.edu        if (remoteGDB.size() <= id) {
2094095Sbinkertn@umich.edu            remoteGDB.resize(id + 1);
2104095Sbinkertn@umich.edu        }
2114095Sbinkertn@umich.edu
2124095Sbinkertn@umich.edu        remoteGDB[id] = rgdb;
2131070SN/A    }
2141070SN/A
2157914SBrad.Beckmann@amd.com    activeCpus.push_back(false);
2167914SBrad.Beckmann@amd.com
2171806SN/A    return id;
218180SN/A}
21975SN/A
2206029Ssteve.reinhardt@amd.comint
2216029Ssteve.reinhardt@amd.comSystem::numRunningContexts()
2226029Ssteve.reinhardt@amd.com{
2236029Ssteve.reinhardt@amd.com    int running = 0;
2246029Ssteve.reinhardt@amd.com    for (int i = 0; i < _numContexts; ++i) {
2256029Ssteve.reinhardt@amd.com        if (threadContexts[i]->status() != ThreadContext::Halted)
2266029Ssteve.reinhardt@amd.com            ++running;
2276029Ssteve.reinhardt@amd.com    }
2286029Ssteve.reinhardt@amd.com    return running;
2296029Ssteve.reinhardt@amd.com}
2306029Ssteve.reinhardt@amd.com
231180SN/Avoid
2327733SAli.Saidi@ARM.comSystem::initState()
2331129SN/A{
2348706Sandreas.hansson@arm.com    // Moved from the constructor to here since it relies on the
2358706Sandreas.hansson@arm.com    // address map being resolved in the interconnect
2368706Sandreas.hansson@arm.com#if FULL_SYSTEM
2378706Sandreas.hansson@arm.com    /**
2388706Sandreas.hansson@arm.com     * Load the kernel code into memory
2398706Sandreas.hansson@arm.com     */
2408706Sandreas.hansson@arm.com    if (params()->kernel == "") {
2418706Sandreas.hansson@arm.com        inform("No kernel set for full system simulation. Assuming you know what"
2428706Sandreas.hansson@arm.com                " you're doing...\n");
2438706Sandreas.hansson@arm.com    } else {
2448706Sandreas.hansson@arm.com        // Load kernel code
2458706Sandreas.hansson@arm.com        kernel = createObjectFile(params()->kernel);
2468706Sandreas.hansson@arm.com        inform("kernel located at: %s", params()->kernel);
2478706Sandreas.hansson@arm.com
2488706Sandreas.hansson@arm.com        if (kernel == NULL)
2498706Sandreas.hansson@arm.com            fatal("Could not load kernel file %s", params()->kernel);
2508706Sandreas.hansson@arm.com
2518706Sandreas.hansson@arm.com        // Load program sections into memory
2528706Sandreas.hansson@arm.com        kernel->loadSections(physProxy, loadAddrMask);
2538706Sandreas.hansson@arm.com
2548706Sandreas.hansson@arm.com        // setup entry points
2558706Sandreas.hansson@arm.com        kernelStart = kernel->textBase();
2568706Sandreas.hansson@arm.com        kernelEnd = kernel->bssBase() + kernel->bssSize();
2578706Sandreas.hansson@arm.com        kernelEntry = kernel->entryPoint();
2588706Sandreas.hansson@arm.com
2598706Sandreas.hansson@arm.com        // load symbols
2608706Sandreas.hansson@arm.com        if (!kernel->loadGlobalSymbols(kernelSymtab))
2618706Sandreas.hansson@arm.com            fatal("could not load kernel symbols\n");
2628706Sandreas.hansson@arm.com
2638706Sandreas.hansson@arm.com        if (!kernel->loadLocalSymbols(kernelSymtab))
2648706Sandreas.hansson@arm.com            fatal("could not load kernel local symbols\n");
2658706Sandreas.hansson@arm.com
2668706Sandreas.hansson@arm.com        if (!kernel->loadGlobalSymbols(debugSymbolTable))
2678706Sandreas.hansson@arm.com            fatal("could not load kernel symbols\n");
2688706Sandreas.hansson@arm.com
2698706Sandreas.hansson@arm.com        if (!kernel->loadLocalSymbols(debugSymbolTable))
2708706Sandreas.hansson@arm.com            fatal("could not load kernel local symbols\n");
2718706Sandreas.hansson@arm.com
2728706Sandreas.hansson@arm.com        DPRINTF(Loader, "Kernel start = %#x\n", kernelStart);
2738706Sandreas.hansson@arm.com        DPRINTF(Loader, "Kernel end   = %#x\n", kernelEnd);
2748706Sandreas.hansson@arm.com        DPRINTF(Loader, "Kernel entry = %#x\n", kernelEntry);
2758706Sandreas.hansson@arm.com        DPRINTF(Loader, "Kernel loaded...\n");
2768706Sandreas.hansson@arm.com    }
2778706Sandreas.hansson@arm.com#endif // FULL_SYSTEM
2788706Sandreas.hansson@arm.com
2798706Sandreas.hansson@arm.com    // increment the number of running systms
2808706Sandreas.hansson@arm.com    numSystemsRunning++;
2818706Sandreas.hansson@arm.com
2828706Sandreas.hansson@arm.com    activeCpus.clear();
2838706Sandreas.hansson@arm.com
2845713Shsul@eecs.umich.edu#if FULL_SYSTEM
2852114SN/A    int i;
2862680Sktlim@umich.edu    for (i = 0; i < threadContexts.size(); i++)
2874194Ssaidi@eecs.umich.edu        TheISA::startupCPU(threadContexts[i], i);
2885713Shsul@eecs.umich.edu#endif
2891129SN/A}
2901129SN/A
2911129SN/Avoid
2925713Shsul@eecs.umich.eduSystem::replaceThreadContext(ThreadContext *tc, int context_id)
293180SN/A{
2945713Shsul@eecs.umich.edu    if (context_id >= threadContexts.size()) {
2952680Sktlim@umich.edu        panic("replaceThreadContext: bad id, %d >= %d\n",
2965713Shsul@eecs.umich.edu              context_id, threadContexts.size());
297180SN/A    }
298180SN/A
2995713Shsul@eecs.umich.edu    threadContexts[context_id] = tc;
3005713Shsul@eecs.umich.edu    if (context_id < remoteGDB.size())
3015713Shsul@eecs.umich.edu        remoteGDB[context_id]->replaceThreadContext(tc);
3022SN/A}
3032SN/A
3042378SN/A#if !FULL_SYSTEM
3052378SN/AAddr
3068601Ssteve.reinhardt@amd.comSystem::allocPhysPages(int npages)
3072378SN/A{
3087770SAli.Saidi@ARM.com    Addr return_addr = pagePtr << LogVMPageSize;
3098601Ssteve.reinhardt@amd.com    pagePtr += npages;
3103162Ssaidi@eecs.umich.edu    if (return_addr >= physmem->size())
3113162Ssaidi@eecs.umich.edu        fatal("Out of memory, please increase size of physical memory.");
3122378SN/A    return return_addr;
3132378SN/A}
3145795Ssaidi@eecs.umich.edu
3155795Ssaidi@eecs.umich.eduAddr
3165795Ssaidi@eecs.umich.eduSystem::memSize()
3175795Ssaidi@eecs.umich.edu{
3185795Ssaidi@eecs.umich.edu    return physmem->size();
3195795Ssaidi@eecs.umich.edu}
3205795Ssaidi@eecs.umich.edu
3215795Ssaidi@eecs.umich.eduAddr
3225795Ssaidi@eecs.umich.eduSystem::freeMemSize()
3235795Ssaidi@eecs.umich.edu{
3247770SAli.Saidi@ARM.com   return physmem->size() - (pagePtr << LogVMPageSize);
3255795Ssaidi@eecs.umich.edu}
3265795Ssaidi@eecs.umich.edu
3272378SN/A#endif
3282378SN/A
3298460SAli.Saidi@ARM.combool
3308460SAli.Saidi@ARM.comSystem::isMemory(const Addr addr) const
3318460SAli.Saidi@ARM.com{
3328460SAli.Saidi@ARM.com    std::list<Range<Addr> >::const_iterator i;
3338460SAli.Saidi@ARM.com    for (i = memRanges.begin(); i != memRanges.end(); i++) {
3348460SAli.Saidi@ARM.com        if (*i == addr)
3358460SAli.Saidi@ARM.com            return true;
3368460SAli.Saidi@ARM.com    }
3378460SAli.Saidi@ARM.com    return false;
3388460SAli.Saidi@ARM.com}
3398460SAli.Saidi@ARM.com
3401070SN/Avoid
3417897Shestness@cs.utexas.eduSystem::resume()
3427897Shestness@cs.utexas.edu{
3437897Shestness@cs.utexas.edu    SimObject::resume();
3447897Shestness@cs.utexas.edu    totalNumInsts = 0;
3457897Shestness@cs.utexas.edu}
3467897Shestness@cs.utexas.edu
3477897Shestness@cs.utexas.eduvoid
3481070SN/ASystem::serialize(ostream &os)
3491070SN/A{
3502378SN/A#if FULL_SYSTEM
3511984SN/A    kernelSymtab->serialize("kernel_symtab", os);
3525183Ssaidi@eecs.umich.edu#else // !FULL_SYSTEM
3537770SAli.Saidi@ARM.com    SERIALIZE_SCALAR(pagePtr);
3547770SAli.Saidi@ARM.com    SERIALIZE_SCALAR(nextPID);
3555183Ssaidi@eecs.umich.edu#endif
3561070SN/A}
3571070SN/A
3581070SN/A
3591070SN/Avoid
3601070SN/ASystem::unserialize(Checkpoint *cp, const string &section)
3611070SN/A{
3622378SN/A#if FULL_SYSTEM
3631984SN/A    kernelSymtab->unserialize("kernel_symtab", cp, section);
3645183Ssaidi@eecs.umich.edu#else // !FULL_SYSTEM
3657770SAli.Saidi@ARM.com    UNSERIALIZE_SCALAR(pagePtr);
3667770SAli.Saidi@ARM.com    UNSERIALIZE_SCALAR(nextPID);
3675183Ssaidi@eecs.umich.edu#endif
3681070SN/A}
3692SN/A
3702SN/Avoid
3718666SPrakash.Ramrakhyani@arm.comSystem::regStats()
3728666SPrakash.Ramrakhyani@arm.com{
3738666SPrakash.Ramrakhyani@arm.com    for (uint32_t j = 0; j < numWorkIds ; j++) {
3748666SPrakash.Ramrakhyani@arm.com        workItemStats[j] = new Stats::Histogram();
3758666SPrakash.Ramrakhyani@arm.com        stringstream namestr;
3768666SPrakash.Ramrakhyani@arm.com        ccprintf(namestr, "work_item_type%d", j);
3778666SPrakash.Ramrakhyani@arm.com        workItemStats[j]->init(20)
3788666SPrakash.Ramrakhyani@arm.com                         .name(name() + "." + namestr.str())
3798666SPrakash.Ramrakhyani@arm.com                         .desc("Run time stat for" + namestr.str())
3808666SPrakash.Ramrakhyani@arm.com                         .prereq(*workItemStats[j]);
3818666SPrakash.Ramrakhyani@arm.com    }
3828666SPrakash.Ramrakhyani@arm.com}
3838666SPrakash.Ramrakhyani@arm.com
3848666SPrakash.Ramrakhyani@arm.comvoid
3858666SPrakash.Ramrakhyani@arm.comSystem::workItemEnd(uint32_t tid, uint32_t workid)
3868666SPrakash.Ramrakhyani@arm.com{
3878666SPrakash.Ramrakhyani@arm.com    std::pair<uint32_t,uint32_t> p(tid, workid);
3888666SPrakash.Ramrakhyani@arm.com    if (!lastWorkItemStarted.count(p))
3898666SPrakash.Ramrakhyani@arm.com        return;
3908666SPrakash.Ramrakhyani@arm.com
3918666SPrakash.Ramrakhyani@arm.com    Tick samp = curTick() - lastWorkItemStarted[p];
3928666SPrakash.Ramrakhyani@arm.com    DPRINTF(WorkItems, "Work item end: %d\t%d\t%lld\n", tid, workid, samp);
3938666SPrakash.Ramrakhyani@arm.com
3948666SPrakash.Ramrakhyani@arm.com    if (workid >= numWorkIds)
3958666SPrakash.Ramrakhyani@arm.com        fatal("Got workid greater than specified in system configuration\n");
3968666SPrakash.Ramrakhyani@arm.com
3978666SPrakash.Ramrakhyani@arm.com    workItemStats[workid]->sample(samp);
3988666SPrakash.Ramrakhyani@arm.com    lastWorkItemStarted.erase(p);
3998666SPrakash.Ramrakhyani@arm.com}
4008666SPrakash.Ramrakhyani@arm.com
4018666SPrakash.Ramrakhyani@arm.comvoid
4022SN/ASystem::printSystems()
4032SN/A{
4042SN/A    vector<System *>::iterator i = systemList.begin();
4052SN/A    vector<System *>::iterator end = systemList.end();
4062SN/A    for (; i != end; ++i) {
4072SN/A        System *sys = *i;
4082SN/A        cerr << "System " << sys->name() << ": " << hex << sys << endl;
4092SN/A    }
4102SN/A}
4112SN/A
4122SN/Avoid
4132SN/AprintSystems()
4142SN/A{
4152SN/A    System::printSystems();
4162SN/A}
4172SN/A
4182902Ssaidi@eecs.umich.educonst char *System::MemoryModeStrings[3] = {"invalid", "atomic",
4192902Ssaidi@eecs.umich.edu    "timing"};
4202902Ssaidi@eecs.umich.edu
4214762Snate@binkert.org#if !FULL_SYSTEM
4222424SN/A
4234762Snate@binkert.orgSystem *
4244762Snate@binkert.orgSystemParams::create()
4252424SN/A{
4265530Snate@binkert.org    return new System(this);
4272424SN/A}
4282424SN/A
4292424SN/A#endif
430