My wife is busy making me a new conical hat, so you don't need to

send any to me this time.  Commited an old copy of this files where
the tables were swapped.  Duh!.
This commit is contained in:
Poul-Henning Kamp 1996-01-15 21:26:43 +00:00
parent e95fbcfeb4
commit 3eb50b2edd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13445
6 changed files with 62 additions and 117 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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,