timers: use DPCs to handle callbacks

This commit is contained in:
Matheus
2023-06-26 19:46:30 -03:00
parent 99a7eccbe4
commit e3bc7e8b8b
3 changed files with 16 additions and 10 deletions
+6 -3
View File
@@ -5,13 +5,15 @@
#include <arch/context.h>
#include <spinlock.h>
#include <stdbool.h>
#include <kernel/dpc.h>
typedef struct timerentry_t {
struct timerentry_t *next;
time_t absolutetick;
time_t repeatus;
void *private;
void (*func)(void *private, context_t* context);
dpcfn_t fn;
dpcarg_t arg;
dpc_t dpc;
} timerentry_t;
typedef struct {
@@ -23,10 +25,11 @@ typedef struct {
time_t (*stop)();
timerentry_t *queue;
} timer_t;
void timer_resume(timer_t *timer);
void timer_stop(timer_t *timer);
void timer_isr(timer_t *timer, context_t *context);
void timer_insert(timer_t *timer, timerentry_t *entry, time_t us);
void timer_insert(timer_t *timer, timerentry_t *entry, dpcfn_t fn, dpcarg_t arg, time_t us, bool repeating);
timer_t *timer_new(time_t ticksperus, void (*arm)(time_t), time_t (*stop)());
#endif