mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-31 00:24:51 +00:00
hw: add Timer re-init/resume support
Add explicit init() to Timer infrastructure to re-initialize the hardware based on the parameters given during constructing time of the timer object. Issue #4669
This commit is contained in:
parent
1b5bfec8f9
commit
5587476b4e
@ -88,6 +88,9 @@ class Kernel::Cpu : public Genode::Cpu, private Irq::Pool, private Timeout
|
|||||||
Ipi(Cpu & cpu);
|
Ipi(Cpu & cpu);
|
||||||
|
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
** Irq interface **
|
** Irq interface **
|
||||||
*********************/
|
*********************/
|
||||||
|
@ -52,5 +52,12 @@ Cpu::Ipi::Ipi(Cpu & cpu)
|
|||||||
:
|
:
|
||||||
Irq(Board::Pic::IPI, cpu, cpu.pic()), cpu(cpu)
|
Irq(Board::Pic::IPI, cpu, cpu.pic()), cpu(cpu)
|
||||||
{
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Cpu::Ipi::init()
|
||||||
|
{
|
||||||
|
pending = false;
|
||||||
cpu.pic().unmask(Board::Pic::IPI, cpu.id());
|
cpu.pic().unmask(Board::Pic::IPI, cpu.id());
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,9 @@ class Kernel::Timer
|
|||||||
unsigned interrupt_id() const;
|
unsigned interrupt_id() const;
|
||||||
|
|
||||||
time_t time() const { return _time + _duration(); }
|
time_t time() const { return _time + _duration(); }
|
||||||
|
|
||||||
|
void init() { _device.init(); }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _CORE__KERNEL__TIMER_H_ */
|
#endif /* _CORE__KERNEL__TIMER_H_ */
|
||||||
|
@ -61,6 +61,8 @@ struct Board::Timer : Genode::Mmio
|
|||||||
Kernel::time_t current_ticks() const;
|
Kernel::time_t current_ticks() const;
|
||||||
|
|
||||||
Timer(unsigned);
|
Timer(unsigned);
|
||||||
|
|
||||||
|
void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _SRC__CORE__SPEC__ARM__CORTEX_A9_GLOBAL_TIMER_H_ */
|
#endif /* _SRC__CORE__SPEC__ARM__CORTEX_A9_GLOBAL_TIMER_H_ */
|
||||||
|
@ -25,6 +25,12 @@ unsigned long Board::Timer::_freq() { return Genode::Cpu::Cntfrq::read(); }
|
|||||||
|
|
||||||
|
|
||||||
Board::Timer::Timer(unsigned) : ticks_per_ms((unsigned)(_freq() / 1000))
|
Board::Timer::Timer(unsigned) : ticks_per_ms((unsigned)(_freq() / 1000))
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Board::Timer::init()
|
||||||
{
|
{
|
||||||
Cpu::Cntp_ctl::access_t ctl = 0;
|
Cpu::Cntp_ctl::access_t ctl = 0;
|
||||||
Cpu::Cntp_ctl::Enable::set(ctl, 1);
|
Cpu::Cntp_ctl::Enable::set(ctl, 1);
|
||||||
|
@ -27,6 +27,8 @@ struct Board::Timer
|
|||||||
unsigned const ticks_per_ms;
|
unsigned const ticks_per_ms;
|
||||||
|
|
||||||
Timer(unsigned);
|
Timer(unsigned);
|
||||||
|
|
||||||
|
void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _SRC__CORE__SPEC__ARM__GENERIC_TIMER_H_ */
|
#endif /* _SRC__CORE__SPEC__ARM__GENERIC_TIMER_H_ */
|
||||||
|
@ -29,6 +29,12 @@ unsigned Timer::interrupt_id() const { return Board::EPIT_1_IRQ; }
|
|||||||
Board::Timer::Timer(unsigned)
|
Board::Timer::Timer(unsigned)
|
||||||
:
|
:
|
||||||
Mmio(Platform::mmio_to_virt(Board::EPIT_1_MMIO_BASE))
|
Mmio(Platform::mmio_to_virt(Board::EPIT_1_MMIO_BASE))
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Board::Timer::init()
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
|
@ -88,6 +88,8 @@ struct Board::Timer : Genode::Mmio
|
|||||||
}
|
}
|
||||||
|
|
||||||
Timer(unsigned);
|
Timer(unsigned);
|
||||||
|
|
||||||
|
void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _SRC__CORE__SPEC__ARM__IMX_EPIT_H_ */
|
#endif /* _SRC__CORE__SPEC__ARM__IMX_EPIT_H_ */
|
||||||
|
@ -21,6 +21,12 @@ using namespace Kernel;
|
|||||||
|
|
||||||
|
|
||||||
Board::Timer::Timer(unsigned)
|
Board::Timer::Timer(unsigned)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Board::Timer::init()
|
||||||
{
|
{
|
||||||
/* enable timer interrupt */
|
/* enable timer interrupt */
|
||||||
enum { STIE = 0x20 };
|
enum { STIE = 0x20 };
|
||||||
|
@ -34,6 +34,8 @@ struct Board::Timer
|
|||||||
Kernel::time_t stime() const;
|
Kernel::time_t stime() const;
|
||||||
|
|
||||||
Timer(unsigned);
|
Timer(unsigned);
|
||||||
|
|
||||||
|
void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _SRC__CORE__SPEC__RISCV__TIMER_H_ */
|
#endif /* _SRC__CORE__SPEC__RISCV__TIMER_H_ */
|
||||||
|
@ -56,6 +56,12 @@ uint32_t Board::Timer::pit_calc_timer_freq(void)
|
|||||||
Board::Timer::Timer(unsigned)
|
Board::Timer::Timer(unsigned)
|
||||||
:
|
:
|
||||||
Mmio(Platform::mmio_to_virt(Hw::Cpu_memory_map::lapic_phys_base()))
|
Mmio(Platform::mmio_to_virt(Hw::Cpu_memory_map::lapic_phys_base()))
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Board::Timer::init()
|
||||||
{
|
{
|
||||||
/* enable LAPIC timer in one-shot mode */
|
/* enable LAPIC timer in one-shot mode */
|
||||||
write<Tmr_lvt::Vector>(Board::TIMER_VECTOR_KERNEL);
|
write<Tmr_lvt::Vector>(Board::TIMER_VECTOR_KERNEL);
|
||||||
|
@ -72,6 +72,8 @@ struct Board::Timer: Genode::Mmio
|
|||||||
Genode::uint32_t pit_calc_timer_freq(void);
|
Genode::uint32_t pit_calc_timer_freq(void);
|
||||||
|
|
||||||
Timer(unsigned);
|
Timer(unsigned);
|
||||||
|
|
||||||
|
void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _SRC__CORE__SPEC__ARM__PIT_H_ */
|
#endif /* _SRC__CORE__SPEC__ARM__PIT_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user