diff options
Diffstat (limited to 'arch/ppc/kernel/time.h')
-rw-r--r-- | arch/ppc/kernel/time.h | 58 |
1 files changed, 15 insertions, 43 deletions
diff --git a/arch/ppc/kernel/time.h b/arch/ppc/kernel/time.h index 9ce5921dc..538ac7bb1 100644 --- a/arch/ppc/kernel/time.h +++ b/arch/ppc/kernel/time.h @@ -1,5 +1,5 @@ /* - * $Id: time.h,v 1.5 1997/08/27 22:06:58 cort Exp $ + * $Id: time.h,v 1.7 1997/12/28 22:47:24 paulus Exp $ * Common time prototypes and such for all ppc machines. * * Written by Cort Dougan (cort@cs.nmt.edu) to merge @@ -9,17 +9,16 @@ #include <linux/mc146818rtc.h> /* time.c */ -__inline__ unsigned long get_dec(void); -__inline__ void set_dec(int val); void prep_calibrate_decr_handler(int, void *,struct pt_regs *); void prep_calibrate_decr(void); void pmac_calibrate_decr(void); -void chrp_calibrate_decr(void); extern unsigned decrementer_count; extern unsigned count_period_num; extern unsigned count_period_den; extern unsigned long mktime(unsigned int, unsigned int,unsigned int, - unsigned int, unsigned int, unsigned int); + unsigned int, unsigned int, unsigned int); +extern void to_tm(int tim, struct rtc_time * tm); +extern unsigned long last_rtc_update; /* pmac/prep/chrp_time.c */ unsigned long prep_get_rtc_time(void); @@ -29,46 +28,19 @@ int prep_set_rtc_time(unsigned long nowtime); int pmac_set_rtc_time(unsigned long nowtime); int chrp_set_rtc_time(unsigned long nowtime); void pmac_read_rtc_time(void); +void chrp_calibrate_decr(void); +void chrp_time_init(void); -#define TICK_SIZE tick -#define FEBRUARY 2 -#define STARTOFTIME 1970 -#define SECDAY 86400L -#define SECYR (SECDAY * 365) -#define leapyear(year) ((year) % 4 == 0) -#define days_in_year(a) (leapyear(a) ? 366 : 365) -#define days_in_month(a) (month_days[(a) - 1]) - -static int month_days[12] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - -extern void inline to_tm(int tim, struct rtc_time * tm) +/* Accessor functions for the decrementer register. */ +static __inline__ unsigned int get_dec(void) { - register int i; - register long hms, day; - - day = tim / SECDAY; - hms = tim % SECDAY; + unsigned int ret; - /* Hours, minutes, seconds are easy */ - tm->tm_hour = hms / 3600; - tm->tm_min = (hms % 3600) / 60; - tm->tm_sec = (hms % 3600) % 60; - - /* Number of years in days */ - for (i = STARTOFTIME; day >= days_in_year(i); i++) - day -= days_in_year(i); - tm->tm_year = i; - - /* Number of months in days left */ - if (leapyear(tm->tm_year)) - days_in_month(FEBRUARY) = 29; - for (i = 1; day >= days_in_month(i); i++) - day -= days_in_month(i); - days_in_month(FEBRUARY) = 28; - tm->tm_mon = i; + asm volatile("mfspr %0,22" : "=r" (ret) :); + return ret; +} - /* Days are what is left over (+1) from all that. */ - tm->tm_mday = day + 1; +static __inline__ void set_dec(unsigned int val) +{ + asm volatile("mtspr 22,%0" : : "r" (val)); } |