DragonOS/kernel/driver/timers/timer.h

52 lines
1.2 KiB
C
Raw Normal View History

2022-04-08 12:04:12 +00:00
#pragma once
#include <common/glib.h>
#include "HPET/HPET.h"
#include "rtc/rtc.h"
uint64_t volatile timer_jiffies = 0; // 系统时钟计数
// 计算接下来n毫秒对应的系统时间片
#define cal_next_n_ms_jiffies(expire_ms) (timer_jiffies + expire_ms / 5 + (expire_ms % HPET0_INTERVAL ? 1 : 0))
2022-04-08 12:04:12 +00:00
void timer_init();
void do_timer_softirq(void *data);
2022-04-08 13:26:42 +00:00
/**
* @brief
*
2022-04-08 13:26:42 +00:00
*/
struct timer_func_list_t
{
struct List list;
uint64_t expire_jiffies;
void (*func)(void *data);
void *data;
};
2022-04-08 13:26:42 +00:00
extern struct timer_func_list_t timer_func_head;
2022-04-08 13:26:42 +00:00
/**
* @brief
*
2022-04-08 13:26:42 +00:00
* @param timer_func
* @param func
* @param data
2022-05-20 11:37:26 +00:00
* @param expire_ms (ms)
2022-04-08 13:26:42 +00:00
*/
void timer_func_init(struct timer_func_list_t *timer_func, void (*func)(void *data), void *data, uint64_t expire_ms);
2022-04-08 13:26:42 +00:00
/**
* @brief
*
2022-04-08 13:26:42 +00:00
* @param timer_func
*/
void timer_func_add(struct timer_func_list_t *timer_func);
2022-04-08 13:26:42 +00:00
/**
* @brief
*
* @param timer_func
2022-04-08 13:26:42 +00:00
*/
void timer_func_del(struct timer_func_list_t *timer_func);