pseudo_inst.cc (9681:4597012dfa97) | pseudo_inst.cc (9733:9d85dfa4696c) |
---|---|
1/* 2 * Copyright (c) 2010-2012 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 45 unchanged lines hidden (view full) --- 54#include "arch/vtophys.hh" 55#include "base/debug.hh" 56#include "base/output.hh" 57#include "config/the_isa.hh" 58#include "cpu/base.hh" 59#include "cpu/quiesce_event.hh" 60#include "cpu/thread_context.hh" 61#include "debug/Loader.hh" | 1/* 2 * Copyright (c) 2010-2012 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 45 unchanged lines hidden (view full) --- 54#include "arch/vtophys.hh" 55#include "base/debug.hh" 56#include "base/output.hh" 57#include "config/the_isa.hh" 58#include "cpu/base.hh" 59#include "cpu/quiesce_event.hh" 60#include "cpu/thread_context.hh" 61#include "debug/Loader.hh" |
62#include "debug/PseudoInst.hh" |
|
62#include "debug/Quiesce.hh" 63#include "debug/WorkItems.hh" 64#include "params/BaseCPU.hh" 65#include "sim/full_system.hh" 66#include "sim/pseudo_inst.hh" 67#include "sim/serialize.hh" 68#include "sim/sim_events.hh" 69#include "sim/sim_exit.hh" --- 15 unchanged lines hidden (view full) --- 85 panic("Pseudo inst \"%s\" is only available in Full System mode."); 86} 87 88uint64_t 89pseudoInst(ThreadContext *tc, uint8_t func, uint8_t subfunc) 90{ 91 uint64_t args[4]; 92 | 63#include "debug/Quiesce.hh" 64#include "debug/WorkItems.hh" 65#include "params/BaseCPU.hh" 66#include "sim/full_system.hh" 67#include "sim/pseudo_inst.hh" 68#include "sim/serialize.hh" 69#include "sim/sim_events.hh" 70#include "sim/sim_exit.hh" --- 15 unchanged lines hidden (view full) --- 86 panic("Pseudo inst \"%s\" is only available in Full System mode."); 87} 88 89uint64_t 90pseudoInst(ThreadContext *tc, uint8_t func, uint8_t subfunc) 91{ 92 uint64_t args[4]; 93 |
94 DPRINTF(PseudoInst, "PseudoInst::pseudoInst(%i, %i)\n", func, subfunc); 95 |
|
93 // We need to do this in a slightly convoluted way since 94 // getArgument() might have side-effects on arg_num. We could have 95 // used the Argument class, but due to the possible side effects 96 // from getArgument, it'd most likely break. 97 int arg_num(0); 98 for (int i = 0; i < sizeof(args) / sizeof(*args); ++i) 99 args[arg_num++] = getArgument(tc, arg_num, sizeof(uint64_t), false); 100 --- 98 unchanged lines hidden (view full) --- 199 } 200 201 return 0; 202} 203 204void 205arm(ThreadContext *tc) 206{ | 96 // We need to do this in a slightly convoluted way since 97 // getArgument() might have side-effects on arg_num. We could have 98 // used the Argument class, but due to the possible side effects 99 // from getArgument, it'd most likely break. 100 int arg_num(0); 101 for (int i = 0; i < sizeof(args) / sizeof(*args); ++i) 102 args[arg_num++] = getArgument(tc, arg_num, sizeof(uint64_t), false); 103 --- 98 unchanged lines hidden (view full) --- 202 } 203 204 return 0; 205} 206 207void 208arm(ThreadContext *tc) 209{ |
210 DPRINTF(PseudoInst, "PseudoInst::arm()\n"); |
|
207 if (!FullSystem) 208 panicFsOnlyPseudoInst("arm"); 209 210 if (tc->getKernelStats()) 211 tc->getKernelStats()->arm(); 212} 213 214void 215quiesce(ThreadContext *tc) 216{ | 211 if (!FullSystem) 212 panicFsOnlyPseudoInst("arm"); 213 214 if (tc->getKernelStats()) 215 tc->getKernelStats()->arm(); 216} 217 218void 219quiesce(ThreadContext *tc) 220{ |
221 DPRINTF(PseudoInst, "PseudoInst::quiesce()\n"); |
|
217 if (!FullSystem) 218 panicFsOnlyPseudoInst("quiesce"); 219 220 if (!tc->getCpuPtr()->params()->do_quiesce) 221 return; 222 223 DPRINTF(Quiesce, "%s: quiesce()\n", tc->getCpuPtr()->name()); 224 225 tc->suspend(); 226 if (tc->getKernelStats()) 227 tc->getKernelStats()->quiesce(); 228} 229 230void 231quiesceSkip(ThreadContext *tc) 232{ | 222 if (!FullSystem) 223 panicFsOnlyPseudoInst("quiesce"); 224 225 if (!tc->getCpuPtr()->params()->do_quiesce) 226 return; 227 228 DPRINTF(Quiesce, "%s: quiesce()\n", tc->getCpuPtr()->name()); 229 230 tc->suspend(); 231 if (tc->getKernelStats()) 232 tc->getKernelStats()->quiesce(); 233} 234 235void 236quiesceSkip(ThreadContext *tc) 237{ |
238 DPRINTF(PseudoInst, "PseudoInst::quiesceSkip()\n"); |
|
233 if (!FullSystem) 234 panicFsOnlyPseudoInst("quiesceSkip"); 235 236 BaseCPU *cpu = tc->getCpuPtr(); 237 238 if (!cpu->params()->do_quiesce) 239 return; 240 --- 9 unchanged lines hidden (view full) --- 250 tc->suspend(); 251 if (tc->getKernelStats()) 252 tc->getKernelStats()->quiesce(); 253} 254 255void 256quiesceNs(ThreadContext *tc, uint64_t ns) 257{ | 239 if (!FullSystem) 240 panicFsOnlyPseudoInst("quiesceSkip"); 241 242 BaseCPU *cpu = tc->getCpuPtr(); 243 244 if (!cpu->params()->do_quiesce) 245 return; 246 --- 9 unchanged lines hidden (view full) --- 256 tc->suspend(); 257 if (tc->getKernelStats()) 258 tc->getKernelStats()->quiesce(); 259} 260 261void 262quiesceNs(ThreadContext *tc, uint64_t ns) 263{ |
264 DPRINTF(PseudoInst, "PseudoInst::quiesceNs(%i)\n", ns); |
|
258 if (!FullSystem) 259 panicFsOnlyPseudoInst("quiesceNs"); 260 261 BaseCPU *cpu = tc->getCpuPtr(); 262 263 if (!cpu->params()->do_quiesce || ns == 0) 264 return; 265 --- 9 unchanged lines hidden (view full) --- 275 tc->suspend(); 276 if (tc->getKernelStats()) 277 tc->getKernelStats()->quiesce(); 278} 279 280void 281quiesceCycles(ThreadContext *tc, uint64_t cycles) 282{ | 265 if (!FullSystem) 266 panicFsOnlyPseudoInst("quiesceNs"); 267 268 BaseCPU *cpu = tc->getCpuPtr(); 269 270 if (!cpu->params()->do_quiesce || ns == 0) 271 return; 272 --- 9 unchanged lines hidden (view full) --- 282 tc->suspend(); 283 if (tc->getKernelStats()) 284 tc->getKernelStats()->quiesce(); 285} 286 287void 288quiesceCycles(ThreadContext *tc, uint64_t cycles) 289{ |
290 DPRINTF(PseudoInst, "PseudoInst::quiesceCycles(%i)\n", cycles); |
|
283 if (!FullSystem) 284 panicFsOnlyPseudoInst("quiesceCycles"); 285 286 BaseCPU *cpu = tc->getCpuPtr(); 287 288 if (!cpu->params()->do_quiesce || cycles == 0) 289 return; 290 --- 9 unchanged lines hidden (view full) --- 300 tc->suspend(); 301 if (tc->getKernelStats()) 302 tc->getKernelStats()->quiesce(); 303} 304 305uint64_t 306quiesceTime(ThreadContext *tc) 307{ | 291 if (!FullSystem) 292 panicFsOnlyPseudoInst("quiesceCycles"); 293 294 BaseCPU *cpu = tc->getCpuPtr(); 295 296 if (!cpu->params()->do_quiesce || cycles == 0) 297 return; 298 --- 9 unchanged lines hidden (view full) --- 308 tc->suspend(); 309 if (tc->getKernelStats()) 310 tc->getKernelStats()->quiesce(); 311} 312 313uint64_t 314quiesceTime(ThreadContext *tc) 315{ |
316 DPRINTF(PseudoInst, "PseudoInst::quiesceTime()\n"); |
|
308 if (!FullSystem) { 309 panicFsOnlyPseudoInst("quiesceTime"); 310 return 0; 311 } 312 313 return (tc->readLastActivate() - tc->readLastSuspend()) / 314 SimClock::Int::ns; 315} 316 317uint64_t 318rpns(ThreadContext *tc) 319{ | 317 if (!FullSystem) { 318 panicFsOnlyPseudoInst("quiesceTime"); 319 return 0; 320 } 321 322 return (tc->readLastActivate() - tc->readLastSuspend()) / 323 SimClock::Int::ns; 324} 325 326uint64_t 327rpns(ThreadContext *tc) 328{ |
329 DPRINTF(PseudoInst, "PseudoInst::rpns()\n"); |
|
320 return curTick() / SimClock::Int::ns; 321} 322 323void 324wakeCPU(ThreadContext *tc, uint64_t cpuid) 325{ | 330 return curTick() / SimClock::Int::ns; 331} 332 333void 334wakeCPU(ThreadContext *tc, uint64_t cpuid) 335{ |
336 DPRINTF(PseudoInst, "PseudoInst::wakeCPU(%i)\n", cpuid); |
|
326 System *sys = tc->getSystemPtr(); 327 ThreadContext *other_tc = sys->threadContexts[cpuid]; 328 if (other_tc->status() == ThreadContext::Suspended) 329 other_tc->activate(); 330} 331 332void 333m5exit(ThreadContext *tc, Tick delay) 334{ | 337 System *sys = tc->getSystemPtr(); 338 ThreadContext *other_tc = sys->threadContexts[cpuid]; 339 if (other_tc->status() == ThreadContext::Suspended) 340 other_tc->activate(); 341} 342 343void 344m5exit(ThreadContext *tc, Tick delay) 345{ |
346 DPRINTF(PseudoInst, "PseudoInst::m5exit(%i)\n", delay); |
|
335 Tick when = curTick() + delay * SimClock::Int::ns; 336 exitSimLoop("m5_exit instruction encountered", 0, when); 337} 338 339void 340m5fail(ThreadContext *tc, Tick delay, uint64_t code) 341{ | 347 Tick when = curTick() + delay * SimClock::Int::ns; 348 exitSimLoop("m5_exit instruction encountered", 0, when); 349} 350 351void 352m5fail(ThreadContext *tc, Tick delay, uint64_t code) 353{ |
354 DPRINTF(PseudoInst, "PseudoInst::m5fail(%i, %i)\n", delay, code); |
|
342 Tick when = curTick() + delay * SimClock::Int::ns; 343 exitSimLoop("m5_fail instruction encountered", code, when); 344} 345 346void 347loadsymbol(ThreadContext *tc) 348{ | 355 Tick when = curTick() + delay * SimClock::Int::ns; 356 exitSimLoop("m5_fail instruction encountered", code, when); 357} 358 359void 360loadsymbol(ThreadContext *tc) 361{ |
362 DPRINTF(PseudoInst, "PseudoInst::loadsymbol()\n"); |
|
349 if (!FullSystem) 350 panicFsOnlyPseudoInst("loadsymbol"); 351 352 const string &filename = tc->getCpuPtr()->system->params()->symbolfile; 353 if (filename.empty()) { 354 return; 355 } 356 --- 35 unchanged lines hidden (view full) --- 392 DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); 393 } 394 file.close(); 395} 396 397void 398addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr) 399{ | 363 if (!FullSystem) 364 panicFsOnlyPseudoInst("loadsymbol"); 365 366 const string &filename = tc->getCpuPtr()->system->params()->symbolfile; 367 if (filename.empty()) { 368 return; 369 } 370 --- 35 unchanged lines hidden (view full) --- 406 DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); 407 } 408 file.close(); 409} 410 411void 412addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr) 413{ |
414 DPRINTF(PseudoInst, "PseudoInst::addsymbol(0x%x, 0x%x)\n", 415 addr, symbolAddr); |
|
400 if (!FullSystem) 401 panicFsOnlyPseudoInst("addSymbol"); 402 403 char symb[100]; 404 CopyStringOut(tc, symb, symbolAddr, 100); 405 std::string symbol(symb); 406 407 DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); 408 409 tc->getSystemPtr()->kernelSymtab->insert(addr,symbol); 410 debugSymbolTable->insert(addr,symbol); 411} 412 413uint64_t 414initParam(ThreadContext *tc) 415{ | 416 if (!FullSystem) 417 panicFsOnlyPseudoInst("addSymbol"); 418 419 char symb[100]; 420 CopyStringOut(tc, symb, symbolAddr, 100); 421 std::string symbol(symb); 422 423 DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); 424 425 tc->getSystemPtr()->kernelSymtab->insert(addr,symbol); 426 debugSymbolTable->insert(addr,symbol); 427} 428 429uint64_t 430initParam(ThreadContext *tc) 431{ |
432 DPRINTF(PseudoInst, "PseudoInst::initParam()\n"); |
|
416 if (!FullSystem) { 417 panicFsOnlyPseudoInst("initParam"); 418 return 0; 419 } 420 421 return tc->getCpuPtr()->system->init_param; 422} 423 424 425void 426resetstats(ThreadContext *tc, Tick delay, Tick period) 427{ | 433 if (!FullSystem) { 434 panicFsOnlyPseudoInst("initParam"); 435 return 0; 436 } 437 438 return tc->getCpuPtr()->system->init_param; 439} 440 441 442void 443resetstats(ThreadContext *tc, Tick delay, Tick period) 444{ |
445 DPRINTF(PseudoInst, "PseudoInst::resetstats(%i, %i)\n", delay, period); |
|
428 if (!tc->getCpuPtr()->params()->do_statistics_insts) 429 return; 430 431 432 Tick when = curTick() + delay * SimClock::Int::ns; 433 Tick repeat = period * SimClock::Int::ns; 434 435 Stats::schedStatEvent(false, true, when, repeat); 436} 437 438void 439dumpstats(ThreadContext *tc, Tick delay, Tick period) 440{ | 446 if (!tc->getCpuPtr()->params()->do_statistics_insts) 447 return; 448 449 450 Tick when = curTick() + delay * SimClock::Int::ns; 451 Tick repeat = period * SimClock::Int::ns; 452 453 Stats::schedStatEvent(false, true, when, repeat); 454} 455 456void 457dumpstats(ThreadContext *tc, Tick delay, Tick period) 458{ |
459 DPRINTF(PseudoInst, "PseudoInst::dumpstats(%i, %i)\n", delay, period); |
|
441 if (!tc->getCpuPtr()->params()->do_statistics_insts) 442 return; 443 444 445 Tick when = curTick() + delay * SimClock::Int::ns; 446 Tick repeat = period * SimClock::Int::ns; 447 448 Stats::schedStatEvent(true, false, when, repeat); 449} 450 451void 452dumpresetstats(ThreadContext *tc, Tick delay, Tick period) 453{ | 460 if (!tc->getCpuPtr()->params()->do_statistics_insts) 461 return; 462 463 464 Tick when = curTick() + delay * SimClock::Int::ns; 465 Tick repeat = period * SimClock::Int::ns; 466 467 Stats::schedStatEvent(true, false, when, repeat); 468} 469 470void 471dumpresetstats(ThreadContext *tc, Tick delay, Tick period) 472{ |
473 DPRINTF(PseudoInst, "PseudoInst::dumpresetstats(%i, %i)\n", delay, period); |
|
454 if (!tc->getCpuPtr()->params()->do_statistics_insts) 455 return; 456 457 458 Tick when = curTick() + delay * SimClock::Int::ns; 459 Tick repeat = period * SimClock::Int::ns; 460 461 Stats::schedStatEvent(true, true, when, repeat); 462} 463 464void 465m5checkpoint(ThreadContext *tc, Tick delay, Tick period) 466{ | 474 if (!tc->getCpuPtr()->params()->do_statistics_insts) 475 return; 476 477 478 Tick when = curTick() + delay * SimClock::Int::ns; 479 Tick repeat = period * SimClock::Int::ns; 480 481 Stats::schedStatEvent(true, true, when, repeat); 482} 483 484void 485m5checkpoint(ThreadContext *tc, Tick delay, Tick period) 486{ |
487 DPRINTF(PseudoInst, "PseudoInst::m5checkpoint(%i, %i)\n", delay, period); |
|
467 if (!tc->getCpuPtr()->params()->do_checkpoint_insts) 468 return; 469 470 Tick when = curTick() + delay * SimClock::Int::ns; 471 Tick repeat = period * SimClock::Int::ns; 472 473 exitSimLoop("checkpoint", 0, when, repeat); 474} 475 476uint64_t 477readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset) 478{ | 488 if (!tc->getCpuPtr()->params()->do_checkpoint_insts) 489 return; 490 491 Tick when = curTick() + delay * SimClock::Int::ns; 492 Tick repeat = period * SimClock::Int::ns; 493 494 exitSimLoop("checkpoint", 0, when, repeat); 495} 496 497uint64_t 498readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset) 499{ |
500 DPRINTF(PseudoInst, "PseudoInst::readfile(0x%x, 0x%x, 0x%x)\n", 501 vaddr, len, offset); |
|
479 if (!FullSystem) { 480 panicFsOnlyPseudoInst("readfile"); 481 return 0; 482 } 483 484 const string &file = tc->getSystemPtr()->params()->readfile; 485 if (file.empty()) { 486 return ULL(0); --- 25 unchanged lines hidden (view full) --- 512 delete [] buf; 513 return result; 514} 515 516uint64_t 517writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset, 518 Addr filename_addr) 519{ | 502 if (!FullSystem) { 503 panicFsOnlyPseudoInst("readfile"); 504 return 0; 505 } 506 507 const string &file = tc->getSystemPtr()->params()->readfile; 508 if (file.empty()) { 509 return ULL(0); --- 25 unchanged lines hidden (view full) --- 535 delete [] buf; 536 return result; 537} 538 539uint64_t 540writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset, 541 Addr filename_addr) 542{ |
543 DPRINTF(PseudoInst, "PseudoInst::writefile(0x%x, 0x%x, 0x%x, 0x%x)\n", 544 vaddr, len, offset, filename_addr); |
|
520 ostream *os; 521 522 // copy out target filename 523 char fn[100]; 524 std::string filename; 525 CopyStringOut(tc, fn, filename_addr, 100); 526 filename = std::string(fn); 527 --- 25 unchanged lines hidden (view full) --- 553 delete [] buf; 554 555 return len; 556} 557 558void 559debugbreak(ThreadContext *tc) 560{ | 545 ostream *os; 546 547 // copy out target filename 548 char fn[100]; 549 std::string filename; 550 CopyStringOut(tc, fn, filename_addr, 100); 551 filename = std::string(fn); 552 --- 25 unchanged lines hidden (view full) --- 578 delete [] buf; 579 580 return len; 581} 582 583void 584debugbreak(ThreadContext *tc) 585{ |
586 DPRINTF(PseudoInst, "PseudoInst::debugbreak()\n"); |
|
561 Debug::breakpoint(); 562} 563 564void 565switchcpu(ThreadContext *tc) 566{ | 587 Debug::breakpoint(); 588} 589 590void 591switchcpu(ThreadContext *tc) 592{ |
593 DPRINTF(PseudoInst, "PseudoInst::switchcpu()\n"); |
|
567 exitSimLoop("switchcpu"); 568} 569 570// 571// This function is executed when annotated work items begin. Depending on 572// what the user specified at the command line, the simulation may exit and/or 573// take a checkpoint when a certain work item begins. 574// 575void 576workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid) 577{ | 594 exitSimLoop("switchcpu"); 595} 596 597// 598// This function is executed when annotated work items begin. Depending on 599// what the user specified at the command line, the simulation may exit and/or 600// take a checkpoint when a certain work item begins. 601// 602void 603workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid) 604{ |
605 DPRINTF(PseudoInst, "PseudoInst::workbegin(%i, %i)\n", workid, threadid); |
|
578 tc->getCpuPtr()->workItemBegin(); 579 System *sys = tc->getSystemPtr(); 580 const System::Params *params = sys->params(); 581 sys->workItemBegin(threadid, workid); 582 583 DPRINTF(WorkItems, "Work Begin workid: %d, threadid %d\n", workid, 584 threadid); 585 --- 41 unchanged lines hidden (view full) --- 627// 628// This function is executed when annotated work items end. Depending on 629// what the user specified at the command line, the simulation may exit and/or 630// take a checkpoint when a certain work item ends. 631// 632void 633workend(ThreadContext *tc, uint64_t workid, uint64_t threadid) 634{ | 606 tc->getCpuPtr()->workItemBegin(); 607 System *sys = tc->getSystemPtr(); 608 const System::Params *params = sys->params(); 609 sys->workItemBegin(threadid, workid); 610 611 DPRINTF(WorkItems, "Work Begin workid: %d, threadid %d\n", workid, 612 threadid); 613 --- 41 unchanged lines hidden (view full) --- 655// 656// This function is executed when annotated work items end. Depending on 657// what the user specified at the command line, the simulation may exit and/or 658// take a checkpoint when a certain work item ends. 659// 660void 661workend(ThreadContext *tc, uint64_t workid, uint64_t threadid) 662{ |
663 DPRINTF(PseudoInst, "PseudoInst::workend(%i, %i)\n", workid, threadid); |
|
635 tc->getCpuPtr()->workItemEnd(); 636 System *sys = tc->getSystemPtr(); 637 const System::Params *params = sys->params(); 638 sys->workItemEnd(threadid, workid); 639 640 DPRINTF(WorkItems, "Work End workid: %d, threadid %d\n", workid, threadid); 641 642 // --- 36 unchanged lines hidden --- | 664 tc->getCpuPtr()->workItemEnd(); 665 System *sys = tc->getSystemPtr(); 666 const System::Params *params = sys->params(); 667 sys->workItemEnd(threadid, workid); 668 669 DPRINTF(WorkItems, "Work End workid: %d, threadid %d\n", workid, threadid); 670 671 // --- 36 unchanged lines hidden --- |