diff options
Diffstat (limited to 'src/dev/arm/timer_cpulocal.cc')
-rw-r--r-- | src/dev/arm/timer_cpulocal.cc | 63 |
1 files changed, 37 insertions, 26 deletions
diff --git a/src/dev/arm/timer_cpulocal.cc b/src/dev/arm/timer_cpulocal.cc index 033031547..9e9946b1f 100644 --- a/src/dev/arm/timer_cpulocal.cc +++ b/src/dev/arm/timer_cpulocal.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 ARM Limited + * Copyright (c) 2010-2013,2018 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -40,6 +40,7 @@ #include "dev/arm/timer_cpulocal.hh" +#include "arch/arm/system.hh" #include "base/intmath.hh" #include "base/trace.hh" #include "debug/Checkpoint.hh" @@ -49,23 +50,38 @@ #include "mem/packet_access.hh" CpuLocalTimer::CpuLocalTimer(Params *p) - : BasicPioDevice(p, 0x38), gic(p->gic) + : BasicPioDevice(p, 0x38) { +} + +void +CpuLocalTimer::init() +{ + auto p = params(); // Initialize the timer registers for each per cpu timer - for (int i = 0; i < CPU_MAX; i++) { + for (int i = 0; i < sys->numContexts(); i++) { + ThreadContext* tc = sys->getThreadContext(i); std::stringstream oss; oss << name() << ".timer" << i; - localTimer[i]._name = oss.str(); - localTimer[i].parent = this; - localTimer[i].intNumTimer = p->int_num_timer; - localTimer[i].intNumWatchdog = p->int_num_watchdog; - localTimer[i].cpuNum = i; + + localTimer.emplace_back( + new Timer(oss.str(), this, + p->int_timer->get(tc), + p->int_watchdog->get(tc))); } + + BasicPioDevice::init(); } -CpuLocalTimer::Timer::Timer() - : timerControl(0x0), watchdogControl(0x0), rawIntTimer(false), rawIntWatchdog(false), - rawResetWatchdog(false), watchdogDisableReg(0x0), pendingIntTimer(false), pendingIntWatchdog(false), +CpuLocalTimer::Timer::Timer(const std::string &timer_name, + CpuLocalTimer* _parent, + ArmInterruptPin* int_timer, + ArmInterruptPin* int_watchdog) + : _name(timer_name), parent(_parent), intTimer(int_timer), + intWatchdog(int_watchdog), timerControl(0x0), watchdogControl(0x0), + rawIntTimer(false), rawIntWatchdog(false), + rawResetWatchdog(false), watchdogDisableReg(0x0), + pendingIntTimer(false), pendingIntWatchdog(false), timerLoadValue(0x0), watchdogLoadValue(0x0), timerZeroEvent([this]{ timerAtZero(); }, name()), watchdogZeroEvent([this]{ watchdogAtZero(); }, name()) @@ -81,10 +97,10 @@ CpuLocalTimer::read(PacketPtr pkt) ContextID cpu_id = pkt->req->contextId(); DPRINTF(Timer, "Reading from CpuLocalTimer at offset: %#x\n", daddr); assert(cpu_id >= 0); - assert(cpu_id < CPU_MAX); + assert(cpu_id < localTimer.size()); if (daddr < Timer::Size) - localTimer[cpu_id].read(pkt, daddr); + localTimer[cpu_id]->read(pkt, daddr); else panic("Tried to read CpuLocalTimer at offset %#x that doesn't exist\n", daddr); pkt->makeAtomicResponse(); @@ -159,10 +175,10 @@ CpuLocalTimer::write(PacketPtr pkt) ContextID cpu_id = pkt->req->contextId(); DPRINTF(Timer, "Writing to CpuLocalTimer at offset: %#x\n", daddr); assert(cpu_id >= 0); - assert(cpu_id < CPU_MAX); + assert(cpu_id < localTimer.size()); if (daddr < Timer::Size) - localTimer[cpu_id].write(pkt, daddr); + localTimer[cpu_id]->write(pkt, daddr); else panic("Tried to write CpuLocalTimer at offset %#x that doesn't exist\n", daddr); pkt->makeAtomicResponse(); @@ -297,7 +313,7 @@ CpuLocalTimer::Timer::timerAtZero() pendingIntTimer = true; if (pendingIntTimer && !old_pending) { DPRINTF(Timer, "-- Causing interrupt\n"); - parent->gic->sendPPInt(intNumTimer, cpuNum); + intTimer->raise(); } if (!timerControl.autoReload) @@ -328,7 +344,7 @@ CpuLocalTimer::Timer::watchdogAtZero() if (pendingIntWatchdog && !old_pending) { DPRINTF(Timer, "-- Causing interrupt\n"); - parent->gic->sendPPInt(intNumWatchdog, cpuNum); + intWatchdog->raise(); } if (watchdogControl.watchdogMode) @@ -341,8 +357,6 @@ void CpuLocalTimer::Timer::serialize(CheckpointOut &cp) const { DPRINTF(Checkpoint, "Serializing Arm CpuLocalTimer\n"); - SERIALIZE_SCALAR(intNumTimer); - SERIALIZE_SCALAR(intNumWatchdog); uint32_t timer_control_serial = timerControl; uint32_t watchdog_control_serial = watchdogControl; @@ -380,9 +394,6 @@ CpuLocalTimer::Timer::unserialize(CheckpointIn &cp) { DPRINTF(Checkpoint, "Unserializing Arm CpuLocalTimer\n"); - UNSERIALIZE_SCALAR(intNumTimer); - UNSERIALIZE_SCALAR(intNumWatchdog); - uint32_t timer_control_serial; UNSERIALIZE_SCALAR(timer_control_serial); timerControl = timer_control_serial; @@ -421,15 +432,15 @@ CpuLocalTimer::Timer::unserialize(CheckpointIn &cp) void CpuLocalTimer::serialize(CheckpointOut &cp) const { - for (int i = 0; i < CPU_MAX; i++) - localTimer[i].serializeSection(cp, csprintf("timer%d", i)); + for (int i = 0; i < sys->numContexts(); i++) + localTimer[i]->serializeSection(cp, csprintf("timer%d", i)); } void CpuLocalTimer::unserialize(CheckpointIn &cp) { - for (int i = 0; i < CPU_MAX; i++) - localTimer[i].unserializeSection(cp, csprintf("timer%d", i)); + for (int i = 0; i < sys->numContexts(); i++) + localTimer[i]->unserializeSection(cp, csprintf("timer%d", i)); } CpuLocalTimer * |