Skip to content

Timer

include/time/timer.h View source View on GitHub

timer_flags: 32 bit bitflags

┌───────────────────────────────────────────────────────┐
Bits │ 31..28 27..24 23..20 19..16 15..12 11..8 7..4 3..0 │
Use │ %%%% %%%% %%Pd ID## #### #### #### #### │
└───────────────────────────────────────────────────────┘

I - IRQ timer - not executed in DPC D - Deferrable (Only activates when CPU non-idle) d - DPC queued P - Pinned

%%% - Bucket idx (if present, up to 1023) **- CPU target for this timer** A - Unused (available) * - Unused (unavailable)

struct timer (5 fields) source
§ struct hlist_node hlist_node
§ time_us_t expiration_us
§ void (*func)(struct timer *timer)
§ enum timer_flags flags
§ void *data
enum timer_flags (5 variants) source
§ TIMER_FLAG_NONE = 0
§ TIMER_FLAG_DEFERRABLE = 1 << 18
§ TIMER_FLAG_IRQ = 1 << 19
§ TIMER_FLAG_DPC_QUEUED = 1 << 20
§ TIMER_FLAG_PINNED = 1 << 21
void timer_bucket_set(struct timer *timer, uint32_t bucket)
source
uint32_t timer_bucket_get(struct timer *timer)
source
void timer_cpu_set(struct timer *timer, cpu_id_t cpu)
source
cpu_id_t timer_cpu_get(struct timer *timer)
source
void timer_init(
    struct timer *timer,
    void (*func)(struct timer *),
    void *data
)
source
void timer_add(struct timer *timer)
source
void timer_add_on(struct timer *timer, cpu_id_t cpu)
source
void timer_add_local(struct timer *timer)
source

Wrappers around add() with flag setting

void timer_add_global(struct timer *timer)
source
bool timer_modify(struct timer *timer, time_us_t new)
source
bool timer_modify_pending(struct timer *timer, time_us_t new)
source
bool timer_modify_reduce(struct timer *timer, time_us_t new)
source

Only modify if new is nearer than expiration

bool timer_delete(struct timer *timer)
source

_sync() functions wait for the handler to finish, and non-_sync() functions do not

bool timer_delete_sync(struct timer *timer)
source
bool timer_shutdown(struct timer *timer)
source
bool timer_shutdown_sync(struct timer *timer)
source
enum irq_result timer_isr(struct irq_context *ctx, void *c)
source
void timers_init_bsp(void)
source
void timers_init_ap(cpu_id_t cpu)
source
time_us_t timer_delta_us(time_us_t delta_us)
source
#define TIMER_FLAG_CPU_MASK 0x0003FFFF
source
#define TIMER_FLAG_CPU(c)
source
Expansion
#define TIMER_FLAG_CPU(c) ((c) & TIMER_FLAG_CPU_MASK)
#define TIMER_FLAG_BUCKET_MASK 0x3FFu
source
#define TIMER_FLAG_BUCKET_SHIFT 22
source
#define TIMER_FLAG_BUCKET(b)
source
#define TIMER_DEFINE(n, fn, ...)
source
Expansion
#define TIMER_DEFINE(n, fn, ...) \
    struct timer n = (struct timer) { \
        .func = fn \
    }