timer.h 1002 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include <common/glib.h>
  3. #include "HPET/HPET.h"
  4. #include "rtc/rtc.h"
  5. uint64_t volatile timer_jiffies = 0; // 系统时钟计数
  6. void timer_init();
  7. void do_timer_softirq(void* data);
  8. /**
  9. * @brief 定时功能队列
  10. *
  11. */
  12. struct timer_func_list_t
  13. {
  14. struct List list;
  15. uint64_t expire_jiffies;
  16. void (*func)(void* data);
  17. void* data;
  18. }timer_func_head;
  19. /**
  20. * @brief 初始化定时功能
  21. *
  22. * @param timer_func 队列结构体
  23. * @param func 定时功能处理函数
  24. * @param data 传输的数据
  25. * @param expire_jiffies 定时时长
  26. */
  27. void timer_func_init(struct timer_func_list_t * timer_func, void (*func)(void*data), void*data,uint64_t expire_jiffies);
  28. /**
  29. * @brief 将定时功能添加到列表中
  30. *
  31. * @param timer_func 待添加的定时功能
  32. */
  33. void timer_func_add(struct timer_func_list_t* timer_func);
  34. /**
  35. * @brief 将定时功能从列表中删除
  36. *
  37. * @param timer_func
  38. */
  39. void timer_func_del(struct timer_func_list_t* timer_func);