#include #include #include #include extern kernel_ctx_t ctx; void pit_init(void) { outb(PIT_MODE_CMD, PIT_CHAN0 | PIT_LOHIGH | PIT_MODE2); outb(PIT_CHAN0_DATA, (uint8_t)(DIVISOR & 0xff)); outb(PIT_CHAN0_DATA, (uint8_t)((DIVISOR & 0xff00) >> 8)); } extern void task_switch(task_t *task); void pit_handler(void) { ctx.ticks++; if (ctx.current_task->next) { LOG("TASK SWITCH\n"); //task_t *old = ctx.current_task; //task_t *new = (task_t *)ctx.current_task->next; //new->next = (uint32_t *)old; //old->next = (uint32_t *)new; task_switch((task_t *)ctx.current_task->next); } outb(PIT_CHAN0_DATA, (uint8_t)(DIVISOR & 0xff)); outb(PIT_CHAN0_DATA, (uint8_t)((DIVISOR & 0xff00) >> 8)); pic_send_eoi(0); }