base.hh (12277:e6455b421c4b) base.hh (12284:b91c036913da)
1/*
2 * Copyright (c) 2011-2013, 2017 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

--- 49 unchanged lines hidden (view full) ---

58#include "arch/isa_traits.hh"
59#include "arch/microcode_rom.hh"
60#include "base/statistics.hh"
61#include "mem/mem_object.hh"
62#include "sim/eventq.hh"
63#include "sim/full_system.hh"
64#include "sim/insttracer.hh"
65#include "sim/probe/pmu.hh"
1/*
2 * Copyright (c) 2011-2013, 2017 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

--- 49 unchanged lines hidden (view full) ---

58#include "arch/isa_traits.hh"
59#include "arch/microcode_rom.hh"
60#include "base/statistics.hh"
61#include "mem/mem_object.hh"
62#include "sim/eventq.hh"
63#include "sim/full_system.hh"
64#include "sim/insttracer.hh"
65#include "sim/probe/pmu.hh"
66#include "sim/probe/probe.hh"
66#include "sim/system.hh"
67#include "debug/Mwait.hh"
68
69class BaseCPU;
70struct BaseCPUParams;
71class CheckerCPU;
72class ThreadContext;
73

--- 198 unchanged lines hidden (view full) ---

272 /// Notify the CPU that the indicated context is now active.
273 virtual void activateContext(ThreadID thread_num);
274
275 /// Notify the CPU that the indicated context is now suspended.
276 /// Check if possible to enter a lower power state
277 virtual void suspendContext(ThreadID thread_num);
278
279 /// Notify the CPU that the indicated context is now halted.
67#include "sim/system.hh"
68#include "debug/Mwait.hh"
69
70class BaseCPU;
71struct BaseCPUParams;
72class CheckerCPU;
73class ThreadContext;
74

--- 198 unchanged lines hidden (view full) ---

273 /// Notify the CPU that the indicated context is now active.
274 virtual void activateContext(ThreadID thread_num);
275
276 /// Notify the CPU that the indicated context is now suspended.
277 /// Check if possible to enter a lower power state
278 virtual void suspendContext(ThreadID thread_num);
279
280 /// Notify the CPU that the indicated context is now halted.
280 virtual void haltContext(ThreadID thread_num) {}
281 virtual void haltContext(ThreadID thread_num);
281
282 /// Given a Thread Context pointer return the thread num
283 int findContext(ThreadContext *tc);
284
285 /// Given a thread num get tho thread context for it
286 virtual ThreadContext *getContext(int tn) { return threadContexts[tn]; }
287
288 /// Get the number of thread contexts available

--- 195 unchanged lines hidden (view full) ---

484 /**
485 * Helper method to trigger PMU probes for a committed
486 * instruction.
487 *
488 * @param inst Instruction that just committed
489 */
490 virtual void probeInstCommit(const StaticInstPtr &inst);
491
282
283 /// Given a Thread Context pointer return the thread num
284 int findContext(ThreadContext *tc);
285
286 /// Given a thread num get tho thread context for it
287 virtual ThreadContext *getContext(int tn) { return threadContexts[tn]; }
288
289 /// Get the number of thread contexts available

--- 195 unchanged lines hidden (view full) ---

485 /**
486 * Helper method to trigger PMU probes for a committed
487 * instruction.
488 *
489 * @param inst Instruction that just committed
490 */
491 virtual void probeInstCommit(const StaticInstPtr &inst);
492
493 protected:
492 /**
493 * Helper method to instantiate probe points belonging to this
494 * object.
495 *
496 * @param name Name of the probe point.
497 * @return A unique_ptr to the new probe point.
498 */
499 ProbePoints::PMUUPtr pmuProbePoint(const char *name);
500
494 /**
495 * Helper method to instantiate probe points belonging to this
496 * object.
497 *
498 * @param name Name of the probe point.
499 * @return A unique_ptr to the new probe point.
500 */
501 ProbePoints::PMUUPtr pmuProbePoint(const char *name);
502
501 /** CPU cycle counter */
502 ProbePoints::PMUUPtr ppCycles;
503
504 /**
505 * Instruction commit probe point.
506 *
507 * This probe point is triggered whenever one or more instructions
508 * are committed. It is normally triggered once for every
509 * instruction. However, CPU models committing bundles of
510 * instructions may call notify once for the entire bundle.
511 */
512 ProbePoints::PMUUPtr ppRetiredInsts;
513
514 /** Retired load instructions */
515 ProbePoints::PMUUPtr ppRetiredLoads;
516 /** Retired store instructions */
517 ProbePoints::PMUUPtr ppRetiredStores;
518
519 /** Retired branches (any type) */
520 ProbePoints::PMUUPtr ppRetiredBranches;
521
503 /**
504 * Instruction commit probe point.
505 *
506 * This probe point is triggered whenever one or more instructions
507 * are committed. It is normally triggered once for every
508 * instruction. However, CPU models committing bundles of
509 * instructions may call notify once for the entire bundle.
510 */
511 ProbePoints::PMUUPtr ppRetiredInsts;
512
513 /** Retired load instructions */
514 ProbePoints::PMUUPtr ppRetiredLoads;
515 /** Retired store instructions */
516 ProbePoints::PMUUPtr ppRetiredStores;
517
518 /** Retired branches (any type) */
519 ProbePoints::PMUUPtr ppRetiredBranches;
520
521 /** CPU cycle counter even if any thread Context is suspended*/
522 ProbePoints::PMUUPtr ppAllCycles;
523
524 /** CPU cycle counter, only counts if any thread contexts is active **/
525 ProbePoints::PMUUPtr ppActiveCycles;
526
527 /**
528 * ProbePoint that signals transitions of threadContexts sets.
529 * The ProbePoint reports information through it bool parameter.
530 * - If the parameter is true then the last enabled threadContext of the
531 * CPU object was disabled.
532 * - If the parameter is false then a threadContext was enabled, all the
533 * remaining threadContexts are disabled.
534 */
535 ProbePointArg<bool> *ppSleeping;
522 /** @} */
523
536 /** @} */
537
538 enum CPUState {
539 CPU_STATE_ON,
540 CPU_STATE_SLEEP,
541 CPU_STATE_WAKEUP
542 };
524
543
544 Cycles previousCycle;
545 CPUState previousState;
525
546
547 /** base method keeping track of cycle progression **/
548 inline void updateCycleCounters(CPUState state)
549 {
550 uint32_t delta = curCycle() - previousCycle;
551
552 if (previousState == CPU_STATE_ON) {
553 ppActiveCycles->notify(delta);
554 }
555
556 switch (state)
557 {
558 case CPU_STATE_WAKEUP:
559 ppSleeping->notify(false);
560 break;
561 case CPU_STATE_SLEEP:
562 ppSleeping->notify(true);
563 break;
564 default:
565 break;
566 }
567
568 ppAllCycles->notify(delta);
569
570 previousCycle = curCycle();
571 previousState = state;
572 }
573
526 // Function tracing
527 private:
528 bool functionTracingEnabled;
529 std::ostream *functionTraceStream;
530 Addr currentFunctionStart;
531 Addr currentFunctionEnd;
532 Tick functionEntryTick;
533 void enableFunctionTrace();

--- 70 unchanged lines hidden ---
574 // Function tracing
575 private:
576 bool functionTracingEnabled;
577 std::ostream *functionTraceStream;
578 Addr currentFunctionStart;
579 Addr currentFunctionEnd;
580 Tick functionEntryTick;
581 void enableFunctionTrace();

--- 70 unchanged lines hidden ---