system.cc revision 8852
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" 542521SN/A#include "base/trace.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" 598769Sgblack@eecs.umich.edu#include "kern/kernel_stats.hh" 602522SN/A#include "mem/physical.hh" 618769Sgblack@eecs.umich.edu#include "params/System.hh" 622037SN/A#include "sim/byteswap.hh" 638229Snate@binkert.org#include "sim/debug.hh" 648769Sgblack@eecs.umich.edu#include "sim/full_system.hh" 6556SN/A#include "sim/system.hh" 666658Snate@binkert.org 672SN/Ausing namespace std; 682107SN/Ausing namespace TheISA; 692SN/A 702SN/Avector<System *> System::systemList; 712SN/A 722SN/Aint System::numSystemsRunning = 0; 732SN/A 741070SN/ASystem::System(Params *p) 758703Sandreas.hansson@arm.com : MemObject(p), _systemPort("system_port", this), 768703Sandreas.hansson@arm.com physmem(p->physmem), 778703Sandreas.hansson@arm.com _numContexts(0), 788826Snilay@cs.wisc.edu pagePtr(0), 792521SN/A init_param(p->init_param), 808852Sandreas.hansson@arm.com physProxy(_systemPort), 818852Sandreas.hansson@arm.com virtProxy(_systemPort), 827580SAli.Saidi@arm.com loadAddrMask(p->load_addr_mask), 837770SAli.Saidi@ARM.com nextPID(0), 847914SBrad.Beckmann@amd.com memoryMode(p->mem_mode), 857914SBrad.Beckmann@amd.com workItemsBegin(0), 867914SBrad.Beckmann@amd.com workItemsEnd(0), 878666SPrakash.Ramrakhyani@arm.com numWorkIds(p->num_work_ids), 887914SBrad.Beckmann@amd.com _params(p), 898666SPrakash.Ramrakhyani@arm.com totalNumInsts(0), 907897Shestness@cs.utexas.edu instEventQueue("system instruction-based event queue") 912SN/A{ 921070SN/A // add self to global system list 931070SN/A systemList.push_back(this); 941070SN/A 958460SAli.Saidi@ARM.com /** Keep track of all memories we can execute code out of 968460SAli.Saidi@ARM.com * in our system 978460SAli.Saidi@ARM.com */ 988460SAli.Saidi@ARM.com for (int x = 0; x < p->memories.size(); x++) { 998460SAli.Saidi@ARM.com if (!p->memories[x]) 1008460SAli.Saidi@ARM.com continue; 1018460SAli.Saidi@ARM.com memRanges.push_back(RangeSize(p->memories[x]->start(), 1028460SAli.Saidi@ARM.com p->memories[x]->size())); 1038460SAli.Saidi@ARM.com } 1048460SAli.Saidi@ARM.com 1058769Sgblack@eecs.umich.edu if (FullSystem) { 1068769Sgblack@eecs.umich.edu kernelSymtab = new SymbolTable; 1078769Sgblack@eecs.umich.edu if (!debugSymbolTable) 1088769Sgblack@eecs.umich.edu debugSymbolTable = new SymbolTable; 1098666SPrakash.Ramrakhyani@arm.com } 1108832SAli.Saidi@ARM.com 1118832SAli.Saidi@ARM.com // Get the generic system master IDs 1128832SAli.Saidi@ARM.com MasterID tmp_id M5_VAR_USED; 1138832SAli.Saidi@ARM.com tmp_id = getMasterId("writebacks"); 1148832SAli.Saidi@ARM.com assert(tmp_id == Request::wbMasterId); 1158832SAli.Saidi@ARM.com tmp_id = getMasterId("functional"); 1168832SAli.Saidi@ARM.com assert(tmp_id == Request::funcMasterId); 1178832SAli.Saidi@ARM.com tmp_id = getMasterId("interrupt"); 1188832SAli.Saidi@ARM.com assert(tmp_id == Request::intMasterId); 1198832SAli.Saidi@ARM.com 1202SN/A} 1212SN/A 1222SN/ASystem::~System() 1232SN/A{ 1241070SN/A delete kernelSymtab; 1251070SN/A delete kernel; 1268666SPrakash.Ramrakhyani@arm.com 1278666SPrakash.Ramrakhyani@arm.com for (uint32_t j = 0; j < numWorkIds; j++) 1288666SPrakash.Ramrakhyani@arm.com delete workItemStats[j]; 1292SN/A} 1302SN/A 1318706Sandreas.hansson@arm.comvoid 1328706Sandreas.hansson@arm.comSystem::init() 1338706Sandreas.hansson@arm.com{ 1348706Sandreas.hansson@arm.com // check that the system port is connected 1358706Sandreas.hansson@arm.com if (!_systemPort.isConnected()) 1368706Sandreas.hansson@arm.com panic("System port on %s is not connected.\n", name()); 1378706Sandreas.hansson@arm.com} 1388706Sandreas.hansson@arm.com 1398703Sandreas.hansson@arm.comPort* 1408703Sandreas.hansson@arm.comSystem::getPort(const std::string &if_name, int idx) 1418703Sandreas.hansson@arm.com{ 1428703Sandreas.hansson@arm.com // no need to distinguish at the moment (besides checking) 1438703Sandreas.hansson@arm.com return &_systemPort; 1448703Sandreas.hansson@arm.com} 1458703Sandreas.hansson@arm.com 1462901Ssaidi@eecs.umich.eduvoid 1474762Snate@binkert.orgSystem::setMemoryMode(Enums::MemoryMode mode) 1482901Ssaidi@eecs.umich.edu{ 1492901Ssaidi@eecs.umich.edu assert(getState() == Drained); 1502901Ssaidi@eecs.umich.edu memoryMode = mode; 1512901Ssaidi@eecs.umich.edu} 1522901Ssaidi@eecs.umich.edu 1533960Sgblack@eecs.umich.edubool System::breakpoint() 1543960Sgblack@eecs.umich.edu{ 1554095Sbinkertn@umich.edu if (remoteGDB.size()) 1564095Sbinkertn@umich.edu return remoteGDB[0]->breakpoint(); 1574095Sbinkertn@umich.edu return false; 1583960Sgblack@eecs.umich.edu} 1593960Sgblack@eecs.umich.edu 1607445Ssteve.reinhardt@amd.com/** 1617445Ssteve.reinhardt@amd.com * Setting rgdb_wait to a positive integer waits for a remote debugger to 1627445Ssteve.reinhardt@amd.com * connect to that context ID before continuing. This should really 1637445Ssteve.reinhardt@amd.com be a parameter on the CPU object or something... 1647445Ssteve.reinhardt@amd.com */ 1657445Ssteve.reinhardt@amd.comint rgdb_wait = -1; 1667445Ssteve.reinhardt@amd.com 167180SN/Aint 1685718Shsul@eecs.umich.eduSystem::registerThreadContext(ThreadContext *tc, int assigned) 1692SN/A{ 1705712Shsul@eecs.umich.edu int id; 1715718Shsul@eecs.umich.edu if (assigned == -1) { 1725718Shsul@eecs.umich.edu for (id = 0; id < threadContexts.size(); id++) { 1735718Shsul@eecs.umich.edu if (!threadContexts[id]) 1745718Shsul@eecs.umich.edu break; 1755718Shsul@eecs.umich.edu } 1765718Shsul@eecs.umich.edu 1775718Shsul@eecs.umich.edu if (threadContexts.size() <= id) 1785718Shsul@eecs.umich.edu threadContexts.resize(id + 1); 1795718Shsul@eecs.umich.edu } else { 1805718Shsul@eecs.umich.edu if (threadContexts.size() <= assigned) 1815718Shsul@eecs.umich.edu threadContexts.resize(assigned + 1); 1825718Shsul@eecs.umich.edu id = assigned; 1831806SN/A } 1841806SN/A 1852680Sktlim@umich.edu if (threadContexts[id]) 1865823Ssaidi@eecs.umich.edu fatal("Cannot have two CPUs with the same id (%d)\n", id); 1871806SN/A 1882680Sktlim@umich.edu threadContexts[id] = tc; 1895714Shsul@eecs.umich.edu _numContexts++; 1901070SN/A 1915512SMichael.Adler@intel.com int port = getRemoteGDBPort(); 1927445Ssteve.reinhardt@amd.com if (port) { 1934095Sbinkertn@umich.edu RemoteGDB *rgdb = new RemoteGDB(this, tc); 1945512SMichael.Adler@intel.com GDBListener *gdbl = new GDBListener(rgdb, port + id); 1954095Sbinkertn@umich.edu gdbl->listen(); 1967445Ssteve.reinhardt@amd.com 1974095Sbinkertn@umich.edu if (rgdb_wait != -1 && rgdb_wait == id) 1984095Sbinkertn@umich.edu gdbl->accept(); 1991070SN/A 2004095Sbinkertn@umich.edu if (remoteGDB.size() <= id) { 2014095Sbinkertn@umich.edu remoteGDB.resize(id + 1); 2024095Sbinkertn@umich.edu } 2034095Sbinkertn@umich.edu 2044095Sbinkertn@umich.edu remoteGDB[id] = rgdb; 2051070SN/A } 2061070SN/A 2077914SBrad.Beckmann@amd.com activeCpus.push_back(false); 2087914SBrad.Beckmann@amd.com 2091806SN/A return id; 210180SN/A} 21175SN/A 2126029Ssteve.reinhardt@amd.comint 2136029Ssteve.reinhardt@amd.comSystem::numRunningContexts() 2146029Ssteve.reinhardt@amd.com{ 2156029Ssteve.reinhardt@amd.com int running = 0; 2166029Ssteve.reinhardt@amd.com for (int i = 0; i < _numContexts; ++i) { 2176029Ssteve.reinhardt@amd.com if (threadContexts[i]->status() != ThreadContext::Halted) 2186029Ssteve.reinhardt@amd.com ++running; 2196029Ssteve.reinhardt@amd.com } 2206029Ssteve.reinhardt@amd.com return running; 2216029Ssteve.reinhardt@amd.com} 2226029Ssteve.reinhardt@amd.com 223180SN/Avoid 2247733SAli.Saidi@ARM.comSystem::initState() 2251129SN/A{ 2268806Sgblack@eecs.umich.edu int i; 2278769Sgblack@eecs.umich.edu if (FullSystem) { 2288769Sgblack@eecs.umich.edu for (i = 0; i < threadContexts.size(); i++) 2298769Sgblack@eecs.umich.edu TheISA::startupCPU(threadContexts[i], i); 2308799Sgblack@eecs.umich.edu // Moved from the constructor to here since it relies on the 2318799Sgblack@eecs.umich.edu // address map being resolved in the interconnect 2328799Sgblack@eecs.umich.edu /** 2338799Sgblack@eecs.umich.edu * Load the kernel code into memory 2348799Sgblack@eecs.umich.edu */ 2358799Sgblack@eecs.umich.edu if (params()->kernel == "") { 2368799Sgblack@eecs.umich.edu inform("No kernel set for full system simulation. " 2378799Sgblack@eecs.umich.edu "Assuming you know what you're doing...\n"); 2388799Sgblack@eecs.umich.edu } else { 2398799Sgblack@eecs.umich.edu // Load kernel code 2408799Sgblack@eecs.umich.edu kernel = createObjectFile(params()->kernel); 2418799Sgblack@eecs.umich.edu inform("kernel located at: %s", params()->kernel); 2428706Sandreas.hansson@arm.com 2438799Sgblack@eecs.umich.edu if (kernel == NULL) 2448799Sgblack@eecs.umich.edu fatal("Could not load kernel file %s", params()->kernel); 2458706Sandreas.hansson@arm.com 2468799Sgblack@eecs.umich.edu // Load program sections into memory 2478799Sgblack@eecs.umich.edu kernel->loadSections(physProxy, loadAddrMask); 2488706Sandreas.hansson@arm.com 2498799Sgblack@eecs.umich.edu // setup entry points 2508799Sgblack@eecs.umich.edu kernelStart = kernel->textBase(); 2518799Sgblack@eecs.umich.edu kernelEnd = kernel->bssBase() + kernel->bssSize(); 2528799Sgblack@eecs.umich.edu kernelEntry = kernel->entryPoint(); 2538706Sandreas.hansson@arm.com 2548799Sgblack@eecs.umich.edu // load symbols 2558799Sgblack@eecs.umich.edu if (!kernel->loadGlobalSymbols(kernelSymtab)) 2568799Sgblack@eecs.umich.edu fatal("could not load kernel symbols\n"); 2578706Sandreas.hansson@arm.com 2588799Sgblack@eecs.umich.edu if (!kernel->loadLocalSymbols(kernelSymtab)) 2598799Sgblack@eecs.umich.edu fatal("could not load kernel local symbols\n"); 2608706Sandreas.hansson@arm.com 2618799Sgblack@eecs.umich.edu if (!kernel->loadGlobalSymbols(debugSymbolTable)) 2628799Sgblack@eecs.umich.edu fatal("could not load kernel symbols\n"); 2638706Sandreas.hansson@arm.com 2648799Sgblack@eecs.umich.edu if (!kernel->loadLocalSymbols(debugSymbolTable)) 2658799Sgblack@eecs.umich.edu fatal("could not load kernel local symbols\n"); 2668706Sandreas.hansson@arm.com 2678799Sgblack@eecs.umich.edu DPRINTF(Loader, "Kernel start = %#x\n", kernelStart); 2688799Sgblack@eecs.umich.edu DPRINTF(Loader, "Kernel end = %#x\n", kernelEnd); 2698799Sgblack@eecs.umich.edu DPRINTF(Loader, "Kernel entry = %#x\n", kernelEntry); 2708799Sgblack@eecs.umich.edu DPRINTF(Loader, "Kernel loaded...\n"); 2718799Sgblack@eecs.umich.edu } 2728706Sandreas.hansson@arm.com } 2738706Sandreas.hansson@arm.com 2748706Sandreas.hansson@arm.com // increment the number of running systms 2758706Sandreas.hansson@arm.com numSystemsRunning++; 2768706Sandreas.hansson@arm.com 2778706Sandreas.hansson@arm.com activeCpus.clear(); 2788706Sandreas.hansson@arm.com 2798806Sgblack@eecs.umich.edu if (!FullSystem) 2808806Sgblack@eecs.umich.edu return; 2818806Sgblack@eecs.umich.edu 2828806Sgblack@eecs.umich.edu for (i = 0; i < threadContexts.size(); i++) 2838806Sgblack@eecs.umich.edu TheISA::startupCPU(threadContexts[i], i); 2841129SN/A} 2851129SN/A 2861129SN/Avoid 2875713Shsul@eecs.umich.eduSystem::replaceThreadContext(ThreadContext *tc, int context_id) 288180SN/A{ 2895713Shsul@eecs.umich.edu if (context_id >= threadContexts.size()) { 2902680Sktlim@umich.edu panic("replaceThreadContext: bad id, %d >= %d\n", 2915713Shsul@eecs.umich.edu context_id, threadContexts.size()); 292180SN/A } 293180SN/A 2945713Shsul@eecs.umich.edu threadContexts[context_id] = tc; 2955713Shsul@eecs.umich.edu if (context_id < remoteGDB.size()) 2965713Shsul@eecs.umich.edu remoteGDB[context_id]->replaceThreadContext(tc); 2972SN/A} 2982SN/A 2992378SN/AAddr 3008601Ssteve.reinhardt@amd.comSystem::allocPhysPages(int npages) 3012378SN/A{ 3027770SAli.Saidi@ARM.com Addr return_addr = pagePtr << LogVMPageSize; 3038601Ssteve.reinhardt@amd.com pagePtr += npages; 3048813Sgblack@eecs.umich.edu if (pagePtr > physmem->size()) 3053162Ssaidi@eecs.umich.edu fatal("Out of memory, please increase size of physical memory."); 3062378SN/A return return_addr; 3072378SN/A} 3085795Ssaidi@eecs.umich.edu 3095795Ssaidi@eecs.umich.eduAddr 3105795Ssaidi@eecs.umich.eduSystem::memSize() 3115795Ssaidi@eecs.umich.edu{ 3125795Ssaidi@eecs.umich.edu return physmem->size(); 3135795Ssaidi@eecs.umich.edu} 3145795Ssaidi@eecs.umich.edu 3155795Ssaidi@eecs.umich.eduAddr 3165795Ssaidi@eecs.umich.eduSystem::freeMemSize() 3175795Ssaidi@eecs.umich.edu{ 3187770SAli.Saidi@ARM.com return physmem->size() - (pagePtr << LogVMPageSize); 3195795Ssaidi@eecs.umich.edu} 3205795Ssaidi@eecs.umich.edu 3218460SAli.Saidi@ARM.combool 3228460SAli.Saidi@ARM.comSystem::isMemory(const Addr addr) const 3238460SAli.Saidi@ARM.com{ 3248460SAli.Saidi@ARM.com std::list<Range<Addr> >::const_iterator i; 3258460SAli.Saidi@ARM.com for (i = memRanges.begin(); i != memRanges.end(); i++) { 3268460SAli.Saidi@ARM.com if (*i == addr) 3278460SAli.Saidi@ARM.com return true; 3288460SAli.Saidi@ARM.com } 3298460SAli.Saidi@ARM.com return false; 3308460SAli.Saidi@ARM.com} 3318460SAli.Saidi@ARM.com 3321070SN/Avoid 3337897Shestness@cs.utexas.eduSystem::resume() 3347897Shestness@cs.utexas.edu{ 3357897Shestness@cs.utexas.edu SimObject::resume(); 3367897Shestness@cs.utexas.edu totalNumInsts = 0; 3377897Shestness@cs.utexas.edu} 3387897Shestness@cs.utexas.edu 3397897Shestness@cs.utexas.eduvoid 3401070SN/ASystem::serialize(ostream &os) 3411070SN/A{ 3428769Sgblack@eecs.umich.edu if (FullSystem) 3438769Sgblack@eecs.umich.edu kernelSymtab->serialize("kernel_symtab", os); 3447770SAli.Saidi@ARM.com SERIALIZE_SCALAR(pagePtr); 3457770SAli.Saidi@ARM.com SERIALIZE_SCALAR(nextPID); 3461070SN/A} 3471070SN/A 3481070SN/A 3491070SN/Avoid 3501070SN/ASystem::unserialize(Checkpoint *cp, const string §ion) 3511070SN/A{ 3528769Sgblack@eecs.umich.edu if (FullSystem) 3538769Sgblack@eecs.umich.edu kernelSymtab->unserialize("kernel_symtab", cp, section); 3547770SAli.Saidi@ARM.com UNSERIALIZE_SCALAR(pagePtr); 3557770SAli.Saidi@ARM.com UNSERIALIZE_SCALAR(nextPID); 3561070SN/A} 3572SN/A 3582SN/Avoid 3598666SPrakash.Ramrakhyani@arm.comSystem::regStats() 3608666SPrakash.Ramrakhyani@arm.com{ 3618666SPrakash.Ramrakhyani@arm.com for (uint32_t j = 0; j < numWorkIds ; j++) { 3628666SPrakash.Ramrakhyani@arm.com workItemStats[j] = new Stats::Histogram(); 3638666SPrakash.Ramrakhyani@arm.com stringstream namestr; 3648666SPrakash.Ramrakhyani@arm.com ccprintf(namestr, "work_item_type%d", j); 3658666SPrakash.Ramrakhyani@arm.com workItemStats[j]->init(20) 3668666SPrakash.Ramrakhyani@arm.com .name(name() + "." + namestr.str()) 3678666SPrakash.Ramrakhyani@arm.com .desc("Run time stat for" + namestr.str()) 3688666SPrakash.Ramrakhyani@arm.com .prereq(*workItemStats[j]); 3698666SPrakash.Ramrakhyani@arm.com } 3708666SPrakash.Ramrakhyani@arm.com} 3718666SPrakash.Ramrakhyani@arm.com 3728666SPrakash.Ramrakhyani@arm.comvoid 3738666SPrakash.Ramrakhyani@arm.comSystem::workItemEnd(uint32_t tid, uint32_t workid) 3748666SPrakash.Ramrakhyani@arm.com{ 3758666SPrakash.Ramrakhyani@arm.com std::pair<uint32_t,uint32_t> p(tid, workid); 3768666SPrakash.Ramrakhyani@arm.com if (!lastWorkItemStarted.count(p)) 3778666SPrakash.Ramrakhyani@arm.com return; 3788666SPrakash.Ramrakhyani@arm.com 3798666SPrakash.Ramrakhyani@arm.com Tick samp = curTick() - lastWorkItemStarted[p]; 3808666SPrakash.Ramrakhyani@arm.com DPRINTF(WorkItems, "Work item end: %d\t%d\t%lld\n", tid, workid, samp); 3818666SPrakash.Ramrakhyani@arm.com 3828666SPrakash.Ramrakhyani@arm.com if (workid >= numWorkIds) 3838666SPrakash.Ramrakhyani@arm.com fatal("Got workid greater than specified in system configuration\n"); 3848666SPrakash.Ramrakhyani@arm.com 3858666SPrakash.Ramrakhyani@arm.com workItemStats[workid]->sample(samp); 3868666SPrakash.Ramrakhyani@arm.com lastWorkItemStarted.erase(p); 3878666SPrakash.Ramrakhyani@arm.com} 3888666SPrakash.Ramrakhyani@arm.com 3898666SPrakash.Ramrakhyani@arm.comvoid 3902SN/ASystem::printSystems() 3912SN/A{ 3922SN/A vector<System *>::iterator i = systemList.begin(); 3932SN/A vector<System *>::iterator end = systemList.end(); 3942SN/A for (; i != end; ++i) { 3952SN/A System *sys = *i; 3962SN/A cerr << "System " << sys->name() << ": " << hex << sys << endl; 3972SN/A } 3982SN/A} 3992SN/A 4002SN/Avoid 4012SN/AprintSystems() 4022SN/A{ 4032SN/A System::printSystems(); 4042SN/A} 4052SN/A 4068832SAli.Saidi@ARM.comMasterID 4078832SAli.Saidi@ARM.comSystem::getMasterId(std::string master_name) 4088832SAli.Saidi@ARM.com{ 4098832SAli.Saidi@ARM.com // strip off system name if the string starts with it 4108832SAli.Saidi@ARM.com if (master_name.size() > name().size() && 4118832SAli.Saidi@ARM.com master_name.compare(0, name().size(), name()) == 0) 4128832SAli.Saidi@ARM.com master_name = master_name.erase(0, name().size() + 1); 4138832SAli.Saidi@ARM.com 4148832SAli.Saidi@ARM.com // CPUs in switch_cpus ask for ids again after switching 4158832SAli.Saidi@ARM.com for (int i = 0; i < masterIds.size(); i++) { 4168832SAli.Saidi@ARM.com if (masterIds[i] == master_name) { 4178832SAli.Saidi@ARM.com return i; 4188832SAli.Saidi@ARM.com } 4198832SAli.Saidi@ARM.com } 4208832SAli.Saidi@ARM.com 4218832SAli.Saidi@ARM.com // todo: Check if stats are enabled yet 4228832SAli.Saidi@ARM.com // I just don't know a good way to do it 4238832SAli.Saidi@ARM.com 4248832SAli.Saidi@ARM.com if (false) 4258832SAli.Saidi@ARM.com fatal("Can't request a masterId after regStats(). \ 4268832SAli.Saidi@ARM.com You must do so in init().\n"); 4278832SAli.Saidi@ARM.com 4288832SAli.Saidi@ARM.com masterIds.push_back(master_name); 4298832SAli.Saidi@ARM.com 4308832SAli.Saidi@ARM.com return masterIds.size() - 1; 4318832SAli.Saidi@ARM.com} 4328832SAli.Saidi@ARM.com 4338832SAli.Saidi@ARM.comstd::string 4348832SAli.Saidi@ARM.comSystem::getMasterName(MasterID master_id) 4358832SAli.Saidi@ARM.com{ 4368832SAli.Saidi@ARM.com if (master_id >= masterIds.size()) 4378832SAli.Saidi@ARM.com fatal("Invalid master_id passed to getMasterName()\n"); 4388832SAli.Saidi@ARM.com 4398832SAli.Saidi@ARM.com return masterIds[master_id]; 4408832SAli.Saidi@ARM.com} 4418832SAli.Saidi@ARM.com 4422902Ssaidi@eecs.umich.educonst char *System::MemoryModeStrings[3] = {"invalid", "atomic", 4432902Ssaidi@eecs.umich.edu "timing"}; 4442902Ssaidi@eecs.umich.edu 4454762Snate@binkert.orgSystem * 4464762Snate@binkert.orgSystemParams::create() 4472424SN/A{ 4485530Snate@binkert.org return new System(this); 4492424SN/A} 450