Make bin2bcd and bcd2bin global macroes instead of having local
implementations all over the place.
This commit is contained in:
parent
ae12cdda30
commit
2898c294f4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13438
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.45 1996/01/08 18:50:14 ache Exp $
|
||||
* $Id: clock.c,v 1.46 1996/01/12 17:33:12 bde 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);
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.45 1996/01/08 18:50:14 ache Exp $
|
||||
* $Id: clock.c,v 1.46 1996/01/12 17:33:12 bde 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);
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file tells config what files go into building a kernel,
|
||||
# files marked standard are always included.
|
||||
#
|
||||
# $Id: files.i386,v 1.122 1995/12/29 15:28:46 bde Exp $
|
||||
# $Id: files.i386,v 1.123 1996/01/03 06:26:15 gibbs Exp $
|
||||
#
|
||||
aic7xxx_asm optional ahc device-driver \
|
||||
dependency "$S/dev/aic7xxx/aic7xxx_asm.c" \
|
||||
@ -194,6 +194,7 @@ i386/linux/linux_sysent.c optional linux
|
||||
i386/scsi/aic7xxx.c optional ahc device-driver \
|
||||
dependency "$S/dev/aic7xxx/aic7xxx_reg.h aic7xxx_seq.h"
|
||||
i386/scsi/bt.c optional bt device-driver
|
||||
libkern/bcd.c standard
|
||||
libkern/divdi3.c standard
|
||||
libkern/inet_ntoa.c standard
|
||||
libkern/mcount.c optional profiling-routine
|
||||
|
@ -40,7 +40,7 @@
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: mcd.c,v 1.56 1995/12/22 13:09:39 phk Exp $
|
||||
* $Id: mcd.c,v 1.57 1995/12/22 15:52:07 phk Exp $
|
||||
*/
|
||||
static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
|
||||
|
||||
@ -184,8 +184,6 @@ static int mcd_get(int unit, char *buf, int nmax);
|
||||
static int mcd_setflags(int unit,struct mcd_data *cd);
|
||||
static int mcd_getstat(int unit,int sflg);
|
||||
static int mcd_send(int unit, int cmd,int nretrys);
|
||||
static int bcd2bin(bcd_t b);
|
||||
static bcd_t bin2bcd(int b);
|
||||
static void hsg2msf(int hsg, bcd_t *msf);
|
||||
static int msf2hsg(bcd_t *msf);
|
||||
static int mcd_volinfo(int unit);
|
||||
@ -938,18 +936,6 @@ mcd_send(int unit, int cmd,int nretrys)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
bcd2bin(bcd_t b)
|
||||
{
|
||||
return (b >> 4) * 10 + (b & 15);
|
||||
}
|
||||
|
||||
static bcd_t
|
||||
bin2bcd(int b)
|
||||
{
|
||||
return ((b / 10) << 4) | (b % 10);
|
||||
}
|
||||
|
||||
static void
|
||||
hsg2msf(int hsg, bcd_t *msf)
|
||||
{
|
||||
|
@ -41,7 +41,7 @@
|
||||
*/
|
||||
|
||||
|
||||
/* $Id: scd.c,v 1.15 1995/12/10 19:44:52 bde Exp $ */
|
||||
/* $Id: scd.c,v 1.16 1995/12/10 20:10:23 bde Exp $ */
|
||||
|
||||
/* Please send any comments to micke@dynas.se */
|
||||
|
||||
@ -153,8 +153,6 @@ static struct scd_data {
|
||||
} scd_data[NSCD];
|
||||
|
||||
/* prototypes */
|
||||
static int bcd2bin(bcd_t b);
|
||||
static bcd_t bin2bcd(int b);
|
||||
static void hsg2msf(int hsg, bcd_t *msf);
|
||||
static int msf2hsg(bcd_t *msf);
|
||||
|
||||
@ -1090,18 +1088,6 @@ scd_doread(int state, struct scd_mbx *mbxin)
|
||||
goto harderr;
|
||||
}
|
||||
|
||||
static int
|
||||
bcd2bin(bcd_t b)
|
||||
{
|
||||
return (b >> 4) * 10 + (b & 15);
|
||||
}
|
||||
|
||||
static bcd_t
|
||||
bin2bcd(int b)
|
||||
{
|
||||
return ((b / 10) << 4) | (b % 10);
|
||||
}
|
||||
|
||||
static void
|
||||
hsg2msf(int hsg, bcd_t *msf)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file tells config what files go into building a kernel,
|
||||
# files marked standard are always included.
|
||||
#
|
||||
# $Id: files.i386,v 1.122 1995/12/29 15:28:46 bde Exp $
|
||||
# $Id: files.i386,v 1.123 1996/01/03 06:26:15 gibbs Exp $
|
||||
#
|
||||
aic7xxx_asm optional ahc device-driver \
|
||||
dependency "$S/dev/aic7xxx/aic7xxx_asm.c" \
|
||||
@ -194,6 +194,7 @@ i386/linux/linux_sysent.c optional linux
|
||||
i386/scsi/aic7xxx.c optional ahc device-driver \
|
||||
dependency "$S/dev/aic7xxx/aic7xxx_reg.h aic7xxx_seq.h"
|
||||
i386/scsi/bt.c optional bt device-driver
|
||||
libkern/bcd.c standard
|
||||
libkern/divdi3.c standard
|
||||
libkern/inet_ntoa.c standard
|
||||
libkern/mcount.c optional profiling-routine
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.45 1996/01/08 18:50:14 ache Exp $
|
||||
* $Id: clock.c,v 1.46 1996/01/12 17:33:12 bde 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);
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.45 1996/01/08 18:50:14 ache Exp $
|
||||
* $Id: clock.c,v 1.46 1996/01/12 17:33:12 bde 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);
|
||||
|
@ -40,7 +40,7 @@
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: mcd.c,v 1.56 1995/12/22 13:09:39 phk Exp $
|
||||
* $Id: mcd.c,v 1.57 1995/12/22 15:52:07 phk Exp $
|
||||
*/
|
||||
static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
|
||||
|
||||
@ -184,8 +184,6 @@ static int mcd_get(int unit, char *buf, int nmax);
|
||||
static int mcd_setflags(int unit,struct mcd_data *cd);
|
||||
static int mcd_getstat(int unit,int sflg);
|
||||
static int mcd_send(int unit, int cmd,int nretrys);
|
||||
static int bcd2bin(bcd_t b);
|
||||
static bcd_t bin2bcd(int b);
|
||||
static void hsg2msf(int hsg, bcd_t *msf);
|
||||
static int msf2hsg(bcd_t *msf);
|
||||
static int mcd_volinfo(int unit);
|
||||
@ -938,18 +936,6 @@ mcd_send(int unit, int cmd,int nretrys)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
bcd2bin(bcd_t b)
|
||||
{
|
||||
return (b >> 4) * 10 + (b & 15);
|
||||
}
|
||||
|
||||
static bcd_t
|
||||
bin2bcd(int b)
|
||||
{
|
||||
return ((b / 10) << 4) | (b % 10);
|
||||
}
|
||||
|
||||
static void
|
||||
hsg2msf(int hsg, bcd_t *msf)
|
||||
{
|
||||
|
@ -41,7 +41,7 @@
|
||||
*/
|
||||
|
||||
|
||||
/* $Id: scd.c,v 1.15 1995/12/10 19:44:52 bde Exp $ */
|
||||
/* $Id: scd.c,v 1.16 1995/12/10 20:10:23 bde Exp $ */
|
||||
|
||||
/* Please send any comments to micke@dynas.se */
|
||||
|
||||
@ -153,8 +153,6 @@ static struct scd_data {
|
||||
} scd_data[NSCD];
|
||||
|
||||
/* prototypes */
|
||||
static int bcd2bin(bcd_t b);
|
||||
static bcd_t bin2bcd(int b);
|
||||
static void hsg2msf(int hsg, bcd_t *msf);
|
||||
static int msf2hsg(bcd_t *msf);
|
||||
|
||||
@ -1090,18 +1088,6 @@ scd_doread(int state, struct scd_mbx *mbxin)
|
||||
goto harderr;
|
||||
}
|
||||
|
||||
static int
|
||||
bcd2bin(bcd_t b)
|
||||
{
|
||||
return (b >> 4) * 10 + (b & 15);
|
||||
}
|
||||
|
||||
static bcd_t
|
||||
bin2bcd(int b)
|
||||
{
|
||||
return ((b / 10) << 4) | (b % 10);
|
||||
}
|
||||
|
||||
static void
|
||||
hsg2msf(int hsg, bcd_t *msf)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.45 1996/01/08 18:50:14 ache Exp $
|
||||
* $Id: clock.c,v 1.46 1996/01/12 17:33:12 bde 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);
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)systm.h 8.4 (Berkeley) 2/23/94
|
||||
* $Id: systm.h,v 1.29 1996/01/01 17:05:07 peter Exp $
|
||||
* $Id: systm.h,v 1.30 1996/01/13 18:02:41 phk Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SYSTM_H_
|
||||
@ -170,7 +170,6 @@ extern void nchinit(void);
|
||||
/* Finalize the world. */
|
||||
void shutdown_nice __P((void));
|
||||
|
||||
|
||||
/*
|
||||
* Kernel to clock driver interface.
|
||||
*/
|
||||
@ -186,4 +185,11 @@ void timeout(timeout_func_t, void *, int);
|
||||
void untimeout(timeout_func_t, void *);
|
||||
void logwakeup __P((void));
|
||||
|
||||
/* BCD conversions */
|
||||
extern u_char _bcd2bin[], _bin2bcd[];
|
||||
extern char _hex2ascii[];
|
||||
#define bcd2bin(foo) _bcd2bin[foo]
|
||||
#define bin2bcd(foo) _bin2bcd[foo]
|
||||
#define hex2ascii(foo) _hex2ascii[foo]
|
||||
|
||||
#endif /* !_SYS_SYSTM_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user