dev, arm: Make GenericTimer param handling more robust

The generic timer needs a pointer to an ArmSystem to wire itself to the
system register handler. This was previously specified as an instance
of System that was later cast to ArmSystem. Make this more robust by
specifying it as an ArmSystem in the Python interface and add a check
to make sure that it is non-NULL.

Change-Id: I989455e666f4ea324df28124edbbadfd094b0d02
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
This commit is contained in:
Andreas Sandberg 2016-10-07 14:14:44 +01:00
parent 22e6f65d72
commit 8c5df4be2e
2 changed files with 3 additions and 2 deletions

View file

@ -231,7 +231,7 @@ class CpuLocalTimer(BasicPioDevice):
class GenericTimer(SimObject): class GenericTimer(SimObject):
type = 'GenericTimer' type = 'GenericTimer'
cxx_header = "dev/arm/generic_timer.hh" cxx_header = "dev/arm/generic_timer.hh"
system = Param.System(Parent.any, "system") system = Param.ArmSystem(Parent.any, "system")
gic = Param.BaseGic(Parent.any, "GIC to use for interrupting") gic = Param.BaseGic(Parent.any, "GIC to use for interrupting")
# @todo: for now only two timers per CPU is supported, which is the # @todo: for now only two timers per CPU is supported, which is the
# normal behaviour when security extensions are disabled. # normal behaviour when security extensions are disabled.

View file

@ -234,7 +234,8 @@ GenericTimer::GenericTimer(GenericTimerParams *p)
irqPhys(p->int_phys), irqPhys(p->int_phys),
irqVirt(p->int_virt) irqVirt(p->int_virt)
{ {
dynamic_cast<ArmSystem &>(*p->system).setGenericTimer(this); fatal_if(!p->system, "No system specified, can't instantiate timer.\n");
p->system->setGenericTimer(this);
} }
void void