clock.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * clock.h
  3. *
  4. * Copyright 2013 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _CLOCK_H_
  20. #define _CLOCK_H_
  21. #include <common.h>
  22. #define CLOCK_IRQ 8
  23. #define CLOCK_PM_BIT (1 << 7)
  24. #define CLOCK_DAYLIGHT_SAVINGS (1 << 0)
  25. #define CLOCK_24HOUR_MODE (1 << 1)
  26. #define CLOCK_BINARY_MODE (1 << 2)
  27. #define CLOCK_SQUARE_WAVE (1 << 3)
  28. #define CLOCK_UPDATE_INT (1 << 4)
  29. #define CLOCK_ALARM_INT (1 << 5)
  30. #define CLOCK_PERIODIC_INT (1 << 6)
  31. #define CLOCK_DISABLE (1 << 7)
  32. #define CMOS_RTC_SECONDS_REG 0x00
  33. #define CMOS_RTC_MINUTES_REG 0x02
  34. #define CMOS_RTC_HOURS_REG 0x04
  35. #define CMOS_RTC_DAY_REG 0x07
  36. #define CMOS_RTC_MONTH_REG 0x08
  37. #define CMOS_RTC_YEAR_REG 0x09
  38. #define CMOS_RTC_STA_REG 0x0A
  39. #define CMOS_RTC_STB_REG 0x0B
  40. #define CMOS_RTC_STC_REG 0x0C
  41. typedef struct
  42. {
  43. word_t year;
  44. byte_t day, month, hours, minutes, seconds;
  45. } clock_time_t;
  46. void clock_init();
  47. dword_t clock_get_time(clock_time_t *time);
  48. bool_t clock_check_time(clock_time_t *time);
  49. dword_t clock_set_time(clock_time_t *time);
  50. #endif