gem5 v24.0.0.0
Loading...
Searching...
No Matches
pmu.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2014, 2017-2019, 2022-2023 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
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met: redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer;
18 * redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution;
21 * neither the name of the copyright holders nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#include "arch/arm/pmu.hh"
39
40#include "arch/arm/isa.hh"
41#include "arch/arm/utility.hh"
42#include "base/trace.hh"
43#include "cpu/base.hh"
44#include "debug/Checkpoint.hh"
45#include "debug/PMUVerbose.hh"
46#include "dev/arm/base_gic.hh"
48#include "params/ArmPMU.hh"
49#include "sim/sim_exit.hh"
50
51namespace gem5
52{
53
54namespace ArmISA {
55
56const RegVal PMU::reg_pmcr_wr_mask = 0x39;
57
58PMU::PMU(const ArmPMUParams &p)
60 use64bitCounters(p.use64bitCounters),
61 reg_pmcnten(0), reg_pmcr(0),
62 reg_pmselr(0), reg_pminten(0), reg_pmovsr(0),
63 reg_pmceid0(0),reg_pmceid1(0),
64 clock_remainder(0),
65 maximumCounterCount(p.eventCounters),
66 cycleCounter(*this, maximumCounterCount, p.use64bitCounters),
67 cycleCounterEventId(p.cycleEventId),
68 swIncrementEvent(nullptr),
69 reg_pmcr_conf(0),
70 interrupt(nullptr),
71 exitOnPMUControl(p.exitOnPMUControl),
72 exitOnPMUInterrupt(p.exitOnPMUInterrupt)
73{
74 DPRINTF(PMUVerbose, "Initializing the PMU.\n");
75
76 if (maximumCounterCount > 31) {
77 fatal("The PMU can only accept 31 counters, %d counters requested.\n",
79 }
80
81 warn_if(!p.interrupt, "ARM PMU: No interrupt specified, interrupt " \
82 "delivery disabled.\n");
83
84 /* Setup the performance counter ID registers */
85 reg_pmcr_conf.imp = 0x41; // ARM Ltd.
86 reg_pmcr_conf.idcode = 0x00;
87 reg_pmcr_conf.n = p.eventCounters;
88
89 // Setup the hard-coded cycle counter, which is equivalent to
90 // architected counter event type 0x11.
91 cycleCounter.eventId = 0x11;
92}
93
95{
96}
97
98void
100{
101 DPRINTF(PMUVerbose, "Assigning PMU to ContextID %i.\n", tc->contextId());
102 const auto &pmu_params = static_cast<const ArmPMUParams &>(params());
103
104 if (pmu_params.interrupt)
105 interrupt = pmu_params.interrupt->get(tc);
106}
107
108void
110{
111 auto old_event = eventMap.find(id);
112 DPRINTF(PMUVerbose, "PMU: Adding SW increment event with id '0x%x'\n", id);
113
114 if (swIncrementEvent) {
115 fatal_if(old_event == eventMap.end() ||
116 old_event->second != swIncrementEvent,
117 "Trying to add a software increment event with multiple"
118 "IDs. This is not supported.\n");
119 return;
120 }
121
122 fatal_if(old_event != eventMap.end(), "An event with id %d has "
123 "been previously defined\n", id);
124
125 swIncrementEvent = std::make_shared<SWIncrementEvent>();
127 registerEvent(id);
128}
129
130void
131PMU::addEventProbe(unsigned int id, SimObject *obj, const char *probe_name)
132{
133
134 DPRINTF(PMUVerbose, "PMU: Adding Probe Driven event with id '0x%x'"
135 "as probe %s:%s\n",id, obj->name(), probe_name);
136
137 std::shared_ptr<RegularEvent> event;
138 auto event_entry = eventMap.find(id);
139 if (event_entry == eventMap.end()) {
140 event = std::make_shared<RegularEvent>();
141 eventMap[id] = event;
142 } else {
143 event = std::dynamic_pointer_cast<RegularEvent>(event_entry->second);
144 fatal_if(!event, "Event with id %d is not probe driven\n", id);
145 }
146 event->addMicroarchitectureProbe(obj, probe_name);
147
148 registerEvent(id);
149
150}
151
152void
154{
155 // Flag the event as available in the corresponding PMCEID register if it
156 // is an architected event.
157 if (id < 0x20) {
158 reg_pmceid0 |= ((uint64_t)1) << id;
159 } else if (id > 0x20 && id < 0x40) {
160 reg_pmceid1 |= ((uint64_t)1) << (id - 0x20);
161 } else if (id >= 0x4000 && id < 0x4020) {
162 reg_pmceid0 |= ((uint64_t)1) << (id - 0x4000 + 32);
163 } else if (id >= 0x4020 && id < 0x4040) {
164 reg_pmceid1 |= ((uint64_t)1) << (id - 0x4020 + 32);
165 }
166}
167
168void
170{
171 // Re-attach enabled counters after a resume in case they changed.
173}
174
175void
177{
178
179 // at this stage all probe configurations are done
180 // counters can be configured
181 for (uint32_t index = 0; index < maximumCounterCount-1; index++) {
182 counters.emplace_back(*this, index, use64bitCounters);
183 }
184
185 std::shared_ptr<PMUEvent> event = getEvent(cycleCounterEventId);
186 panic_if(!event, "core cycle event is not present\n");
187 cycleCounter.enabled = true;
189}
190
191void
193{
194 DPRINTF(PMUVerbose, "setMiscReg(%s, 0x%x)\n",
195 miscRegName[unflattenMiscReg(misc_reg)], val);
196
197 switch (unflattenMiscReg(misc_reg)) {
198 case MISCREG_PMCR_EL0:
199 case MISCREG_PMCR:
201 return;
202
205 reg_pmcnten |= val;
207 return;
208
211 reg_pmcnten &= ~val;
213 return;
214
216 case MISCREG_PMOVSR:
218 return;
219
221 case MISCREG_PMSWINC:
222 if (swIncrementEvent) {
223 swIncrementEvent->write(val);
224 }
225 return;
226
228 case MISCREG_PMCCNTR:
230 return;
231
233 case MISCREG_PMSELR:
234 reg_pmselr = val;
235 return;
236 //TODO: implement MISCREF_PMCEID{2,3}
238 case MISCREG_PMCEID0:
240 case MISCREG_PMCEID1:
241 // Ignore writes
242 return;
243
244 case MISCREG_PMEVTYPER0_EL0...MISCREG_PMEVTYPER5_EL0:
246 return;
247
250 DPRINTF(PMUVerbose, "Setting PMCCFILTR: 0x%x\n", val);
252 return;
253
257 DPRINTF(PMUVerbose, "Setting counter type: "
258 "[PMSELR: 0x%x, PMSELER.sel: 0x%x, EVTYPER: 0x%x]\n",
261 return;
262
263 case MISCREG_PMEVCNTR0_EL0...MISCREG_PMEVCNTR5_EL0:
265 return;
266
270 return;
271
274 // TODO
275 break;
276
279 reg_pminten |= val;
280 return;
281
284 reg_pminten &= ~val;
285 return;
286
288 case MISCREG_PMOVSSET:
290 return;
291
292 default:
293 panic("Unexpected PMU register: %i\n", miscRegName[misc_reg]);
294 }
295
296 warn("Not doing anything for write to miscreg %s\n",
297 miscRegName[misc_reg]);
298}
299
300RegVal
301PMU::readMiscReg(int misc_reg)
302{
303 RegVal val(readMiscRegInt(misc_reg));
304 DPRINTF(PMUVerbose, "readMiscReg(%s): 0x%x\n",
305 miscRegName[unflattenMiscReg(misc_reg)], val);
306 return val;
307}
308
309RegVal
311{
312 misc_reg = unflattenMiscReg(misc_reg);
313 switch (misc_reg) {
314 case MISCREG_PMCR_EL0:
315 case MISCREG_PMCR:
317
322 return reg_pmcnten;
323
326 case MISCREG_PMOVSR: // Overflow Status Register
327 case MISCREG_PMOVSSET:
328 return reg_pmovsr;
329
331 case MISCREG_PMSWINC: // Software Increment Register (RAZ)
332 return 0;
333
335 case MISCREG_PMSELR:
336 return reg_pmselr;
337
339 return reg_pmceid0;
340
342 return reg_pmceid1;
343
344 //TODO: implement MISCREF_PMCEID{2,3}
345 case MISCREG_PMCEID0: // Common Event ID register
346 return reg_pmceid0 & 0xFFFFFFFF;
347
348 case MISCREG_PMCEID1: // Common Event ID register
349 return reg_pmceid1 & 0xFFFFFFFF;
350
352 return cycleCounter.getValue();
353
354 case MISCREG_PMCCNTR:
355 return cycleCounter.getValue() & 0xFFFFFFFF;
356
357 case MISCREG_PMEVTYPER0_EL0...MISCREG_PMEVTYPER5_EL0:
359
363
368
369 case MISCREG_PMEVCNTR0_EL0...MISCREG_PMEVCNTR5_EL0: {
370 return getCounterValue(misc_reg - MISCREG_PMEVCNTR0_EL0) &
371 0xFFFFFFFF;
372
373 }
374
377 return getCounterValue(reg_pmselr.sel) & 0xFFFFFFFF;
378
381 // TODO
382 return 0;
383
388 return reg_pminten;
389
390 default:
391 panic("Unexpected PMU register: %i\n", miscRegName[misc_reg]);
392 }
393
394 warn("Not doing anything for read from miscreg %s\n",
395 miscRegName[misc_reg]);
396 return 0;
397}
398
399void
401{
402 DPRINTF(PMUVerbose, "Set Control Reg 0x%08x.\n", val);
403
404 if (val.p) {
405 DPRINTF(PMUVerbose, "PMU reset all events to zero.\n");
407 }
408
409 if (val.c) {
410 DPRINTF(PMUVerbose, "PMU reset cycle counter to zero.\n");
412 }
413
414 // Reset the clock remainder if divide by 64-mode is toggled.
415 if (reg_pmcr.d != val.d)
416 clock_remainder = 0;
417
418 // Optionally exit the simulation on various PMU control events.
419 // Exit on enable/disable takes precedence over exit on reset.
420 if (exitOnPMUControl) {
421 if (!reg_pmcr.e && val.e) {
422 inform("Exiting simulation: PMU enable detected");
423 exitSimLoop("performance counter enabled", 0);
424 } else if (reg_pmcr.e && !val.e) {
425 inform("Exiting simulation: PMU disable detected");
426 exitSimLoop("performance counter disabled", 0);
427 } else if (val.p) {
428 inform("Exiting simulation: PMU reset detected");
429 exitSimLoop("performance counter reset", 0);
430 }
431 }
432
435}
436
437void
439{
440 const bool global_enable(reg_pmcr.e);
441
442 for (int i = 0; i < counters.size(); ++i) {
443 CounterState &ctr(counters[i]);
444 const bool enable(global_enable && (reg_pmcnten & (1 << i)));
445 if (ctr.enabled != enable) {
446 ctr.enabled = enable;
447 updateCounter(ctr);
448 }
449 }
450
451 const bool ccntr_enable(global_enable && (reg_pmcnten & (1 << PMCCNTR)));
452 if (cycleCounter.enabled != ccntr_enable) {
453 cycleCounter.enabled = ccntr_enable;
455 }
456}
457
458void
460{
461 if (userCounters.empty()) {
462 enable();
463 }
464 userCounters.insert(user);
466}
467
468void
470{
471 for (auto& counter: userCounters) {
472 counter->add(val);
473 }
474}
475
476void
478{
479 userCounters.erase(user);
480
481 if (userCounters.empty()) {
482 disable();
483 }
484}
485
486void
488{
489 parentEvent->increment(val);
490}
491
492void
494{
495 for (auto& subEvents: microArchitectureEventSet) {
496 attachedProbePointList.emplace_back(
497 new RegularProbe(this, subEvents.first, subEvents.second));
498 }
499}
500
501void
503{
504 attachedProbePointList.clear();
505}
506
507bool
509{
510 assert(pmu.isa);
511
512 const PMEVTYPER_t filter(this->filter);
513 const ExceptionLevel el(pmu.isa->currEL());
514 const bool secure(pmu.isa->inSecureState());
515
516 switch (el) {
517 case EL0:
518 return secure ? filter.u : (filter.u != filter.nsu);
519
520 case EL1:
521 return secure ? filter.p : (filter.p != filter.nsk);
522
523 case EL2:
524 return !filter.nsh;
525
526 case EL3:
527 return filter.p != filter.m;
528
529 default:
530 panic("Unexpected execution level in PMU::isFiltered.\n");
531 }
532}
533
534void
536{
537 if (sourceEvent) {
538 sourceEvent->detachEvent(this);
539 sourceEvent = nullptr;
540 } else {
541 debugCounter("detaching event not currently attached"
542 " to any event\n");
543 }
544}
545
546void
547PMU::CounterState::attach(const std::shared_ptr<PMUEvent> &event)
548{
549 if (!resetValue) {
550 value = 0;
551 resetValue = true;
552 }
553 sourceEvent = event;
554 sourceEvent->attachEvent(this);
555}
556
557uint64_t
559{
560 if (sourceEvent) {
561 sourceEvent->updateAttachedCounters();
562 } else {
563 debugCounter("attempted to get value from a counter without"
564 " an associated event\n");
565 }
566 return value;
567}
568
569void
571{
572 value = val;
573 resetValue = true;
574
575 if (sourceEvent) {
576 sourceEvent->updateAttachedCounters();
577 } else {
578 debugCounter("attempted to set value from a counter without"
579 " an associated event\n");
580 }
581}
582
583void
585{
586 if (!ctr.enabled) {
587 DPRINTF(PMUVerbose, "updateCounter(%i): Disabling counter\n",
588 ctr.getCounterId());
589 ctr.detach();
590
591 } else {
592 DPRINTF(PMUVerbose, "updateCounter(%i): Enable event id 0x%x\n",
593 ctr.getCounterId(), ctr.eventId);
594
595 auto sourceEvent = eventMap.find(ctr.eventId);
596 if (sourceEvent == eventMap.end()) {
597 warn("Can't enable PMU counter of type '0x%x': "
598 "No such event type.\n", ctr.eventId);
599 } else {
600 ctr.attach(sourceEvent->second);
601 }
602 }
603}
604
605
606void
608{
609 for (CounterState &ctr : counters)
610 ctr.setValue(0);
611}
612
613void
614PMU::setCounterValue(CounterId id, uint64_t val)
615{
616 if (!isValidCounter(id)) {
617 warn_once("Can't change counter value: Counter %i does not exist.\n",
618 id);
619 return;
620 }
621
622 CounterState &ctr(getCounter(id));
623 ctr.setValue(val);
624}
625
626PMU::PMEVTYPER_t
628{
629 if (!isValidCounter(id))
630 return 0;
631
632 const CounterState &cs(getCounter(id));
633 PMEVTYPER_t type(cs.filter);
634
635 type.evtCount = cs.eventId;
636
637 return type;
638}
639
640void
641PMU::setCounterTypeRegister(CounterId id, PMEVTYPER_t val)
642{
643 DPRINTF(PMUVerbose, "Set Event [%d] = 0x%08x\n", id, val);
644 if (!isValidCounter(id)) {
645 warn_once("Can't change counter type: Counter %i does not exist.\n",
646 id);
647 return;
648 }
649
650 CounterState &ctr(getCounter(id));
651 const EventTypeId old_event_id(ctr.eventId);
652
653 ctr.filter = val;
654
655 // If PMCCNTR Register, do not change event type. PMCCNTR can
656 // count processor cycles only. If we change the event type, we
657 // need to update the probes the counter is using.
658 if (id != PMCCNTR && old_event_id != val.evtCount) {
659 ctr.eventId = val.evtCount;
660 updateCounter(ctr);
661 }
662}
663
664void
666{
667 const bool int_old = reg_pmovsr != 0;
668 const bool int_new = new_val != 0;
669
670 reg_pmovsr = new_val;
671 if (int_old && !int_new) {
673 } else if (!int_old && int_new && (reg_pminten & reg_pmovsr)) {
675 }
676}
677
678void
680{
681 if (exitOnPMUInterrupt) {
682 inform("Exiting simulation: PMU interrupt detected");
683 exitSimLoop("performance counter interrupt", 0);
684 }
685 if (interrupt) {
686 DPRINTF(PMUVerbose, "Delivering PMU interrupt.\n");
687 interrupt->raise();
688 } else {
689 warn_once("Dropping PMU interrupt as no interrupt has "
690 "been specified\n");
691 }
692}
693
694void
696{
697 if (interrupt) {
698 DPRINTF(PMUVerbose, "Clearing PMU interrupt.\n");
699 interrupt->clear();
700 } else {
701 warn_once("Dropping PMU interrupt as no interrupt has "
702 "been specified\n");
703 }
704}
705
706void
708{
709 DPRINTF(Checkpoint, "Serializing Arm PMU\n");
710
720
721 for (size_t i = 0; i < counters.size(); ++i)
722 counters[i].serializeSection(cp, csprintf("counters.%i", i));
723
724 cycleCounter.serializeSection(cp, "cycleCounter");
725}
726
727void
729{
730 DPRINTF(Checkpoint, "Unserializing Arm PMU\n");
731
738
739 // Old checkpoints used to store the entire PMCEID value in a
740 // single 64-bit entry (reg_pmceid). The register was extended in
741 // ARMv8.1, so we now need to store it as two 64-bit registers.
743 paramIn(cp, "reg_pmceid", reg_pmceid0);
744
746 reg_pmceid1 = 0;
747
749
750 for (size_t i = 0; i < counters.size(); ++i)
751 counters[i].unserializeSection(cp, csprintf("counters.%i", i));
752
753 cycleCounter.unserializeSection(cp, "cycleCounter");
754}
755
756std::shared_ptr<PMU::PMUEvent>
757PMU::getEvent(uint64_t eventId)
758{
759 auto entry = eventMap.find(eventId);
760
761 if (entry == eventMap.end()) {
762 warn("event %d does not exist\n", eventId);
763 return nullptr;
764 } else {
765 return entry->second;
766 }
767}
768
769void
771{
772 SERIALIZE_SCALAR(eventId);
773 SERIALIZE_SCALAR(value);
774 SERIALIZE_SCALAR(overflow64);
775}
776
777void
784
785uint64_t
787{
788 uint64_t value_until_overflow;
789 if (overflow64) {
790 value_until_overflow = UINT64_MAX - value;
791 } else {
792 value_until_overflow = UINT32_MAX - (uint32_t)value;
793 }
794
795 if (isFiltered())
796 return value_until_overflow;
797
798 if (resetValue) {
799 delta = 0;
800 resetValue = false;
801 } else {
802 value += delta;
803 }
804
805 if (delta > value_until_overflow) {
806
807 // overflow situation detected
808 // flag the overflow occurence
809 pmu.reg_pmovsr |= (1 << counterId);
810
811 // Deliver a PMU interrupt if interrupt delivery is enabled
812 // for this counter.
813 if (pmu.reg_pminten & (1 << counterId)) {
814 pmu.raiseInterrupt();
815 }
816 return overflow64 ? UINT64_MAX : UINT32_MAX;
817 }
818 return value_until_overflow - delta + 1;
819}
820
821void
823{
824 for (auto& counter: userCounters) {
825 if (val & (0x1 << counter->getCounterId())) {
826 counter->add(1);
827 }
828 }
829}
830
831} // namespace ArmISA
832} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:210
Base class for ARM GIC implementations.
Base class for devices that use the MiscReg interfaces.
Definition isa_device.hh:62
void write(uint64_t val)
write on the sw increment register inducing an increment of the counters with this event selected acc...
Definition pmu.cc:822
void regProbeListeners() override
Register probe listeners for this object.
Definition pmu.cc:176
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition pmu.cc:728
void setControlReg(PMCR_t val)
PMCR write handling.
Definition pmu.cc:400
void raiseInterrupt()
Deliver a PMU interrupt to the GIC.
Definition pmu.cc:679
PMCR_t reg_pmcr_conf
Constant (configuration-dependent) part of the PMCR.
Definition pmu.hh:623
RegVal readMiscReg(int misc_reg) override
Read a register within the PMU.
Definition pmu.cc:301
RegVal reg_pmcnten
Performance Monitor Count Enable Register.
Definition pmu.hh:580
std::shared_ptr< PMUEvent > getEvent(uint64_t eventId)
Obtain the event of a given id.
Definition pmu.cc:757
void clearInterrupt()
Clear a PMU interrupt.
Definition pmu.cc:695
const uint64_t cycleCounterEventId
The id of the counter hardwired to the cpu cycle counter.
Definition pmu.hh:616
uint64_t maximumCounterCount
The number of regular event counters.
Definition pmu.hh:607
static const RegVal reg_pmcr_wr_mask
PMCR write mask when accessed from the guest.
Definition pmu.hh:626
bool isFiltered(const CounterState &ctr) const
Check if a counter's settings allow it to be counted.
PMEVTYPER_t getCounterTypeRegister(CounterId id) const
Get the type and filter settings of a counter (PMEVTYPER)
Definition pmu.cc:627
unsigned clock_remainder
Remainder part when the clock counter is divided by 64.
Definition pmu.hh:604
uint64_t reg_pmceid1
Definition pmu.hh:601
void updateAllCounters()
Call updateCounter() for each counter in the PMU if the counter's state has changed.
Definition pmu.cc:438
void resetEventCounts()
Reset all event counters excluding the cycle counter to zero.
Definition pmu.cc:607
void registerEvent(uint32_t id)
Definition pmu.cc:153
void setOverflowStatus(RegVal new_val)
Used for writing the Overflow Flag Status Register (SET/CLR)
Definition pmu.cc:665
PMSELR_t reg_pmselr
Performance Monitor Selection Register.
Definition pmu.hh:586
std::map< EventTypeId, std::shared_ptr< PMUEvent > > eventMap
List of event types supported by this PMU.
Definition pmu.hh:634
static const CounterId PMCCNTR
Cycle Count Register Number.
Definition pmu.hh:189
void setThreadContext(ThreadContext *tc) override
Definition pmu.cc:99
std::vector< CounterState > counters
State of all general-purpose counters supported by PMU.
Definition pmu.hh:610
void setCounterTypeRegister(CounterId id, PMEVTYPER_t type)
Set the type and filter settings of a performance counter (PMEVTYPER)
Definition pmu.cc:641
void drainResume() override
Resume execution after a successful drain.
Definition pmu.cc:169
PMU(const ArmPMUParams &p)
Definition pmu.cc:58
RegVal readMiscRegInt(int misc_reg)
Definition pmu.cc:310
void setMiscReg(int misc_reg, RegVal val) override
Set a register within the PMU.
Definition pmu.cc:192
CounterState cycleCounter
State of the cycle counter.
Definition pmu.hh:613
uint64_t reg_pmceid0
Performance counter ID register.
Definition pmu.hh:600
bool isValidCounter(CounterId id) const
Is this a valid counter ID?
Definition pmu.hh:518
PMCR_t reg_pmcr
Performance Monitor Control Register.
Definition pmu.hh:583
Bitfield< 1 > p
Definition pmu.hh:138
RegVal reg_pmovsr
Performance Monitor Overflow Status Register.
Definition pmu.hh:592
ArmInterruptPin * interrupt
Performance monitor interrupt number.
Definition pmu.hh:629
void addSoftwareIncrementEvent(unsigned int id)
Definition pmu.cc:109
CounterState & getCounter(CounterId id)
Return the state of a counter.
Definition pmu.hh:529
bool use64bitCounters
Determine whether to use 64-bit or 32-bit counters.
Definition pmu.hh:577
std::shared_ptr< SWIncrementEvent > swIncrementEvent
The event that implements the software increment.
Definition pmu.hh:619
uint64_t getCounterValue(CounterId id) const
Get the value of a performance counter.
Definition pmu.hh:236
bool exitOnPMUInterrupt
Exit simloop on PMU interrupt.
Definition pmu.hh:644
unsigned int EventTypeId
Event type ID.
Definition pmu.hh:196
void setCounterValue(CounterId id, uint64_t val)
Set the value of a performance counter.
Definition pmu.cc:614
RegVal reg_pminten
Performance Monitor Interrupt Enable Register.
Definition pmu.hh:589
void updateCounter(CounterState &ctr)
Depending on counter configuration, add or remove the probes driving the counter.
Definition pmu.cc:584
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition pmu.cc:707
const bool exitOnPMUControl
Exit simloop on PMU reset or disable.
Definition pmu.hh:639
void addEventProbe(unsigned int id, SimObject *obj, const char *name)
Definition pmu.cc:131
virtual void clear()=0
Clear a signalled interrupt.
virtual void raise()=0
Signal an interrupt.
virtual std::string name() const
Definition named.hh:47
Abstract superclass for simulation objects.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual ContextID contextId() const =0
This module implements the global system counter and the local per-CPU architected timers as specifie...
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition logging.hh:236
#define fatal(...)
This implements a cprintf based fatal() function.
Definition logging.hh:200
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition logging.hh:214
#define UNSERIALIZE_OPT_SCALAR(scalar)
Definition serialize.hh:582
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
Definition serialize.cc:74
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
Definition serialize.cc:81
const Params & params() const
#define warn(...)
Definition logging.hh:256
#define warn_once(...)
Definition logging.hh:260
#define warn_if(cond,...)
Conditional warning macro that checks the supplied condition and only prints a warning if the conditi...
Definition logging.hh:283
#define inform(...)
Definition logging.hh:257
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 33 > id
@ MISCREG_PMXEVTYPER_EL0
Definition misc.hh:781
@ MISCREG_PMUSERENR
Definition misc.hh:369
@ MISCREG_PMSELR_EL0
Definition misc.hh:777
@ MISCREG_PMOVSSET
Definition misc.hh:372
@ MISCREG_PMXEVCNTR_EL0
Definition misc.hh:783
@ MISCREG_PMCCNTR_EL0
Definition misc.hh:780
@ MISCREG_PMINTENSET
Definition misc.hh:370
@ MISCREG_PMXEVTYPER
Definition misc.hh:366
@ MISCREG_PMEVTYPER0_EL0
Definition misc.hh:856
@ MISCREG_PMUSERENR_EL0
Definition misc.hh:784
@ MISCREG_PMCR
Definition misc.hh:357
@ MISCREG_PMEVCNTR0_EL0
Definition misc.hh:850
@ MISCREG_PMOVSR
Definition misc.hh:360
@ MISCREG_PMCNTENCLR
Definition misc.hh:359
@ MISCREG_PMCCFILTR_EL0
Definition misc.hh:782
@ MISCREG_PMSWINC_EL0
Definition misc.hh:776
@ MISCREG_PMINTENSET_EL1
Definition misc.hh:770
@ MISCREG_PMINTENCLR_EL1
Definition misc.hh:771
@ MISCREG_PMCCFILTR
Definition misc.hh:367
@ MISCREG_PMCEID1
Definition misc.hh:364
@ MISCREG_PMCNTENSET
Definition misc.hh:358
@ MISCREG_PMCEID0_EL0
Definition misc.hh:778
@ MISCREG_PMSELR
Definition misc.hh:362
@ MISCREG_PMXEVCNTR
Definition misc.hh:368
@ MISCREG_PMCEID0
Definition misc.hh:363
@ MISCREG_PMINTENCLR
Definition misc.hh:371
@ MISCREG_PMCNTENCLR_EL0
Definition misc.hh:774
@ MISCREG_PMSWINC
Definition misc.hh:361
@ MISCREG_PMCNTENSET_EL0
Definition misc.hh:773
@ MISCREG_PMOVSCLR_EL0
Definition misc.hh:775
@ MISCREG_PMCCNTR
Definition misc.hh:365
@ MISCREG_PMCR_EL0
Definition misc.hh:772
@ MISCREG_PMCEID1_EL0
Definition misc.hh:779
@ MISCREG_PMXEVTYPER_PMCCFILTR
Definition misc.hh:96
@ MISCREG_PMOVSSET_EL0
Definition misc.hh:785
Bitfield< 3, 2 > el
Definition misc_types.hh:73
int unflattenMiscReg(int reg)
Definition misc.cc:724
const char *const miscRegName[]
Definition misc.hh:1815
Bitfield< 10, 5 > event
Bitfield< 30, 0 > index
Bitfield< 0 > p
Bitfield< 11 > enable
Definition misc.hh:1086
Bitfield< 63 > val
Definition misc.hh:804
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t RegVal
Definition types.hh:173
std::ostream CheckpointOut
Definition serialize.hh:66
void paramIn(CheckpointIn &cp, const std::string &name, ExtMachInst &machInst)
Definition types.cc:72
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
Schedule an event to exit the simulation loop (returning to Python) at the end of the current cycle (...
Definition sim_events.cc:88
std::string csprintf(const char *format, const Args &...args)
Definition cprintf.hh:161
#define UNSERIALIZE_SCALAR(scalar)
Definition serialize.hh:575
#define SERIALIZE_SCALAR(scalar)
Definition serialize.hh:568
State of a counter within the PMU.
Definition pmu.hh:415
void attach(const std::shared_ptr< PMUEvent > &event)
Attach this counter to an event.
Definition pmu.cc:547
PMEVTYPER_t filter
Filtering settings (evtCount is unused)
Definition pmu.hh:476
void detach()
Detach the counter from its event.
Definition pmu.cc:535
EventTypeId eventId
Counter event ID.
Definition pmu.hh:473
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition pmu.cc:778
uint64_t getCounterId() const
Obtain the counter id.
Definition pmu.hh:453
uint64_t getValue() const
rReturn the counter value
Definition pmu.cc:558
bool enabled
Is the counter enabled?
Definition pmu.hh:479
uint64_t add(uint64_t delta)
Add an event count to the counter and check for overflow.
Definition pmu.cc:786
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition pmu.cc:770
void setValue(uint64_t val)
overwrite the value of the counter
Definition pmu.cc:570
void attachEvent(PMU::CounterState *user)
attach this event to a given counter
Definition pmu.cc:459
virtual void enable()=0
Enable the current event.
std::set< PMU::CounterState * > userCounters
set of counters using this event
Definition pmu.hh:344
virtual void updateAttachedCounters()
Method called immediately before a counter access in order for the associated event to update its sta...
Definition pmu.hh:339
void detachEvent(PMU::CounterState *user)
detach this event from a given counter
Definition pmu.cc:477
virtual void increment(const uint64_t val)
notify an event increment of val units, all the attached counters' value is incremented by val units.
Definition pmu.cc:469
void notify(const uint64_t &val)
Definition pmu.cc:487
void enable() override
Enable the current event.
Definition pmu.cc:493
void disable() override
Disable the current event.
Definition pmu.cc:502

Generated on Tue Jun 18 2024 16:23:57 for gem5 by doxygen 1.11.0