pseudo_inst.cc revision 11290
1298SN/A/* 211270Sandreas.sandberg@arm.com * Copyright (c) 2010-2012, 2015 ARM Limited 38142SAli.Saidi@ARM.com * All rights reserved 48142SAli.Saidi@ARM.com * 58142SAli.Saidi@ARM.com * The license below extends only to copyright in the software and shall 68142SAli.Saidi@ARM.com * not be construed as granting a license to any other intellectual 78142SAli.Saidi@ARM.com * property including but not limited to intellectual property relating 88142SAli.Saidi@ARM.com * to a hardware implementation of the functionality of the software 98142SAli.Saidi@ARM.com * licensed hereunder. You may use the software subject to the license 108142SAli.Saidi@ARM.com * terms below provided that you ensure that this notice is replicated 118142SAli.Saidi@ARM.com * unmodified and in its entirety in all distributions of the software, 128142SAli.Saidi@ARM.com * modified or unmodified, in source code or in binary form. 138142SAli.Saidi@ARM.com * 148580Ssteve.reinhardt@amd.com * Copyright (c) 2011 Advanced Micro Devices, Inc. 152188SN/A * Copyright (c) 2003-2006 The Regents of The University of Michigan 16298SN/A * All rights reserved. 17298SN/A * 18298SN/A * Redistribution and use in source and binary forms, with or without 19298SN/A * modification, are permitted provided that the following conditions are 20298SN/A * met: redistributions of source code must retain the above copyright 21298SN/A * notice, this list of conditions and the following disclaimer; 22298SN/A * redistributions in binary form must reproduce the above copyright 23298SN/A * notice, this list of conditions and the following disclaimer in the 24298SN/A * documentation and/or other materials provided with the distribution; 25298SN/A * neither the name of the copyright holders nor the names of its 26298SN/A * contributors may be used to endorse or promote products derived from 27298SN/A * this software without specific prior written permission. 28298SN/A * 29298SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30298SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31298SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 32298SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 33298SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 34298SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 35298SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 36298SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 37298SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38298SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 39298SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 402665Ssaidi@eecs.umich.edu * 412665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert 42298SN/A */ 43298SN/A 44954SN/A#include <fcntl.h> 45956SN/A#include <unistd.h> 46956SN/A 478229Snate@binkert.org#include <cerrno> 484078Sbinkertn@umich.edu#include <fstream> 49299SN/A#include <string> 509659SAndreas.Sandberg@ARM.com#include <vector> 51299SN/A 528777Sgblack@eecs.umich.edu#include "arch/kernel_stats.hh" 539659SAndreas.Sandberg@ARM.com#include "arch/utility.hh" 542170SN/A#include "arch/vtophys.hh" 5510553Salexandru.dutu@amd.com#include "arch/pseudo_inst.hh" 565882Snate@binkert.org#include "base/debug.hh" 578734Sdam.sunwoo@arm.com#include "base/output.hh" 586658Snate@binkert.org#include "config/the_isa.hh" 591717SN/A#include "cpu/base.hh" 608229Snate@binkert.org#include "cpu/quiesce_event.hh" 612680Sktlim@umich.edu#include "cpu/thread_context.hh" 628232Snate@binkert.org#include "debug/Loader.hh" 639733Sandreas@sandberg.pp.se#include "debug/PseudoInst.hh" 648232Snate@binkert.org#include "debug/Quiesce.hh" 658232Snate@binkert.org#include "debug/WorkItems.hh" 6611290Sgabor.dozsa@arm.com#include "dev/net/dist_iface.hh" 675529Snate@binkert.org#include "params/BaseCPU.hh" 688784Sgblack@eecs.umich.edu#include "sim/full_system.hh" 6911290Sgabor.dozsa@arm.com#include "sim/initparam_keys.hh" 7010553Salexandru.dutu@amd.com#include "sim/process.hh" 713565Sgblack@eecs.umich.edu#include "sim/pseudo_inst.hh" 72298SN/A#include "sim/serialize.hh" 735606Snate@binkert.org#include "sim/sim_events.hh" 74298SN/A#include "sim/sim_exit.hh" 75695SN/A#include "sim/stat_control.hh" 76695SN/A#include "sim/stats.hh" 77954SN/A#include "sim/system.hh" 782080SN/A#include "sim/vptr.hh" 79298SN/A 80299SN/Ausing namespace std; 811052SN/A 82729SN/Ausing namespace Stats; 832107SN/Ausing namespace TheISA; 84298SN/A 855504Snate@binkert.orgnamespace PseudoInst { 865504Snate@binkert.org 878784Sgblack@eecs.umich.edustatic inline void 888784Sgblack@eecs.umich.edupanicFsOnlyPseudoInst(const char *name) 898784Sgblack@eecs.umich.edu{ 908784Sgblack@eecs.umich.edu panic("Pseudo inst \"%s\" is only available in Full System mode."); 918784Sgblack@eecs.umich.edu} 925780Ssteve.reinhardt@amd.com 939659SAndreas.Sandberg@ARM.comuint64_t 949659SAndreas.Sandberg@ARM.compseudoInst(ThreadContext *tc, uint8_t func, uint8_t subfunc) 959659SAndreas.Sandberg@ARM.com{ 969659SAndreas.Sandberg@ARM.com uint64_t args[4]; 979659SAndreas.Sandberg@ARM.com 989733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::pseudoInst(%i, %i)\n", func, subfunc); 999733Sandreas@sandberg.pp.se 1009659SAndreas.Sandberg@ARM.com // We need to do this in a slightly convoluted way since 1019659SAndreas.Sandberg@ARM.com // getArgument() might have side-effects on arg_num. We could have 1029659SAndreas.Sandberg@ARM.com // used the Argument class, but due to the possible side effects 1039659SAndreas.Sandberg@ARM.com // from getArgument, it'd most likely break. 1049659SAndreas.Sandberg@ARM.com int arg_num(0); 1059879Sandreas@sandberg.pp.se for (int i = 0; i < sizeof(args) / sizeof(*args); ++i) { 1069879Sandreas@sandberg.pp.se args[arg_num] = getArgument(tc, arg_num, sizeof(uint64_t), false); 1079879Sandreas@sandberg.pp.se ++arg_num; 1089879Sandreas@sandberg.pp.se } 1099659SAndreas.Sandberg@ARM.com 1109659SAndreas.Sandberg@ARM.com switch (func) { 1119659SAndreas.Sandberg@ARM.com case 0x00: // arm_func 1129659SAndreas.Sandberg@ARM.com arm(tc); 1139659SAndreas.Sandberg@ARM.com break; 1149659SAndreas.Sandberg@ARM.com 1159659SAndreas.Sandberg@ARM.com case 0x01: // quiesce_func 1169659SAndreas.Sandberg@ARM.com quiesce(tc); 1179659SAndreas.Sandberg@ARM.com break; 1189659SAndreas.Sandberg@ARM.com 1199659SAndreas.Sandberg@ARM.com case 0x02: // quiescens_func 1209659SAndreas.Sandberg@ARM.com quiesceSkip(tc); 1219659SAndreas.Sandberg@ARM.com break; 1229659SAndreas.Sandberg@ARM.com 1239659SAndreas.Sandberg@ARM.com case 0x03: // quiescecycle_func 1249659SAndreas.Sandberg@ARM.com quiesceNs(tc, args[0]); 1259659SAndreas.Sandberg@ARM.com break; 1269659SAndreas.Sandberg@ARM.com 1279659SAndreas.Sandberg@ARM.com case 0x04: // quiescetime_func 1289659SAndreas.Sandberg@ARM.com return quiesceTime(tc); 1299659SAndreas.Sandberg@ARM.com 1309659SAndreas.Sandberg@ARM.com case 0x07: // rpns_func 1319659SAndreas.Sandberg@ARM.com return rpns(tc); 1329659SAndreas.Sandberg@ARM.com 1339659SAndreas.Sandberg@ARM.com case 0x09: // wakecpu_func 1349659SAndreas.Sandberg@ARM.com wakeCPU(tc, args[0]); 1359659SAndreas.Sandberg@ARM.com break; 1369659SAndreas.Sandberg@ARM.com 1379659SAndreas.Sandberg@ARM.com case 0x21: // exit_func 1389659SAndreas.Sandberg@ARM.com m5exit(tc, args[0]); 1399659SAndreas.Sandberg@ARM.com break; 1409659SAndreas.Sandberg@ARM.com 1419681Sandreas@sandberg.pp.se case 0x22: 1429681Sandreas@sandberg.pp.se m5fail(tc, args[0], args[1]); 1439681Sandreas@sandberg.pp.se break; 1449681Sandreas@sandberg.pp.se 1459659SAndreas.Sandberg@ARM.com case 0x30: // initparam_func 14611289Sgabor.dozsa@arm.com return initParam(tc, args[0], args[1]); 1479659SAndreas.Sandberg@ARM.com 1489659SAndreas.Sandberg@ARM.com case 0x31: // loadsymbol_func 1499659SAndreas.Sandberg@ARM.com loadsymbol(tc); 1509659SAndreas.Sandberg@ARM.com break; 1519659SAndreas.Sandberg@ARM.com 1529659SAndreas.Sandberg@ARM.com case 0x40: // resetstats_func 1539659SAndreas.Sandberg@ARM.com resetstats(tc, args[0], args[1]); 1549659SAndreas.Sandberg@ARM.com break; 1559659SAndreas.Sandberg@ARM.com 1569659SAndreas.Sandberg@ARM.com case 0x41: // dumpstats_func 1579659SAndreas.Sandberg@ARM.com dumpstats(tc, args[0], args[1]); 1589659SAndreas.Sandberg@ARM.com break; 1599659SAndreas.Sandberg@ARM.com 1609659SAndreas.Sandberg@ARM.com case 0x42: // dumprststats_func 1619659SAndreas.Sandberg@ARM.com dumpresetstats(tc, args[0], args[1]); 1629659SAndreas.Sandberg@ARM.com break; 1639659SAndreas.Sandberg@ARM.com 1649659SAndreas.Sandberg@ARM.com case 0x43: // ckpt_func 1659659SAndreas.Sandberg@ARM.com m5checkpoint(tc, args[0], args[1]); 1669659SAndreas.Sandberg@ARM.com break; 1679659SAndreas.Sandberg@ARM.com 1689659SAndreas.Sandberg@ARM.com case 0x4f: // writefile_func 1699659SAndreas.Sandberg@ARM.com return writefile(tc, args[0], args[1], args[2], args[3]); 1709659SAndreas.Sandberg@ARM.com 1719659SAndreas.Sandberg@ARM.com case 0x50: // readfile_func 1729659SAndreas.Sandberg@ARM.com return readfile(tc, args[0], args[1], args[2]); 1739659SAndreas.Sandberg@ARM.com 1749659SAndreas.Sandberg@ARM.com case 0x51: // debugbreak_func 1759659SAndreas.Sandberg@ARM.com debugbreak(tc); 1769659SAndreas.Sandberg@ARM.com break; 1779659SAndreas.Sandberg@ARM.com 1789659SAndreas.Sandberg@ARM.com case 0x52: // switchcpu_func 1799659SAndreas.Sandberg@ARM.com switchcpu(tc); 1809659SAndreas.Sandberg@ARM.com break; 1819659SAndreas.Sandberg@ARM.com 1829659SAndreas.Sandberg@ARM.com case 0x53: // addsymbol_func 1839659SAndreas.Sandberg@ARM.com addsymbol(tc, args[0], args[1]); 1849659SAndreas.Sandberg@ARM.com break; 1859659SAndreas.Sandberg@ARM.com 1869659SAndreas.Sandberg@ARM.com case 0x54: // panic_func 1879659SAndreas.Sandberg@ARM.com panic("M5 panic instruction called at %s\n", tc->pcState()); 1889659SAndreas.Sandberg@ARM.com 1899659SAndreas.Sandberg@ARM.com case 0x5a: // work_begin_func 1909659SAndreas.Sandberg@ARM.com workbegin(tc, args[0], args[1]); 1919659SAndreas.Sandberg@ARM.com break; 1929659SAndreas.Sandberg@ARM.com 1939659SAndreas.Sandberg@ARM.com case 0x5b: // work_end_func 1949659SAndreas.Sandberg@ARM.com workend(tc, args[0], args[1]); 1959659SAndreas.Sandberg@ARM.com break; 1969659SAndreas.Sandberg@ARM.com 1979659SAndreas.Sandberg@ARM.com case 0x55: // annotate_func 1989659SAndreas.Sandberg@ARM.com case 0x56: // reserved2_func 1999659SAndreas.Sandberg@ARM.com case 0x57: // reserved3_func 2009659SAndreas.Sandberg@ARM.com case 0x58: // reserved4_func 2019659SAndreas.Sandberg@ARM.com case 0x59: // reserved5_func 2029659SAndreas.Sandberg@ARM.com warn("Unimplemented m5 op (0x%x)\n", func); 2039659SAndreas.Sandberg@ARM.com break; 2049659SAndreas.Sandberg@ARM.com 20510553Salexandru.dutu@amd.com /* SE mode functions */ 20610553Salexandru.dutu@amd.com case 0x60: // syscall_func 20710553Salexandru.dutu@amd.com m5Syscall(tc); 20810553Salexandru.dutu@amd.com break; 20910553Salexandru.dutu@amd.com 21010553Salexandru.dutu@amd.com case 0x61: // pagefault_func 21110553Salexandru.dutu@amd.com m5PageFault(tc); 21210553Salexandru.dutu@amd.com break; 21310553Salexandru.dutu@amd.com 2149659SAndreas.Sandberg@ARM.com default: 2159659SAndreas.Sandberg@ARM.com warn("Unhandled m5 op: 0x%x\n", func); 2169659SAndreas.Sandberg@ARM.com break; 2179659SAndreas.Sandberg@ARM.com } 2189659SAndreas.Sandberg@ARM.com 2199659SAndreas.Sandberg@ARM.com return 0; 2209659SAndreas.Sandberg@ARM.com} 2219659SAndreas.Sandberg@ARM.com 2225504Snate@binkert.orgvoid 2235504Snate@binkert.orgarm(ThreadContext *tc) 224298SN/A{ 2259733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::arm()\n"); 2268806Sgblack@eecs.umich.edu if (!FullSystem) 2278784Sgblack@eecs.umich.edu panicFsOnlyPseudoInst("arm"); 2288806Sgblack@eecs.umich.edu 2295504Snate@binkert.org if (tc->getKernelStats()) 2305504Snate@binkert.org tc->getKernelStats()->arm(); 2315504Snate@binkert.org} 2325504Snate@binkert.org 2335504Snate@binkert.orgvoid 2345504Snate@binkert.orgquiesce(ThreadContext *tc) 2355504Snate@binkert.org{ 2369733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::quiesce()\n"); 2378806Sgblack@eecs.umich.edu if (!FullSystem) 2388806Sgblack@eecs.umich.edu panicFsOnlyPseudoInst("quiesce"); 2398666SPrakash.Ramrakhyani@arm.com 2405529Snate@binkert.org if (!tc->getCpuPtr()->params()->do_quiesce) 2415504Snate@binkert.org return; 2425504Snate@binkert.org 2435504Snate@binkert.org DPRINTF(Quiesce, "%s: quiesce()\n", tc->getCpuPtr()->name()); 2445504Snate@binkert.org 2455504Snate@binkert.org tc->suspend(); 2465504Snate@binkert.org if (tc->getKernelStats()) 2475504Snate@binkert.org tc->getKernelStats()->quiesce(); 2485504Snate@binkert.org} 2495504Snate@binkert.org 2505504Snate@binkert.orgvoid 2518142SAli.Saidi@ARM.comquiesceSkip(ThreadContext *tc) 2528142SAli.Saidi@ARM.com{ 2539733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::quiesceSkip()\n"); 2548806Sgblack@eecs.umich.edu if (!FullSystem) 2558806Sgblack@eecs.umich.edu panicFsOnlyPseudoInst("quiesceSkip"); 2568666SPrakash.Ramrakhyani@arm.com 2578142SAli.Saidi@ARM.com BaseCPU *cpu = tc->getCpuPtr(); 2588142SAli.Saidi@ARM.com 2598142SAli.Saidi@ARM.com if (!cpu->params()->do_quiesce) 2608142SAli.Saidi@ARM.com return; 2618142SAli.Saidi@ARM.com 2628142SAli.Saidi@ARM.com EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); 2638142SAli.Saidi@ARM.com 2648142SAli.Saidi@ARM.com Tick resume = curTick() + 1; 2658142SAli.Saidi@ARM.com 2668142SAli.Saidi@ARM.com cpu->reschedule(quiesceEvent, resume, true); 2678142SAli.Saidi@ARM.com 2688142SAli.Saidi@ARM.com DPRINTF(Quiesce, "%s: quiesceSkip() until %d\n", 2698142SAli.Saidi@ARM.com cpu->name(), resume); 2708142SAli.Saidi@ARM.com 2718142SAli.Saidi@ARM.com tc->suspend(); 2728142SAli.Saidi@ARM.com if (tc->getKernelStats()) 2738142SAli.Saidi@ARM.com tc->getKernelStats()->quiesce(); 2748142SAli.Saidi@ARM.com} 2758142SAli.Saidi@ARM.com 2768142SAli.Saidi@ARM.comvoid 2775504Snate@binkert.orgquiesceNs(ThreadContext *tc, uint64_t ns) 2785504Snate@binkert.org{ 2799733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::quiesceNs(%i)\n", ns); 2808806Sgblack@eecs.umich.edu if (!FullSystem) 2818806Sgblack@eecs.umich.edu panicFsOnlyPseudoInst("quiesceNs"); 2828666SPrakash.Ramrakhyani@arm.com 2837819Ssteve.reinhardt@amd.com BaseCPU *cpu = tc->getCpuPtr(); 2847819Ssteve.reinhardt@amd.com 28511058Secastill@bsc.es if (!cpu->params()->do_quiesce) 2865504Snate@binkert.org return; 2875504Snate@binkert.org 2885504Snate@binkert.org EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); 2895504Snate@binkert.org 2907823Ssteve.reinhardt@amd.com Tick resume = curTick() + SimClock::Int::ns * ns; 2915504Snate@binkert.org 2927819Ssteve.reinhardt@amd.com cpu->reschedule(quiesceEvent, resume, true); 2935504Snate@binkert.org 2945504Snate@binkert.org DPRINTF(Quiesce, "%s: quiesceNs(%d) until %d\n", 2957819Ssteve.reinhardt@amd.com cpu->name(), ns, resume); 2965504Snate@binkert.org 2975504Snate@binkert.org tc->suspend(); 2985504Snate@binkert.org if (tc->getKernelStats()) 2995504Snate@binkert.org tc->getKernelStats()->quiesce(); 3005504Snate@binkert.org} 3015504Snate@binkert.org 3025504Snate@binkert.orgvoid 3035504Snate@binkert.orgquiesceCycles(ThreadContext *tc, uint64_t cycles) 3045504Snate@binkert.org{ 3059733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::quiesceCycles(%i)\n", cycles); 3068806Sgblack@eecs.umich.edu if (!FullSystem) 3078806Sgblack@eecs.umich.edu panicFsOnlyPseudoInst("quiesceCycles"); 3088666SPrakash.Ramrakhyani@arm.com 3097819Ssteve.reinhardt@amd.com BaseCPU *cpu = tc->getCpuPtr(); 3107819Ssteve.reinhardt@amd.com 31111058Secastill@bsc.es if (!cpu->params()->do_quiesce) 3125504Snate@binkert.org return; 3135504Snate@binkert.org 3145504Snate@binkert.org EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); 3155504Snate@binkert.org 3169180Sandreas.hansson@arm.com Tick resume = cpu->clockEdge(Cycles(cycles)); 3175504Snate@binkert.org 3187819Ssteve.reinhardt@amd.com cpu->reschedule(quiesceEvent, resume, true); 3195504Snate@binkert.org 3205504Snate@binkert.org DPRINTF(Quiesce, "%s: quiesceCycles(%d) until %d\n", 3217819Ssteve.reinhardt@amd.com cpu->name(), cycles, resume); 3225504Snate@binkert.org 3235504Snate@binkert.org tc->suspend(); 3245504Snate@binkert.org if (tc->getKernelStats()) 3255504Snate@binkert.org tc->getKernelStats()->quiesce(); 3265504Snate@binkert.org} 3275504Snate@binkert.org 3285504Snate@binkert.orguint64_t 3295504Snate@binkert.orgquiesceTime(ThreadContext *tc) 3305504Snate@binkert.org{ 3319733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::quiesceTime()\n"); 3328806Sgblack@eecs.umich.edu if (!FullSystem) { 3338784Sgblack@eecs.umich.edu panicFsOnlyPseudoInst("quiesceTime"); 3348784Sgblack@eecs.umich.edu return 0; 3358784Sgblack@eecs.umich.edu } 3368806Sgblack@eecs.umich.edu 3377064Snate@binkert.org return (tc->readLastActivate() - tc->readLastSuspend()) / 3387064Snate@binkert.org SimClock::Int::ns; 3395504Snate@binkert.org} 3405504Snate@binkert.org 3415741Snate@binkert.orguint64_t 3425741Snate@binkert.orgrpns(ThreadContext *tc) 3435741Snate@binkert.org{ 3449733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::rpns()\n"); 3457823Ssteve.reinhardt@amd.com return curTick() / SimClock::Int::ns; 3465741Snate@binkert.org} 3475741Snate@binkert.org 3485504Snate@binkert.orgvoid 3495808Snate@binkert.orgwakeCPU(ThreadContext *tc, uint64_t cpuid) 3505808Snate@binkert.org{ 3519733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::wakeCPU(%i)\n", cpuid); 3525808Snate@binkert.org System *sys = tc->getSystemPtr(); 3535808Snate@binkert.org ThreadContext *other_tc = sys->threadContexts[cpuid]; 3545808Snate@binkert.org if (other_tc->status() == ThreadContext::Suspended) 3555808Snate@binkert.org other_tc->activate(); 3565808Snate@binkert.org} 3575808Snate@binkert.org 3585808Snate@binkert.orgvoid 3595504Snate@binkert.orgm5exit(ThreadContext *tc, Tick delay) 3605504Snate@binkert.org{ 3619733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::m5exit(%i)\n", delay); 36211290Sgabor.dozsa@arm.com if (DistIface::readyToExit(delay)) { 36311290Sgabor.dozsa@arm.com Tick when = curTick() + delay * SimClock::Int::ns; 36411290Sgabor.dozsa@arm.com exitSimLoop("m5_exit instruction encountered", 0, when, 0, true); 36511290Sgabor.dozsa@arm.com } 3665504Snate@binkert.org} 3675504Snate@binkert.org 3685504Snate@binkert.orgvoid 3699457Svilanova@ac.upc.edum5fail(ThreadContext *tc, Tick delay, uint64_t code) 3709457Svilanova@ac.upc.edu{ 3719733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::m5fail(%i, %i)\n", delay, code); 3729457Svilanova@ac.upc.edu Tick when = curTick() + delay * SimClock::Int::ns; 3739952Sdam.sunwoo@arm.com exitSimLoop("m5_fail instruction encountered", code, when, 0, true); 3749457Svilanova@ac.upc.edu} 3759457Svilanova@ac.upc.edu 3769457Svilanova@ac.upc.eduvoid 3775504Snate@binkert.orgloadsymbol(ThreadContext *tc) 3785504Snate@binkert.org{ 3799733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::loadsymbol()\n"); 3808806Sgblack@eecs.umich.edu if (!FullSystem) 3818806Sgblack@eecs.umich.edu panicFsOnlyPseudoInst("loadsymbol"); 3828784Sgblack@eecs.umich.edu 3835504Snate@binkert.org const string &filename = tc->getCpuPtr()->system->params()->symbolfile; 3845504Snate@binkert.org if (filename.empty()) { 3855504Snate@binkert.org return; 386711SN/A } 387711SN/A 3885504Snate@binkert.org std::string buffer; 3895504Snate@binkert.org ifstream file(filename.c_str()); 390310SN/A 3915504Snate@binkert.org if (!file) 3925504Snate@binkert.org fatal("file error: Can't open symbol table file %s\n", filename); 3933373Sstever@eecs.umich.edu 3945504Snate@binkert.org while (!file.eof()) { 3955504Snate@binkert.org getline(file, buffer); 3965504Snate@binkert.org 3975504Snate@binkert.org if (buffer.empty()) 3985504Snate@binkert.org continue; 3995504Snate@binkert.org 4006227Snate@binkert.org string::size_type idx = buffer.find(' '); 4015504Snate@binkert.org if (idx == string::npos) 4025504Snate@binkert.org continue; 4035504Snate@binkert.org 4045504Snate@binkert.org string address = "0x" + buffer.substr(0, idx); 4055504Snate@binkert.org eat_white(address); 4065504Snate@binkert.org if (address.empty()) 4075504Snate@binkert.org continue; 4085504Snate@binkert.org 4095504Snate@binkert.org // Skip over letter and space 4105504Snate@binkert.org string symbol = buffer.substr(idx + 3); 4115504Snate@binkert.org eat_white(symbol); 4125504Snate@binkert.org if (symbol.empty()) 4135504Snate@binkert.org continue; 4145504Snate@binkert.org 4155504Snate@binkert.org Addr addr; 4165504Snate@binkert.org if (!to_number(address, addr)) 4175504Snate@binkert.org continue; 4185504Snate@binkert.org 4195504Snate@binkert.org if (!tc->getSystemPtr()->kernelSymtab->insert(addr, symbol)) 4205504Snate@binkert.org continue; 4215504Snate@binkert.org 4225504Snate@binkert.org 4235504Snate@binkert.org DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); 4245504Snate@binkert.org } 4255504Snate@binkert.org file.close(); 4265504Snate@binkert.org} 4275504Snate@binkert.org 4285504Snate@binkert.orgvoid 4295780Ssteve.reinhardt@amd.comaddsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr) 4305780Ssteve.reinhardt@amd.com{ 4319733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::addsymbol(0x%x, 0x%x)\n", 4329733Sandreas@sandberg.pp.se addr, symbolAddr); 4338806Sgblack@eecs.umich.edu if (!FullSystem) 4348806Sgblack@eecs.umich.edu panicFsOnlyPseudoInst("addSymbol"); 4358666SPrakash.Ramrakhyani@arm.com 4365780Ssteve.reinhardt@amd.com char symb[100]; 4375780Ssteve.reinhardt@amd.com CopyStringOut(tc, symb, symbolAddr, 100); 4385780Ssteve.reinhardt@amd.com std::string symbol(symb); 4395780Ssteve.reinhardt@amd.com 4405780Ssteve.reinhardt@amd.com DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); 4415780Ssteve.reinhardt@amd.com 4425780Ssteve.reinhardt@amd.com tc->getSystemPtr()->kernelSymtab->insert(addr,symbol); 4435952Ssaidi@eecs.umich.edu debugSymbolTable->insert(addr,symbol); 4445780Ssteve.reinhardt@amd.com} 4455780Ssteve.reinhardt@amd.com 4468555Sgblack@eecs.umich.eduuint64_t 44711289Sgabor.dozsa@arm.cominitParam(ThreadContext *tc, uint64_t key_str1, uint64_t key_str2) 4488555Sgblack@eecs.umich.edu{ 44911289Sgabor.dozsa@arm.com DPRINTF(PseudoInst, "PseudoInst::initParam() key:%s%s\n", (char *)&key_str1, 45011289Sgabor.dozsa@arm.com (char *)&key_str2); 4518806Sgblack@eecs.umich.edu if (!FullSystem) { 4528784Sgblack@eecs.umich.edu panicFsOnlyPseudoInst("initParam"); 4538784Sgblack@eecs.umich.edu return 0; 4548784Sgblack@eecs.umich.edu } 4558806Sgblack@eecs.umich.edu 45611289Sgabor.dozsa@arm.com // The key parameter string is passed in via two 64-bit registers. We copy 45711289Sgabor.dozsa@arm.com // out the characters from the 64-bit integer variables here and concatenate 45811289Sgabor.dozsa@arm.com // them in the key_str character buffer 45911289Sgabor.dozsa@arm.com const int len = 2 * sizeof(uint64_t) + 1; 46011289Sgabor.dozsa@arm.com char key_str[len]; 46111289Sgabor.dozsa@arm.com memset(key_str, '\0', len); 46211289Sgabor.dozsa@arm.com if (key_str1 == 0) { 46311289Sgabor.dozsa@arm.com assert(key_str2 == 0); 46411289Sgabor.dozsa@arm.com } else { 46511289Sgabor.dozsa@arm.com strncpy(key_str, (char *)&key_str1, sizeof(uint64_t)); 46611289Sgabor.dozsa@arm.com } 46711289Sgabor.dozsa@arm.com 46811289Sgabor.dozsa@arm.com if (strlen(key_str) == sizeof(uint64_t)) { 46911289Sgabor.dozsa@arm.com strncpy(key_str + sizeof(uint64_t), (char *)&key_str2, 47011289Sgabor.dozsa@arm.com sizeof(uint64_t)); 47111289Sgabor.dozsa@arm.com } else { 47211289Sgabor.dozsa@arm.com assert(key_str2 == 0); 47311289Sgabor.dozsa@arm.com } 47411289Sgabor.dozsa@arm.com 47511289Sgabor.dozsa@arm.com // Compare the key parameter with the known values to select the return 47611289Sgabor.dozsa@arm.com // value 47711289Sgabor.dozsa@arm.com uint64_t val; 47811290Sgabor.dozsa@arm.com if (strcmp(key_str, InitParamKey::DEFAULT) == 0) { 47911289Sgabor.dozsa@arm.com val = tc->getCpuPtr()->system->init_param; 48011290Sgabor.dozsa@arm.com } else if (strcmp(key_str, InitParamKey::DIST_RANK) == 0) { 48111290Sgabor.dozsa@arm.com val = DistIface::rankParam(); 48211290Sgabor.dozsa@arm.com } else if (strcmp(key_str, InitParamKey::DIST_SIZE) == 0) { 48311290Sgabor.dozsa@arm.com val = DistIface::sizeParam(); 48411289Sgabor.dozsa@arm.com } else { 48511290Sgabor.dozsa@arm.com panic("Unknown key for initparam pseudo instruction:\"%s\"", key_str); 48611289Sgabor.dozsa@arm.com } 48711289Sgabor.dozsa@arm.com return val; 4888555Sgblack@eecs.umich.edu} 4898555Sgblack@eecs.umich.edu 4905780Ssteve.reinhardt@amd.com 4915780Ssteve.reinhardt@amd.comvoid 4925504Snate@binkert.orgresetstats(ThreadContext *tc, Tick delay, Tick period) 4935504Snate@binkert.org{ 4949733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::resetstats(%i, %i)\n", delay, period); 4955529Snate@binkert.org if (!tc->getCpuPtr()->params()->do_statistics_insts) 4965504Snate@binkert.org return; 4975504Snate@binkert.org 4985504Snate@binkert.org 4997823Ssteve.reinhardt@amd.com Tick when = curTick() + delay * SimClock::Int::ns; 5007064Snate@binkert.org Tick repeat = period * SimClock::Int::ns; 5015504Snate@binkert.org 5027822Ssteve.reinhardt@amd.com Stats::schedStatEvent(false, true, when, repeat); 5035504Snate@binkert.org} 5045504Snate@binkert.org 5055504Snate@binkert.orgvoid 5065504Snate@binkert.orgdumpstats(ThreadContext *tc, Tick delay, Tick period) 5075504Snate@binkert.org{ 5089733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::dumpstats(%i, %i)\n", delay, period); 5095529Snate@binkert.org if (!tc->getCpuPtr()->params()->do_statistics_insts) 5105504Snate@binkert.org return; 5115504Snate@binkert.org 5125504Snate@binkert.org 5137823Ssteve.reinhardt@amd.com Tick when = curTick() + delay * SimClock::Int::ns; 5147064Snate@binkert.org Tick repeat = period * SimClock::Int::ns; 5155504Snate@binkert.org 5167822Ssteve.reinhardt@amd.com Stats::schedStatEvent(true, false, when, repeat); 5175504Snate@binkert.org} 5185504Snate@binkert.org 5195504Snate@binkert.orgvoid 5205504Snate@binkert.orgdumpresetstats(ThreadContext *tc, Tick delay, Tick period) 5215504Snate@binkert.org{ 5229733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::dumpresetstats(%i, %i)\n", delay, period); 5235529Snate@binkert.org if (!tc->getCpuPtr()->params()->do_statistics_insts) 5245504Snate@binkert.org return; 5255504Snate@binkert.org 5265504Snate@binkert.org 5277823Ssteve.reinhardt@amd.com Tick when = curTick() + delay * SimClock::Int::ns; 5287064Snate@binkert.org Tick repeat = period * SimClock::Int::ns; 5295504Snate@binkert.org 5307822Ssteve.reinhardt@amd.com Stats::schedStatEvent(true, true, when, repeat); 5315504Snate@binkert.org} 5325504Snate@binkert.org 5335504Snate@binkert.orgvoid 5345504Snate@binkert.orgm5checkpoint(ThreadContext *tc, Tick delay, Tick period) 5355504Snate@binkert.org{ 5369733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::m5checkpoint(%i, %i)\n", delay, period); 5375529Snate@binkert.org if (!tc->getCpuPtr()->params()->do_checkpoint_insts) 5385504Snate@binkert.org return; 5395504Snate@binkert.org 54011290Sgabor.dozsa@arm.com if (DistIface::readyToCkpt(delay, period)) { 54111290Sgabor.dozsa@arm.com Tick when = curTick() + delay * SimClock::Int::ns; 54211290Sgabor.dozsa@arm.com Tick repeat = period * SimClock::Int::ns; 54311290Sgabor.dozsa@arm.com exitSimLoop("checkpoint", 0, when, repeat); 54411290Sgabor.dozsa@arm.com } 5455504Snate@binkert.org} 5465504Snate@binkert.org 5475504Snate@binkert.orguint64_t 5485504Snate@binkert.orgreadfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset) 5495504Snate@binkert.org{ 5509733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::readfile(0x%x, 0x%x, 0x%x)\n", 5519733Sandreas@sandberg.pp.se vaddr, len, offset); 5528806Sgblack@eecs.umich.edu if (!FullSystem) { 5538784Sgblack@eecs.umich.edu panicFsOnlyPseudoInst("readfile"); 5548784Sgblack@eecs.umich.edu return 0; 5558666SPrakash.Ramrakhyani@arm.com } 5568806Sgblack@eecs.umich.edu 5575504Snate@binkert.org const string &file = tc->getSystemPtr()->params()->readfile; 5585504Snate@binkert.org if (file.empty()) { 5595504Snate@binkert.org return ULL(0); 560310SN/A } 561299SN/A 5625504Snate@binkert.org uint64_t result = 0; 5632188SN/A 5645504Snate@binkert.org int fd = ::open(file.c_str(), O_RDONLY, 0); 5655504Snate@binkert.org if (fd < 0) 5665504Snate@binkert.org panic("could not open file %s\n", file); 5672235SN/A 5685504Snate@binkert.org if (::lseek(fd, offset, SEEK_SET) < 0) 5695504Snate@binkert.org panic("could not seek: %s", strerror(errno)); 5703368Sstever@eecs.umich.edu 5715504Snate@binkert.org char *buf = new char[len]; 5725504Snate@binkert.org char *p = buf; 5735504Snate@binkert.org while (len > 0) { 5745504Snate@binkert.org int bytes = ::read(fd, p, len); 5755504Snate@binkert.org if (bytes <= 0) 5765504Snate@binkert.org break; 5773368Sstever@eecs.umich.edu 5785504Snate@binkert.org p += bytes; 5795504Snate@binkert.org result += bytes; 5805504Snate@binkert.org len -= bytes; 5812188SN/A } 5822188SN/A 5835504Snate@binkert.org close(fd); 5845504Snate@binkert.org CopyIn(tc, vaddr, buf, result); 5855504Snate@binkert.org delete [] buf; 5865504Snate@binkert.org return result; 5875504Snate@binkert.org} 5882188SN/A 5898734Sdam.sunwoo@arm.comuint64_t 5908734Sdam.sunwoo@arm.comwritefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset, 5918734Sdam.sunwoo@arm.com Addr filename_addr) 5928734Sdam.sunwoo@arm.com{ 5939733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::writefile(0x%x, 0x%x, 0x%x, 0x%x)\n", 5949733Sandreas@sandberg.pp.se vaddr, len, offset, filename_addr); 5958734Sdam.sunwoo@arm.com ostream *os; 5968734Sdam.sunwoo@arm.com 5978734Sdam.sunwoo@arm.com // copy out target filename 5988734Sdam.sunwoo@arm.com char fn[100]; 5998734Sdam.sunwoo@arm.com std::string filename; 6008734Sdam.sunwoo@arm.com CopyStringOut(tc, fn, filename_addr, 100); 6018734Sdam.sunwoo@arm.com filename = std::string(fn); 6028734Sdam.sunwoo@arm.com 6038734Sdam.sunwoo@arm.com if (offset == 0) { 6048734Sdam.sunwoo@arm.com // create a new file (truncate) 60511259Ssascha.bischoff@ARM.com os = simout.create(filename, true, true); 6068734Sdam.sunwoo@arm.com } else { 6078734Sdam.sunwoo@arm.com // do not truncate file if offset is non-zero 6088734Sdam.sunwoo@arm.com // (ios::in flag is required as well to keep the existing data 6098734Sdam.sunwoo@arm.com // intact, otherwise existing data will be zeroed out.) 6108734Sdam.sunwoo@arm.com os = simout.openFile(simout.directory() + filename, 61111259Ssascha.bischoff@ARM.com ios::in | ios::out | ios::binary, true); 6128734Sdam.sunwoo@arm.com } 6138734Sdam.sunwoo@arm.com if (!os) 6148734Sdam.sunwoo@arm.com panic("could not open file %s\n", filename); 6158734Sdam.sunwoo@arm.com 6168734Sdam.sunwoo@arm.com // seek to offset 6178734Sdam.sunwoo@arm.com os->seekp(offset); 6188734Sdam.sunwoo@arm.com 6198734Sdam.sunwoo@arm.com // copy out data and write to file 6208734Sdam.sunwoo@arm.com char *buf = new char[len]; 6218734Sdam.sunwoo@arm.com CopyOut(tc, buf, vaddr, len); 6228734Sdam.sunwoo@arm.com os->write(buf, len); 6238734Sdam.sunwoo@arm.com if (os->fail() || os->bad()) 6248734Sdam.sunwoo@arm.com panic("Error while doing writefile!\n"); 6258734Sdam.sunwoo@arm.com 6268734Sdam.sunwoo@arm.com simout.close(os); 6278734Sdam.sunwoo@arm.com 6288734Sdam.sunwoo@arm.com delete [] buf; 6298734Sdam.sunwoo@arm.com 6308734Sdam.sunwoo@arm.com return len; 6318734Sdam.sunwoo@arm.com} 6328734Sdam.sunwoo@arm.com 6335504Snate@binkert.orgvoid 6345504Snate@binkert.orgdebugbreak(ThreadContext *tc) 6355504Snate@binkert.org{ 6369733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::debugbreak()\n"); 6378231Snate@binkert.org Debug::breakpoint(); 6385504Snate@binkert.org} 6392235SN/A 6405504Snate@binkert.orgvoid 6415504Snate@binkert.orgswitchcpu(ThreadContext *tc) 6425504Snate@binkert.org{ 6439733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::switchcpu()\n"); 6445504Snate@binkert.org exitSimLoop("switchcpu"); 6455504Snate@binkert.org} 6463368Sstever@eecs.umich.edu 6477914SBrad.Beckmann@amd.com// 6487914SBrad.Beckmann@amd.com// This function is executed when annotated work items begin. Depending on 6497914SBrad.Beckmann@amd.com// what the user specified at the command line, the simulation may exit and/or 6507914SBrad.Beckmann@amd.com// take a checkpoint when a certain work item begins. 6517914SBrad.Beckmann@amd.com// 6527914SBrad.Beckmann@amd.comvoid 6537914SBrad.Beckmann@amd.comworkbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid) 6547914SBrad.Beckmann@amd.com{ 6559733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::workbegin(%i, %i)\n", workid, threadid); 6567914SBrad.Beckmann@amd.com System *sys = tc->getSystemPtr(); 6578580Ssteve.reinhardt@amd.com const System::Params *params = sys->params(); 65811270Sandreas.sandberg@arm.com 65911270Sandreas.sandberg@arm.com if (params->exit_on_work_items) { 66011270Sandreas.sandberg@arm.com exitSimLoop("workbegin", static_cast<int>(workid)); 66111270Sandreas.sandberg@arm.com return; 66211270Sandreas.sandberg@arm.com } 66311270Sandreas.sandberg@arm.com 66411270Sandreas.sandberg@arm.com DPRINTF(WorkItems, "Work Begin workid: %d, threadid %d\n", workid, 66511270Sandreas.sandberg@arm.com threadid); 66611270Sandreas.sandberg@arm.com tc->getCpuPtr()->workItemBegin(); 6678666SPrakash.Ramrakhyani@arm.com sys->workItemBegin(threadid, workid); 6687914SBrad.Beckmann@amd.com 6697914SBrad.Beckmann@amd.com // 6707914SBrad.Beckmann@amd.com // If specified, determine if this is the specific work item the user 6717914SBrad.Beckmann@amd.com // identified 6727914SBrad.Beckmann@amd.com // 6738580Ssteve.reinhardt@amd.com if (params->work_item_id == -1 || params->work_item_id == workid) { 6747914SBrad.Beckmann@amd.com 6757914SBrad.Beckmann@amd.com uint64_t systemWorkBeginCount = sys->incWorkItemsBegin(); 6767914SBrad.Beckmann@amd.com int cpuId = tc->getCpuPtr()->cpuId(); 6777914SBrad.Beckmann@amd.com 6788580Ssteve.reinhardt@amd.com if (params->work_cpus_ckpt_count != 0 && 6798580Ssteve.reinhardt@amd.com sys->markWorkItem(cpuId) >= params->work_cpus_ckpt_count) { 6807914SBrad.Beckmann@amd.com // 6817914SBrad.Beckmann@amd.com // If active cpus equals checkpoint count, create checkpoint 6827914SBrad.Beckmann@amd.com // 6838580Ssteve.reinhardt@amd.com exitSimLoop("checkpoint"); 6847914SBrad.Beckmann@amd.com } 6857914SBrad.Beckmann@amd.com 6868580Ssteve.reinhardt@amd.com if (systemWorkBeginCount == params->work_begin_ckpt_count) { 6877914SBrad.Beckmann@amd.com // 6887914SBrad.Beckmann@amd.com // Note: the string specified as the cause of the exit event must 6897914SBrad.Beckmann@amd.com // exactly equal "checkpoint" inorder to create a checkpoint 6907914SBrad.Beckmann@amd.com // 6918580Ssteve.reinhardt@amd.com exitSimLoop("checkpoint"); 6927914SBrad.Beckmann@amd.com } 6937914SBrad.Beckmann@amd.com 6948580Ssteve.reinhardt@amd.com if (systemWorkBeginCount == params->work_begin_exit_count) { 6957914SBrad.Beckmann@amd.com // 6967914SBrad.Beckmann@amd.com // If a certain number of work items started, exit simulation 6977914SBrad.Beckmann@amd.com // 6988580Ssteve.reinhardt@amd.com exitSimLoop("work started count reach"); 6997914SBrad.Beckmann@amd.com } 7007914SBrad.Beckmann@amd.com 7018580Ssteve.reinhardt@amd.com if (cpuId == params->work_begin_cpu_id_exit) { 7027914SBrad.Beckmann@amd.com // 7038580Ssteve.reinhardt@amd.com // If work started on the cpu id specified, exit simulation 7047914SBrad.Beckmann@amd.com // 7058580Ssteve.reinhardt@amd.com exitSimLoop("work started on specific cpu"); 7067914SBrad.Beckmann@amd.com } 7077914SBrad.Beckmann@amd.com } 7087914SBrad.Beckmann@amd.com} 7097914SBrad.Beckmann@amd.com 7107914SBrad.Beckmann@amd.com// 7117914SBrad.Beckmann@amd.com// This function is executed when annotated work items end. Depending on 7127914SBrad.Beckmann@amd.com// what the user specified at the command line, the simulation may exit and/or 7137914SBrad.Beckmann@amd.com// take a checkpoint when a certain work item ends. 7147914SBrad.Beckmann@amd.com// 7157914SBrad.Beckmann@amd.comvoid 7167914SBrad.Beckmann@amd.comworkend(ThreadContext *tc, uint64_t workid, uint64_t threadid) 7177914SBrad.Beckmann@amd.com{ 7189733Sandreas@sandberg.pp.se DPRINTF(PseudoInst, "PseudoInst::workend(%i, %i)\n", workid, threadid); 7197914SBrad.Beckmann@amd.com System *sys = tc->getSystemPtr(); 7208580Ssteve.reinhardt@amd.com const System::Params *params = sys->params(); 72111270Sandreas.sandberg@arm.com 72211270Sandreas.sandberg@arm.com if (params->exit_on_work_items) { 72311270Sandreas.sandberg@arm.com exitSimLoop("workend", static_cast<int>(workid)); 72411270Sandreas.sandberg@arm.com return; 72511270Sandreas.sandberg@arm.com } 7267914SBrad.Beckmann@amd.com 7277914SBrad.Beckmann@amd.com DPRINTF(WorkItems, "Work End workid: %d, threadid %d\n", workid, threadid); 72811270Sandreas.sandberg@arm.com tc->getCpuPtr()->workItemEnd(); 72911270Sandreas.sandberg@arm.com sys->workItemEnd(threadid, workid); 7307914SBrad.Beckmann@amd.com 7317914SBrad.Beckmann@amd.com // 7327914SBrad.Beckmann@amd.com // If specified, determine if this is the specific work item the user 7337914SBrad.Beckmann@amd.com // identified 7347914SBrad.Beckmann@amd.com // 7358580Ssteve.reinhardt@amd.com if (params->work_item_id == -1 || params->work_item_id == workid) { 7367914SBrad.Beckmann@amd.com 7377914SBrad.Beckmann@amd.com uint64_t systemWorkEndCount = sys->incWorkItemsEnd(); 7387914SBrad.Beckmann@amd.com int cpuId = tc->getCpuPtr()->cpuId(); 7397914SBrad.Beckmann@amd.com 7408580Ssteve.reinhardt@amd.com if (params->work_cpus_ckpt_count != 0 && 7418580Ssteve.reinhardt@amd.com sys->markWorkItem(cpuId) >= params->work_cpus_ckpt_count) { 7427914SBrad.Beckmann@amd.com // 7437914SBrad.Beckmann@amd.com // If active cpus equals checkpoint count, create checkpoint 7447914SBrad.Beckmann@amd.com // 7458580Ssteve.reinhardt@amd.com exitSimLoop("checkpoint"); 7467914SBrad.Beckmann@amd.com } 7477914SBrad.Beckmann@amd.com 7488580Ssteve.reinhardt@amd.com if (params->work_end_ckpt_count != 0 && 7498580Ssteve.reinhardt@amd.com systemWorkEndCount == params->work_end_ckpt_count) { 7507914SBrad.Beckmann@amd.com // 7517914SBrad.Beckmann@amd.com // If total work items completed equals checkpoint count, create 7527914SBrad.Beckmann@amd.com // checkpoint 7537914SBrad.Beckmann@amd.com // 7548580Ssteve.reinhardt@amd.com exitSimLoop("checkpoint"); 7557914SBrad.Beckmann@amd.com } 7567914SBrad.Beckmann@amd.com 7578580Ssteve.reinhardt@amd.com if (params->work_end_exit_count != 0 && 7588580Ssteve.reinhardt@amd.com systemWorkEndCount == params->work_end_exit_count) { 7597914SBrad.Beckmann@amd.com // 7607914SBrad.Beckmann@amd.com // If total work items completed equals exit count, exit simulation 7617914SBrad.Beckmann@amd.com // 7628580Ssteve.reinhardt@amd.com exitSimLoop("work items exit count reached"); 7637914SBrad.Beckmann@amd.com } 7647914SBrad.Beckmann@amd.com } 7657914SBrad.Beckmann@amd.com} 7667914SBrad.Beckmann@amd.com 7677811Ssteve.reinhardt@amd.com} // namespace PseudoInst 768