mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
x86/timer: add timer_is_running()
This commit is contained in:
parent
a1f55c3793
commit
a285a78b1b
3 changed files with 13 additions and 1 deletions
|
@ -204,6 +204,7 @@ int apic_is_enabled(void);
|
|||
int apic_enable_timer(void);
|
||||
int apic_disable_timer(void);
|
||||
int apic_timer_deadline(uint32_t);
|
||||
int apic_timer_is_running(void);
|
||||
int apic_send_ipi(uint64_t dest, uint8_t irq);
|
||||
int ioapic_inton(uint8_t irq, uint8_t apicid);
|
||||
int ioapic_intoff(uint8_t irq, uint8_t apicid);
|
||||
|
|
|
@ -303,6 +303,15 @@ static inline void set_ipi_dest(uint32_t cpu_id) {
|
|||
lapic_write(APIC_ICR2, tmp);
|
||||
}
|
||||
|
||||
int apic_timer_is_running(void)
|
||||
{
|
||||
if (BUILTIN_EXPECT(apic_is_enabled(), 1)) {
|
||||
return lapic_read(APIC_CCR) != 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int apic_timer_deadline(uint32_t ticks)
|
||||
{
|
||||
if (BUILTIN_EXPECT(apic_is_enabled() && icr, 1)) {
|
||||
|
|
|
@ -83,7 +83,9 @@ static inline void sleep(unsigned int sec) { timer_wait(sec*TIMER_FREQ); }
|
|||
|
||||
static inline int timer_deadline(uint32_t t) { return apic_timer_deadline(t); }
|
||||
|
||||
static inline void timer_disable() { apic_disable_timer(); }
|
||||
static inline void timer_disable(void) { apic_disable_timer(); }
|
||||
|
||||
static inline int timer_is_running(void) { return apic_timer_is_running(); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue