time.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include <linux/config.h> /* CONFIG_HEARTBEAT */
  2. #include <linux/errno.h>
  3. #include <linux/sched.h>
  4. #include <linux/kernel.h>
  5. #include <linux/param.h>
  6. #include <linux/string.h>
  7. #include <linux/mm.h>
  8. #include <asm/machdep.h>
  9. #include <asm/io.h>
  10. #include <linux/timex.h>
  11. unsigned long m68k_get_rtc_time(void)
  12. {
  13. unsigned int year, mon, day, hour, min, sec;
  14. extern void arch_gettod(int *year, int *mon, int *day, int *hour,
  15. int *min, int *sec);
  16. arch_gettod (&year, &mon, &day, &hour, &min, &sec);
  17. if ((year += 1900) < 1970)
  18. year += 100;
  19. return mktime(year, mon, day, hour, min, sec);
  20. }
  21. int m68k_set_rtc_time(unsigned long nowtime)
  22. {
  23. if (mach_set_clock_mmss)
  24. return mach_set_clock_mmss (nowtime);
  25. return -1;
  26. }
  27. void apus_heartbeat (void)
  28. {
  29. #ifdef CONFIG_HEARTBEAT
  30. static unsigned cnt = 0, period = 0, dist = 0;
  31. if (cnt == 0 || cnt == dist)
  32. mach_heartbeat( 1 );
  33. else if (cnt == 7 || cnt == dist+7)
  34. mach_heartbeat( 0 );
  35. if (++cnt > period) {
  36. cnt = 0;
  37. /* The hyperbolic function below modifies the heartbeat period
  38. * length in dependency of the current (5min) load. It goes
  39. * through the points f(0)=126, f(1)=86, f(5)=51,
  40. * f(inf)->30. */
  41. period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
  42. dist = period / 4;
  43. }
  44. #endif
  45. /* should be made smarter */
  46. ppc_md.heartbeat_count = 1;
  47. }