timer.c 409 B

12345678910111213141516171819202122232425
  1. #include <asm/port_io.h>
  2. #include <kernel/hw/timer.h>
  3. static time_t _current_ticks = 0;
  4. void init_pit(void)
  5. {
  6. // set interval
  7. asm_outb(PORT_PIT_CONTROL, 0x34);
  8. // send interval number
  9. // 0x2e9c = 11932 = 100Hz
  10. asm_outb(PORT_PIT_COUNT, 0x9c);
  11. asm_outb(PORT_PIT_COUNT, 0x2e);
  12. }
  13. void inc_tick(void)
  14. {
  15. ++_current_ticks;
  16. }
  17. time_t current_ticks(void)
  18. {
  19. return _current_ticks;
  20. }