arm64: Disable timer when not in use.
* ARM documentation indicates this may save power. * Notably, the timer keeps ticking even when "disabled", but cannot be read by the core without temporarily "enabling" the timer. Change-Id: Iccff84915c611b43ee7a3c53ed2f8a3e426eda06 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8093 Haiku-Format: Haiku-format Bot <[email protected]> Tested-by: Commit checker robot <[email protected]> Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
653d40cc93
commit
b278b98232
@@ -16,8 +16,11 @@ static uint64 sTimerTicksUS;
|
|||||||
static bigtime_t sTimerMaxInterval;
|
static bigtime_t sTimerMaxInterval;
|
||||||
static uint64 sBootTime;
|
static uint64 sBootTime;
|
||||||
|
|
||||||
#define TIMER_ARMED (1)
|
#define TIMER_DISABLED (0)
|
||||||
#define TIMER_MASKED (2 | 1)
|
#define TIMER_ENABLE (1)
|
||||||
|
#define TIMER_IMASK (2)
|
||||||
|
#define TIMER_ISTATUS (4)
|
||||||
|
|
||||||
#define TIMER_IRQ 27
|
#define TIMER_IRQ 27
|
||||||
|
|
||||||
|
|
||||||
@@ -28,21 +31,21 @@ arch_timer_set_hardware_timer(bigtime_t timeout)
|
|||||||
timeout = sTimerMaxInterval;
|
timeout = sTimerMaxInterval;
|
||||||
|
|
||||||
WRITE_SPECIALREG(CNTV_TVAL_EL0, timeout * sTimerTicksUS);
|
WRITE_SPECIALREG(CNTV_TVAL_EL0, timeout * sTimerTicksUS);
|
||||||
WRITE_SPECIALREG(CNTV_CTL_EL0, TIMER_ARMED);
|
WRITE_SPECIALREG(CNTV_CTL_EL0, TIMER_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
arch_timer_clear_hardware_timer()
|
arch_timer_clear_hardware_timer()
|
||||||
{
|
{
|
||||||
WRITE_SPECIALREG(CNTV_CTL_EL0, TIMER_MASKED);
|
WRITE_SPECIALREG(CNTV_CTL_EL0, TIMER_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
arch_timer_interrupt(void *data)
|
arch_timer_interrupt(void *data)
|
||||||
{
|
{
|
||||||
WRITE_SPECIALREG(CNTV_CTL_EL0, TIMER_MASKED);
|
WRITE_SPECIALREG(CNTV_CTL_EL0, TIMER_DISABLED);
|
||||||
return timer_interrupt();
|
return timer_interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +56,7 @@ arch_init_timer(kernel_args *args)
|
|||||||
sTimerTicksUS = READ_SPECIALREG(CNTFRQ_EL0) / 1000000;
|
sTimerTicksUS = READ_SPECIALREG(CNTFRQ_EL0) / 1000000;
|
||||||
sTimerMaxInterval = INT32_MAX / sTimerTicksUS;
|
sTimerMaxInterval = INT32_MAX / sTimerTicksUS;
|
||||||
|
|
||||||
WRITE_SPECIALREG(CNTV_CTL_EL0, TIMER_MASKED);
|
WRITE_SPECIALREG(CNTV_CTL_EL0, TIMER_DISABLED);
|
||||||
install_io_interrupt_handler(TIMER_IRQ, &arch_timer_interrupt, NULL, 0);
|
install_io_interrupt_handler(TIMER_IRQ, &arch_timer_interrupt, NULL, 0);
|
||||||
|
|
||||||
sBootTime = READ_SPECIALREG(CNTPCT_EL0);
|
sBootTime = READ_SPECIALREG(CNTPCT_EL0);
|
||||||
|
|||||||
Reference in New Issue
Block a user