system.cc revision 9142
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/str.hh" 552521SN/A#include "base/trace.hh" 566658Snate@binkert.org#include "config/the_isa.hh" 578229Snate@binkert.org#include "cpu/thread_context.hh" 588232Snate@binkert.org#include "debug/Loader.hh" 598666SPrakash.Ramrakhyani@arm.com#include "debug/WorkItems.hh" 608769Sgblack@eecs.umich.edu#include "kern/kernel_stats.hh" 612522SN/A#include "mem/physical.hh" 628769Sgblack@eecs.umich.edu#include "params/System.hh" 632037SN/A#include "sim/byteswap.hh" 648229Snate@binkert.org#include "sim/debug.hh" 658769Sgblack@eecs.umich.edu#include "sim/full_system.hh" 6656SN/A#include "sim/system.hh" 676658Snate@binkert.org 682SN/Ausing namespace std; 692107SN/Ausing namespace TheISA; 702SN/A 712SN/Avector<System *> System::systemList; 722SN/A 732SN/Aint System::numSystemsRunning = 0; 742SN/A 751070SN/ASystem::System(Params *p) 768703Sandreas.hansson@arm.com : MemObject(p), _systemPort("system_port", this), 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), 848931Sandreas.hansson@arm.com physmem(p->memories), 857914SBrad.Beckmann@amd.com memoryMode(p->mem_mode), 867914SBrad.Beckmann@amd.com workItemsBegin(0), 877914SBrad.Beckmann@amd.com workItemsEnd(0), 888666SPrakash.Ramrakhyani@arm.com numWorkIds(p->num_work_ids), 897914SBrad.Beckmann@amd.com _params(p), 908666SPrakash.Ramrakhyani@arm.com totalNumInsts(0), 917897Shestness@cs.utexas.edu instEventQueue("system instruction-based event queue") 922SN/A{ 931070SN/A // add self to global system list 941070SN/A systemList.push_back(this); 951070SN/A 968769Sgblack@eecs.umich.edu if (FullSystem) { 978769Sgblack@eecs.umich.edu kernelSymtab = new SymbolTable; 988769Sgblack@eecs.umich.edu if (!debugSymbolTable) 998769Sgblack@eecs.umich.edu debugSymbolTable = new SymbolTable; 1008666SPrakash.Ramrakhyani@arm.com } 1018832SAli.Saidi@ARM.com 1028832SAli.Saidi@ARM.com // Get the generic system master IDs 1038832SAli.Saidi@ARM.com MasterID tmp_id M5_VAR_USED; 1048832SAli.Saidi@ARM.com tmp_id = getMasterId("writebacks"); 1058832SAli.Saidi@ARM.com assert(tmp_id == Request::wbMasterId); 1068832SAli.Saidi@ARM.com tmp_id = getMasterId("functional"); 1078832SAli.Saidi@ARM.com assert(tmp_id == Request::funcMasterId); 1088832SAli.Saidi@ARM.com tmp_id = getMasterId("interrupt"); 1098832SAli.Saidi@ARM.com assert(tmp_id == Request::intMasterId); 1108832SAli.Saidi@ARM.com 1118885SAli.Saidi@ARM.com if (FullSystem) { 1128885SAli.Saidi@ARM.com if (params()->kernel == "") { 1138885SAli.Saidi@ARM.com inform("No kernel set for full system simulation. " 1148885SAli.Saidi@ARM.com "Assuming you know what you're doing if not SPARC ISA\n"); 1158885SAli.Saidi@ARM.com } else { 1168885SAli.Saidi@ARM.com // Get the kernel code 1178885SAli.Saidi@ARM.com kernel = createObjectFile(params()->kernel); 1188885SAli.Saidi@ARM.com inform("kernel located at: %s", params()->kernel); 1198885SAli.Saidi@ARM.com 1208885SAli.Saidi@ARM.com if (kernel == NULL) 1218885SAli.Saidi@ARM.com fatal("Could not load kernel file %s", params()->kernel); 1228885SAli.Saidi@ARM.com 1238885SAli.Saidi@ARM.com // setup entry points 1248885SAli.Saidi@ARM.com kernelStart = kernel->textBase(); 1258885SAli.Saidi@ARM.com kernelEnd = kernel->bssBase() + kernel->bssSize(); 1268885SAli.Saidi@ARM.com kernelEntry = kernel->entryPoint(); 1278885SAli.Saidi@ARM.com 1288885SAli.Saidi@ARM.com // load symbols 1298885SAli.Saidi@ARM.com if (!kernel->loadGlobalSymbols(kernelSymtab)) 1308885SAli.Saidi@ARM.com fatal("could not load kernel symbols\n"); 1318885SAli.Saidi@ARM.com 1328885SAli.Saidi@ARM.com if (!kernel->loadLocalSymbols(kernelSymtab)) 1338885SAli.Saidi@ARM.com fatal("could not load kernel local symbols\n"); 1348885SAli.Saidi@ARM.com 1358885SAli.Saidi@ARM.com if (!kernel->loadGlobalSymbols(debugSymbolTable)) 1368885SAli.Saidi@ARM.com fatal("could not load kernel symbols\n"); 1378885SAli.Saidi@ARM.com 1388885SAli.Saidi@ARM.com if (!kernel->loadLocalSymbols(debugSymbolTable)) 1398885SAli.Saidi@ARM.com fatal("could not load kernel local symbols\n"); 1408885SAli.Saidi@ARM.com 1418885SAli.Saidi@ARM.com // Loading only needs to happen once and after memory system is 1428885SAli.Saidi@ARM.com // connected so it will happen in initState() 1438885SAli.Saidi@ARM.com } 1448885SAli.Saidi@ARM.com } 1458885SAli.Saidi@ARM.com 1468885SAli.Saidi@ARM.com // increment the number of running systms 1478885SAli.Saidi@ARM.com numSystemsRunning++; 1488885SAli.Saidi@ARM.com 1499053Sdam.sunwoo@arm.com // Set back pointers to the system in all memories 1509053Sdam.sunwoo@arm.com for (int x = 0; x < params()->memories.size(); x++) 1519053Sdam.sunwoo@arm.com params()->memories[x]->system(this); 1522SN/A} 1532SN/A 1542SN/ASystem::~System() 1552SN/A{ 1561070SN/A delete kernelSymtab; 1571070SN/A delete kernel; 1588666SPrakash.Ramrakhyani@arm.com 1598666SPrakash.Ramrakhyani@arm.com for (uint32_t j = 0; j < numWorkIds; j++) 1608666SPrakash.Ramrakhyani@arm.com delete workItemStats[j]; 1612SN/A} 1622SN/A 1638706Sandreas.hansson@arm.comvoid 1648706Sandreas.hansson@arm.comSystem::init() 1658706Sandreas.hansson@arm.com{ 1668706Sandreas.hansson@arm.com // check that the system port is connected 1678706Sandreas.hansson@arm.com if (!_systemPort.isConnected()) 1688706Sandreas.hansson@arm.com panic("System port on %s is not connected.\n", name()); 1698706Sandreas.hansson@arm.com} 1708706Sandreas.hansson@arm.com 1718922Swilliam.wang@arm.comMasterPort& 1728922Swilliam.wang@arm.comSystem::getMasterPort(const std::string &if_name, int idx) 1738703Sandreas.hansson@arm.com{ 1748703Sandreas.hansson@arm.com // no need to distinguish at the moment (besides checking) 1758922Swilliam.wang@arm.com return _systemPort; 1768703Sandreas.hansson@arm.com} 1778703Sandreas.hansson@arm.com 1782901Ssaidi@eecs.umich.eduvoid 1794762Snate@binkert.orgSystem::setMemoryMode(Enums::MemoryMode mode) 1802901Ssaidi@eecs.umich.edu{ 1812901Ssaidi@eecs.umich.edu assert(getState() == Drained); 1822901Ssaidi@eecs.umich.edu memoryMode = mode; 1832901Ssaidi@eecs.umich.edu} 1842901Ssaidi@eecs.umich.edu 1853960Sgblack@eecs.umich.edubool System::breakpoint() 1863960Sgblack@eecs.umich.edu{ 1874095Sbinkertn@umich.edu if (remoteGDB.size()) 1884095Sbinkertn@umich.edu return remoteGDB[0]->breakpoint(); 1894095Sbinkertn@umich.edu return false; 1903960Sgblack@eecs.umich.edu} 1913960Sgblack@eecs.umich.edu 1927445Ssteve.reinhardt@amd.com/** 1937445Ssteve.reinhardt@amd.com * Setting rgdb_wait to a positive integer waits for a remote debugger to 1947445Ssteve.reinhardt@amd.com * connect to that context ID before continuing. This should really 1957445Ssteve.reinhardt@amd.com be a parameter on the CPU object or something... 1967445Ssteve.reinhardt@amd.com */ 1977445Ssteve.reinhardt@amd.comint rgdb_wait = -1; 1987445Ssteve.reinhardt@amd.com 199180SN/Aint 2005718Shsul@eecs.umich.eduSystem::registerThreadContext(ThreadContext *tc, int assigned) 2012SN/A{ 2025712Shsul@eecs.umich.edu int id; 2035718Shsul@eecs.umich.edu if (assigned == -1) { 2045718Shsul@eecs.umich.edu for (id = 0; id < threadContexts.size(); id++) { 2055718Shsul@eecs.umich.edu if (!threadContexts[id]) 2065718Shsul@eecs.umich.edu break; 2075718Shsul@eecs.umich.edu } 2085718Shsul@eecs.umich.edu 2095718Shsul@eecs.umich.edu if (threadContexts.size() <= id) 2105718Shsul@eecs.umich.edu threadContexts.resize(id + 1); 2115718Shsul@eecs.umich.edu } else { 2125718Shsul@eecs.umich.edu if (threadContexts.size() <= assigned) 2135718Shsul@eecs.umich.edu threadContexts.resize(assigned + 1); 2145718Shsul@eecs.umich.edu id = assigned; 2151806SN/A } 2161806SN/A 2172680Sktlim@umich.edu if (threadContexts[id]) 2185823Ssaidi@eecs.umich.edu fatal("Cannot have two CPUs with the same id (%d)\n", id); 2191806SN/A 2202680Sktlim@umich.edu threadContexts[id] = tc; 2215714Shsul@eecs.umich.edu _numContexts++; 2221070SN/A 2235512SMichael.Adler@intel.com int port = getRemoteGDBPort(); 2247445Ssteve.reinhardt@amd.com if (port) { 2254095Sbinkertn@umich.edu RemoteGDB *rgdb = new RemoteGDB(this, tc); 2265512SMichael.Adler@intel.com GDBListener *gdbl = new GDBListener(rgdb, port + id); 2274095Sbinkertn@umich.edu gdbl->listen(); 2287445Ssteve.reinhardt@amd.com 2294095Sbinkertn@umich.edu if (rgdb_wait != -1 && rgdb_wait == id) 2304095Sbinkertn@umich.edu gdbl->accept(); 2311070SN/A 2324095Sbinkertn@umich.edu if (remoteGDB.size() <= id) { 2334095Sbinkertn@umich.edu remoteGDB.resize(id + 1); 2344095Sbinkertn@umich.edu } 2354095Sbinkertn@umich.edu 2364095Sbinkertn@umich.edu remoteGDB[id] = rgdb; 2371070SN/A } 2381070SN/A 2397914SBrad.Beckmann@amd.com activeCpus.push_back(false); 2407914SBrad.Beckmann@amd.com 2411806SN/A return id; 242180SN/A} 24375SN/A 2446029Ssteve.reinhardt@amd.comint 2456029Ssteve.reinhardt@amd.comSystem::numRunningContexts() 2466029Ssteve.reinhardt@amd.com{ 2476029Ssteve.reinhardt@amd.com int running = 0; 2486029Ssteve.reinhardt@amd.com for (int i = 0; i < _numContexts; ++i) { 2496029Ssteve.reinhardt@amd.com if (threadContexts[i]->status() != ThreadContext::Halted) 2506029Ssteve.reinhardt@amd.com ++running; 2516029Ssteve.reinhardt@amd.com } 2526029Ssteve.reinhardt@amd.com return running; 2536029Ssteve.reinhardt@amd.com} 2546029Ssteve.reinhardt@amd.com 255180SN/Avoid 2567733SAli.Saidi@ARM.comSystem::initState() 2571129SN/A{ 2588806Sgblack@eecs.umich.edu int i; 2598769Sgblack@eecs.umich.edu if (FullSystem) { 2608769Sgblack@eecs.umich.edu for (i = 0; i < threadContexts.size(); i++) 2618769Sgblack@eecs.umich.edu TheISA::startupCPU(threadContexts[i], i); 2628799Sgblack@eecs.umich.edu // Moved from the constructor to here since it relies on the 2638799Sgblack@eecs.umich.edu // address map being resolved in the interconnect 2648799Sgblack@eecs.umich.edu /** 2658799Sgblack@eecs.umich.edu * Load the kernel code into memory 2668799Sgblack@eecs.umich.edu */ 2678885SAli.Saidi@ARM.com if (params()->kernel != "") { 2688799Sgblack@eecs.umich.edu // Load program sections into memory 2698799Sgblack@eecs.umich.edu kernel->loadSections(physProxy, loadAddrMask); 2708706Sandreas.hansson@arm.com 2718799Sgblack@eecs.umich.edu DPRINTF(Loader, "Kernel start = %#x\n", kernelStart); 2728799Sgblack@eecs.umich.edu DPRINTF(Loader, "Kernel end = %#x\n", kernelEnd); 2738799Sgblack@eecs.umich.edu DPRINTF(Loader, "Kernel entry = %#x\n", kernelEntry); 2748799Sgblack@eecs.umich.edu DPRINTF(Loader, "Kernel loaded...\n"); 2758799Sgblack@eecs.umich.edu } 2768706Sandreas.hansson@arm.com } 2778706Sandreas.hansson@arm.com 2788706Sandreas.hansson@arm.com activeCpus.clear(); 2798706Sandreas.hansson@arm.com 2808806Sgblack@eecs.umich.edu if (!FullSystem) 2818806Sgblack@eecs.umich.edu return; 2828806Sgblack@eecs.umich.edu 2838806Sgblack@eecs.umich.edu for (i = 0; i < threadContexts.size(); i++) 2848806Sgblack@eecs.umich.edu TheISA::startupCPU(threadContexts[i], i); 2851129SN/A} 2861129SN/A 2871129SN/Avoid 2885713Shsul@eecs.umich.eduSystem::replaceThreadContext(ThreadContext *tc, int context_id) 289180SN/A{ 2905713Shsul@eecs.umich.edu if (context_id >= threadContexts.size()) { 2912680Sktlim@umich.edu panic("replaceThreadContext: bad id, %d >= %d\n", 2925713Shsul@eecs.umich.edu context_id, threadContexts.size()); 293180SN/A } 294180SN/A 2955713Shsul@eecs.umich.edu threadContexts[context_id] = tc; 2965713Shsul@eecs.umich.edu if (context_id < remoteGDB.size()) 2975713Shsul@eecs.umich.edu remoteGDB[context_id]->replaceThreadContext(tc); 2982SN/A} 2992SN/A 3002378SN/AAddr 3018601Ssteve.reinhardt@amd.comSystem::allocPhysPages(int npages) 3022378SN/A{ 3037770SAli.Saidi@ARM.com Addr return_addr = pagePtr << LogVMPageSize; 3048601Ssteve.reinhardt@amd.com pagePtr += npages; 3059007Slena@cs.wisc.edu if ((pagePtr << LogVMPageSize) > physmem.totalSize()) 3063162Ssaidi@eecs.umich.edu fatal("Out of memory, please increase size of physical memory."); 3072378SN/A return return_addr; 3082378SN/A} 3095795Ssaidi@eecs.umich.edu 3105795Ssaidi@eecs.umich.eduAddr 3118931Sandreas.hansson@arm.comSystem::memSize() const 3125795Ssaidi@eecs.umich.edu{ 3138931Sandreas.hansson@arm.com return physmem.totalSize(); 3145795Ssaidi@eecs.umich.edu} 3155795Ssaidi@eecs.umich.edu 3165795Ssaidi@eecs.umich.eduAddr 3178931Sandreas.hansson@arm.comSystem::freeMemSize() const 3185795Ssaidi@eecs.umich.edu{ 3198931Sandreas.hansson@arm.com return physmem.totalSize() - (pagePtr << LogVMPageSize); 3205795Ssaidi@eecs.umich.edu} 3215795Ssaidi@eecs.umich.edu 3228460SAli.Saidi@ARM.combool 3238931Sandreas.hansson@arm.comSystem::isMemAddr(Addr addr) const 3248460SAli.Saidi@ARM.com{ 3258931Sandreas.hansson@arm.com return physmem.isMemAddr(addr); 3268460SAli.Saidi@ARM.com} 3278460SAli.Saidi@ARM.com 3281070SN/Avoid 3297897Shestness@cs.utexas.eduSystem::resume() 3307897Shestness@cs.utexas.edu{ 3317897Shestness@cs.utexas.edu SimObject::resume(); 3327897Shestness@cs.utexas.edu totalNumInsts = 0; 3337897Shestness@cs.utexas.edu} 3347897Shestness@cs.utexas.edu 3357897Shestness@cs.utexas.eduvoid 3361070SN/ASystem::serialize(ostream &os) 3371070SN/A{ 3388769Sgblack@eecs.umich.edu if (FullSystem) 3398769Sgblack@eecs.umich.edu kernelSymtab->serialize("kernel_symtab", os); 3407770SAli.Saidi@ARM.com SERIALIZE_SCALAR(pagePtr); 3417770SAli.Saidi@ARM.com SERIALIZE_SCALAR(nextPID); 3421070SN/A} 3431070SN/A 3441070SN/A 3451070SN/Avoid 3461070SN/ASystem::unserialize(Checkpoint *cp, const string §ion) 3471070SN/A{ 3488769Sgblack@eecs.umich.edu if (FullSystem) 3498769Sgblack@eecs.umich.edu kernelSymtab->unserialize("kernel_symtab", cp, section); 3507770SAli.Saidi@ARM.com UNSERIALIZE_SCALAR(pagePtr); 3517770SAli.Saidi@ARM.com UNSERIALIZE_SCALAR(nextPID); 3521070SN/A} 3532SN/A 3542SN/Avoid 3558666SPrakash.Ramrakhyani@arm.comSystem::regStats() 3568666SPrakash.Ramrakhyani@arm.com{ 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 3862SN/ASystem::printSystems() 3872SN/A{ 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 4028832SAli.Saidi@ARM.comMasterID 4038832SAli.Saidi@ARM.comSystem::getMasterId(std::string master_name) 4048832SAli.Saidi@ARM.com{ 4058832SAli.Saidi@ARM.com // strip off system name if the string starts with it 4069142Ssteve.reinhardt@amd.com if (startswith(master_name, name())) 4078832SAli.Saidi@ARM.com master_name = master_name.erase(0, name().size() + 1); 4088832SAli.Saidi@ARM.com 4098832SAli.Saidi@ARM.com // CPUs in switch_cpus ask for ids again after switching 4108832SAli.Saidi@ARM.com for (int i = 0; i < masterIds.size(); i++) { 4118832SAli.Saidi@ARM.com if (masterIds[i] == master_name) { 4128832SAli.Saidi@ARM.com return i; 4138832SAli.Saidi@ARM.com } 4148832SAli.Saidi@ARM.com } 4158832SAli.Saidi@ARM.com 4168986SAli.Saidi@ARM.com // Verify that the statistics haven't been enabled yet 4178986SAli.Saidi@ARM.com // Otherwise objects will have sized their stat buckets and 4188986SAli.Saidi@ARM.com // they will be too small 4198832SAli.Saidi@ARM.com 4208986SAli.Saidi@ARM.com if (Stats::enabled()) 4218832SAli.Saidi@ARM.com fatal("Can't request a masterId after regStats(). \ 4228832SAli.Saidi@ARM.com You must do so in init().\n"); 4238832SAli.Saidi@ARM.com 4248832SAli.Saidi@ARM.com masterIds.push_back(master_name); 4258832SAli.Saidi@ARM.com 4268832SAli.Saidi@ARM.com return masterIds.size() - 1; 4278832SAli.Saidi@ARM.com} 4288832SAli.Saidi@ARM.com 4298832SAli.Saidi@ARM.comstd::string 4308832SAli.Saidi@ARM.comSystem::getMasterName(MasterID master_id) 4318832SAli.Saidi@ARM.com{ 4328832SAli.Saidi@ARM.com if (master_id >= masterIds.size()) 4338832SAli.Saidi@ARM.com fatal("Invalid master_id passed to getMasterName()\n"); 4348832SAli.Saidi@ARM.com 4358832SAli.Saidi@ARM.com return masterIds[master_id]; 4368832SAli.Saidi@ARM.com} 4378832SAli.Saidi@ARM.com 4382902Ssaidi@eecs.umich.educonst char *System::MemoryModeStrings[3] = {"invalid", "atomic", 4392902Ssaidi@eecs.umich.edu "timing"}; 4402902Ssaidi@eecs.umich.edu 4414762Snate@binkert.orgSystem * 4424762Snate@binkert.orgSystemParams::create() 4432424SN/A{ 4445530Snate@binkert.org return new System(this); 4452424SN/A} 446