diff options
author | phk <phk@FreeBSD.org> | 1996-01-15 21:12:50 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1996-01-15 21:12:50 +0000 |
commit | 53601cdcfd7ed1757f209cd45cf9d2b85757f919 (patch) | |
tree | 49bd4a6715720bb75ee9c4605db4a375b11aeb4a /sys/isa | |
parent | a3998bb8d13e442746235e00fda1a9f723d86206 (diff) | |
download | FreeBSD-src-53601cdcfd7ed1757f209cd45cf9d2b85757f919.zip FreeBSD-src-53601cdcfd7ed1757f209cd45cf9d2b85757f919.tar.gz |
Soren called an said that I screwed up badly, so I backup until
I find out how... Sorry.
Diffstat (limited to 'sys/isa')
-rw-r--r-- | sys/isa/atrtc.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index be02840..9dba18b 100644 --- a/sys/isa/atrtc.c +++ b/sys/isa/atrtc.c @@ -398,18 +398,29 @@ sysbeep(int pitch, int period) /* * RTC support routines */ +static int +bcd2int(int bcd) +{ + return(bcd/16 * 10 + bcd%16); +} + +static int +int2bcd(int dez) +{ + return(dez/10 * 16 + dez%10); +} -static __inline void +static inline void writertc(u_char reg, u_char val) { outb(IO_RTC, reg); outb(IO_RTC + 1, val); } -static __inline int +static int readrtc(int port) { - return(bcd2bin(rtcin(port))); + return(bcd2int(rtcin(port))); } /* @@ -512,9 +523,9 @@ resettodr() tm -= tz.tz_minuteswest * 60 + adjkerntz; - writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */ - writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */ - writertc(RTC_HRS, bin2bcd(tm%24)); tm /= 24; /* Write back Hours */ + writertc(RTC_SEC, int2bcd(tm%60)); tm /= 60; /* Write back Seconds */ + writertc(RTC_MIN, int2bcd(tm%60)); tm /= 60; /* Write back Minutes */ + writertc(RTC_HRS, int2bcd(tm%24)); tm /= 24; /* Write back Hours */ /* We have now the days since 01-01-1970 in tm */ writertc(RTC_WDAY, (tm+4)%7); /* Write back Weekday */ @@ -525,10 +536,10 @@ resettodr() /* Now we have the years in y and the day-of-the-year in tm */ #ifdef USE_RTC_CENTURY - writertc(RTC_YEAR, bin2bcd(y%100)); /* Write back Year */ - writertc(RTC_CENTURY, bin2bcd(y/100)); /* ... and Century */ + writertc(RTC_YEAR, int2bcd(y%100)); /* Write back Year */ + writertc(RTC_CENTURY, int2bcd(y/100)); /* ... and Century */ #else - writertc(RTC_YEAR, bin2bcd(y - 1900)); /* Write back Year */ + writertc(RTC_YEAR, int2bcd(y - 1900)); /* Write back Year */ #endif for (m = 0; ; m++) { int ml; @@ -541,8 +552,8 @@ resettodr() tm -= ml; } - writertc(RTC_MONTH, bin2bcd(m + 1)); /* Write back Month */ - writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */ + writertc(RTC_MONTH, int2bcd(m + 1)); /* Write back Month */ + writertc(RTC_DAY, int2bcd(tm + 1)); /* Write back Month Day */ /* Reenable RTC updates and interrupts. */ writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR); |