time.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * linux/arch/h8300/kernel/time.c
  3. *
  4. * Yoshinori Sato <ysato@users.sourceforge.jp>
  5. *
  6. * Copied/hacked from:
  7. *
  8. * linux/arch/m68k/kernel/time.c
  9. *
  10. * Copyright (C) 1991, 1992, 1995 Linus Torvalds
  11. *
  12. * This file contains the m68k-specific time handling details.
  13. * Most of the stuff is located in the machine specific files.
  14. *
  15. * 1997-09-10 Updated NTP code according to technical memorandum Jan '96
  16. * "A Kernel Model for Precision Timekeeping" by Dave Mills
  17. */
  18. #include <linux/errno.h>
  19. #include <linux/module.h>
  20. #include <linux/sched.h>
  21. #include <linux/kernel.h>
  22. #include <linux/param.h>
  23. #include <linux/string.h>
  24. #include <linux/mm.h>
  25. #include <linux/timex.h>
  26. #include <linux/profile.h>
  27. #include <asm/io.h>
  28. #include <asm/timer.h>
  29. #define TICK_SIZE (tick_nsec / 1000)
  30. void h8300_timer_tick(void)
  31. {
  32. if (current->pid)
  33. profile_tick(CPU_PROFILING);
  34. xtime_update(1);
  35. update_process_times(user_mode(get_irq_regs()));
  36. }
  37. void read_persistent_clock(struct timespec *ts)
  38. {
  39. unsigned int year, mon, day, hour, min, sec;
  40. /* FIX by dqg : Set to zero for platforms that don't have tod */
  41. /* without this time is undefined and can overflow time_t, causing */
  42. /* very strange errors */
  43. year = 1980;
  44. mon = day = 1;
  45. hour = min = sec = 0;
  46. #ifdef CONFIG_H8300_GETTOD
  47. h8300_gettod (&year, &mon, &day, &hour, &min, &sec);
  48. #endif
  49. if ((year += 1900) < 1970)
  50. year += 100;
  51. ts->tv_sec = mktime(year, mon, day, hour, min, sec);
  52. ts->tv_nsec = 0;
  53. }
  54. void __init time_init(void)
  55. {
  56. h8300_timer_setup();
  57. }