summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>1996-01-15 21:26:43 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>1996-01-15 21:26:43 +0000
commit3eb50b2eddeda38038d81e2786dc1f1fe0c89ec5 (patch)
tree4bf47fe2b3e27e96c5e444a1527d407ddd423ed0
parente95fbcfeb407ad32f8ec4bbbecccf2459d0fe894 (diff)
Notes
-rw-r--r--sys/amd64/amd64/tsc.c35
-rw-r--r--sys/amd64/isa/clock.c35
-rw-r--r--sys/i386/i386/tsc.c35
-rw-r--r--sys/i386/isa/clock.c35
-rw-r--r--sys/isa/atrtc.c35
-rw-r--r--sys/libkern/bcd.c4
6 files changed, 62 insertions, 117 deletions
diff --git a/sys/amd64/amd64/tsc.c b/sys/amd64/amd64/tsc.c
index 9dba18b0e603..a6d2aca78d85 100644
--- a/sys/amd64/amd64/tsc.c
+++ b/sys/amd64/amd64/tsc.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
- * $Id: clock.c,v 1.46 1996/01/12 17:33:12 bde Exp $
+ * $Id: clock.c,v 1.48 1996/01/15 21:12:50 phk Exp $
*/
/*
@@ -398,29 +398,18 @@ 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 int
+static __inline int
readrtc(int port)
{
- return(bcd2int(rtcin(port)));
+ return(bcd2bin(rtcin(port)));
}
/*
@@ -523,9 +512,9 @@ resettodr()
tm -= tz.tz_minuteswest * 60 + adjkerntz;
- 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 */
+ 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 */
/* We have now the days since 01-01-1970 in tm */
writertc(RTC_WDAY, (tm+4)%7); /* Write back Weekday */
@@ -536,10 +525,10 @@ resettodr()
/* Now we have the years in y and the day-of-the-year in tm */
#ifdef USE_RTC_CENTURY
- writertc(RTC_YEAR, int2bcd(y%100)); /* Write back Year */
- writertc(RTC_CENTURY, int2bcd(y/100)); /* ... and Century */
+ writertc(RTC_YEAR, bin2bcd(y%100)); /* Write back Year */
+ writertc(RTC_CENTURY, bin2bcd(y/100)); /* ... and Century */
#else
- writertc(RTC_YEAR, int2bcd(y - 1900)); /* Write back Year */
+ writertc(RTC_YEAR, bin2bcd(y - 1900)); /* Write back Year */
#endif
for (m = 0; ; m++) {
int ml;
@@ -552,8 +541,8 @@ resettodr()
tm -= ml;
}
- writertc(RTC_MONTH, int2bcd(m + 1)); /* Write back Month */
- writertc(RTC_DAY, int2bcd(tm + 1)); /* Write back Month Day */
+ writertc(RTC_MONTH, bin2bcd(m + 1)); /* Write back Month */
+ writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
/* Reenable RTC updates and interrupts. */
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR);
diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c
index 9dba18b0e603..a6d2aca78d85 100644
--- a/sys/amd64/isa/clock.c
+++ b/sys/amd64/isa/clock.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
- * $Id: clock.c,v 1.46 1996/01/12 17:33:12 bde Exp $
+ * $Id: clock.c,v 1.48 1996/01/15 21:12:50 phk Exp $
*/
/*
@@ -398,29 +398,18 @@ 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 int
+static __inline int
readrtc(int port)
{
- return(bcd2int(rtcin(port)));
+ return(bcd2bin(rtcin(port)));
}
/*
@@ -523,9 +512,9 @@ resettodr()
tm -= tz.tz_minuteswest * 60 + adjkerntz;
- 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 */
+ 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 */
/* We have now the days since 01-01-1970 in tm */
writertc(RTC_WDAY, (tm+4)%7); /* Write back Weekday */
@@ -536,10 +525,10 @@ resettodr()
/* Now we have the years in y and the day-of-the-year in tm */
#ifdef USE_RTC_CENTURY
- writertc(RTC_YEAR, int2bcd(y%100)); /* Write back Year */
- writertc(RTC_CENTURY, int2bcd(y/100)); /* ... and Century */
+ writertc(RTC_YEAR, bin2bcd(y%100)); /* Write back Year */
+ writertc(RTC_CENTURY, bin2bcd(y/100)); /* ... and Century */
#else
- writertc(RTC_YEAR, int2bcd(y - 1900)); /* Write back Year */
+ writertc(RTC_YEAR, bin2bcd(y - 1900)); /* Write back Year */
#endif
for (m = 0; ; m++) {
int ml;
@@ -552,8 +541,8 @@ resettodr()
tm -= ml;
}
- writertc(RTC_MONTH, int2bcd(m + 1)); /* Write back Month */
- writertc(RTC_DAY, int2bcd(tm + 1)); /* Write back Month Day */
+ writertc(RTC_MONTH, bin2bcd(m + 1)); /* Write back Month */
+ writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
/* Reenable RTC updates and interrupts. */
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR);
diff --git a/sys/i386/i386/tsc.c b/sys/i386/i386/tsc.c
index 9dba18b0e603..a6d2aca78d85 100644
--- a/sys/i386/i386/tsc.c
+++ b/sys/i386/i386/tsc.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
- * $Id: clock.c,v 1.46 1996/01/12 17:33:12 bde Exp $
+ * $Id: clock.c,v 1.48 1996/01/15 21:12:50 phk Exp $
*/
/*
@@ -398,29 +398,18 @@ 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 int
+static __inline int
readrtc(int port)
{
- return(bcd2int(rtcin(port)));
+ return(bcd2bin(rtcin(port)));
}
/*
@@ -523,9 +512,9 @@ resettodr()
tm -= tz.tz_minuteswest * 60 + adjkerntz;
- 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 */
+ 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 */
/* We have now the days since 01-01-1970 in tm */
writertc(RTC_WDAY, (tm+4)%7); /* Write back Weekday */
@@ -536,10 +525,10 @@ resettodr()
/* Now we have the years in y and the day-of-the-year in tm */
#ifdef USE_RTC_CENTURY
- writertc(RTC_YEAR, int2bcd(y%100)); /* Write back Year */
- writertc(RTC_CENTURY, int2bcd(y/100)); /* ... and Century */
+ writertc(RTC_YEAR, bin2bcd(y%100)); /* Write back Year */
+ writertc(RTC_CENTURY, bin2bcd(y/100)); /* ... and Century */
#else
- writertc(RTC_YEAR, int2bcd(y - 1900)); /* Write back Year */
+ writertc(RTC_YEAR, bin2bcd(y - 1900)); /* Write back Year */
#endif
for (m = 0; ; m++) {
int ml;
@@ -552,8 +541,8 @@ resettodr()
tm -= ml;
}
- writertc(RTC_MONTH, int2bcd(m + 1)); /* Write back Month */
- writertc(RTC_DAY, int2bcd(tm + 1)); /* Write back Month Day */
+ writertc(RTC_MONTH, bin2bcd(m + 1)); /* Write back Month */
+ writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
/* Reenable RTC updates and interrupts. */
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR);
diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c
index 9dba18b0e603..a6d2aca78d85 100644
--- a/sys/i386/isa/clock.c
+++ b/sys/i386/isa/clock.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
- * $Id: clock.c,v 1.46 1996/01/12 17:33:12 bde Exp $
+ * $Id: clock.c,v 1.48 1996/01/15 21:12:50 phk Exp $
*/
/*
@@ -398,29 +398,18 @@ 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 int
+static __inline int
readrtc(int port)
{
- return(bcd2int(rtcin(port)));
+ return(bcd2bin(rtcin(port)));
}
/*
@@ -523,9 +512,9 @@ resettodr()
tm -= tz.tz_minuteswest * 60 + adjkerntz;
- 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 */
+ 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 */
/* We have now the days since 01-01-1970 in tm */
writertc(RTC_WDAY, (tm+4)%7); /* Write back Weekday */
@@ -536,10 +525,10 @@ resettodr()
/* Now we have the years in y and the day-of-the-year in tm */
#ifdef USE_RTC_CENTURY
- writertc(RTC_YEAR, int2bcd(y%100)); /* Write back Year */
- writertc(RTC_CENTURY, int2bcd(y/100)); /* ... and Century */
+ writertc(RTC_YEAR, bin2bcd(y%100)); /* Write back Year */
+ writertc(RTC_CENTURY, bin2bcd(y/100)); /* ... and Century */
#else
- writertc(RTC_YEAR, int2bcd(y - 1900)); /* Write back Year */
+ writertc(RTC_YEAR, bin2bcd(y - 1900)); /* Write back Year */
#endif
for (m = 0; ; m++) {
int ml;
@@ -552,8 +541,8 @@ resettodr()
tm -= ml;
}
- writertc(RTC_MONTH, int2bcd(m + 1)); /* Write back Month */
- writertc(RTC_DAY, int2bcd(tm + 1)); /* Write back Month Day */
+ writertc(RTC_MONTH, bin2bcd(m + 1)); /* Write back Month */
+ writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
/* Reenable RTC updates and interrupts. */
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR);
diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c
index 9dba18b0e603..a6d2aca78d85 100644
--- a/sys/isa/atrtc.c
+++ b/sys/isa/atrtc.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
- * $Id: clock.c,v 1.46 1996/01/12 17:33:12 bde Exp $
+ * $Id: clock.c,v 1.48 1996/01/15 21:12:50 phk Exp $
*/
/*
@@ -398,29 +398,18 @@ 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 int
+static __inline int
readrtc(int port)
{
- return(bcd2int(rtcin(port)));
+ return(bcd2bin(rtcin(port)));
}
/*
@@ -523,9 +512,9 @@ resettodr()
tm -= tz.tz_minuteswest * 60 + adjkerntz;
- 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 */
+ 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 */
/* We have now the days since 01-01-1970 in tm */
writertc(RTC_WDAY, (tm+4)%7); /* Write back Weekday */
@@ -536,10 +525,10 @@ resettodr()
/* Now we have the years in y and the day-of-the-year in tm */
#ifdef USE_RTC_CENTURY
- writertc(RTC_YEAR, int2bcd(y%100)); /* Write back Year */
- writertc(RTC_CENTURY, int2bcd(y/100)); /* ... and Century */
+ writertc(RTC_YEAR, bin2bcd(y%100)); /* Write back Year */
+ writertc(RTC_CENTURY, bin2bcd(y/100)); /* ... and Century */
#else
- writertc(RTC_YEAR, int2bcd(y - 1900)); /* Write back Year */
+ writertc(RTC_YEAR, bin2bcd(y - 1900)); /* Write back Year */
#endif
for (m = 0; ; m++) {
int ml;
@@ -552,8 +541,8 @@ resettodr()
tm -= ml;
}
- writertc(RTC_MONTH, int2bcd(m + 1)); /* Write back Month */
- writertc(RTC_DAY, int2bcd(tm + 1)); /* Write back Month Day */
+ writertc(RTC_MONTH, bin2bcd(m + 1)); /* Write back Month */
+ writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
/* Reenable RTC updates and interrupts. */
writertc(RTC_STATUSB, RTCSB_24HR | RTCSB_PINTR);
diff --git a/sys/libkern/bcd.c b/sys/libkern/bcd.c
index 13178f0206fb..35daaccf1e11 100644
--- a/sys/libkern/bcd.c
+++ b/sys/libkern/bcd.c
@@ -5,7 +5,7 @@
#include <sys/types.h>
-u_char const _bin2bcd[] = {
+u_char const _bcd2bin[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,0,0,0,0,0,0,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,0,0,0,0,0,0,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,0,0,0,0,0,0,
@@ -18,7 +18,7 @@ u_char const _bin2bcd[] = {
90, 91, 92, 93, 94, 95, 96, 97, 98, 99
};
-u_char const _bcd2bin[] = {
+u_char const _bin2bcd[] = {
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,