#include <hal/apic.h>
#include <hal/rtc.h>
-#include <lunaix/mm/kalloc.h>
+#include <lunaix/mm/cake.h>
+#include <lunaix/mm/valloc.h>
#include <lunaix/sched.h>
#include <lunaix/spike.h>
#include <lunaix/syslog.h>
static volatile uint32_t sched_ticks = 0;
static volatile uint32_t sched_ticks_counter = 0;
+static struct cake_pile* timer_pile;
+
#define APIC_CALIBRATION_CONST 0x100000
void
timer_init_context()
{
+ timer_pile = cake_new_pile("timer", sizeof(struct lx_timer), 1, 0);
timer_ctx =
- (struct lx_timer_context*)lxmalloc(sizeof(struct lx_timer_context));
+ (struct lx_timer_context*)valloc(sizeof(struct lx_timer_context));
assert_msg(timer_ctx, "Fail to initialize timer contex");
- timer_ctx->active_timers =
- (struct lx_timer*)lxmalloc(sizeof(struct lx_timer));
+ timer_ctx->active_timers = (struct lx_timer*)cake_grab(timer_pile);
llist_init_head(timer_ctx->active_timers);
}
struct lx_timer*
timer_run(ticks_t ticks, void (*callback)(void*), void* payload, uint8_t flags)
{
- struct lx_timer* timer =
- (struct lx_timer*)lxmalloc(sizeof(struct lx_timer));
+ struct lx_timer* timer = (struct lx_timer*)cake_grab(timer_pile);
if (!timer)
return NULL;
pos->counter = pos->deadline;
} else {
llist_delete(&pos->link);
- lxfree(pos);
+ cake_release(timer_pile, pos);
}
}