time.c 1.4 KB

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