--- Gnu-Mach/i386/i386at/rtc.c 2020/09/02 04:44:37 1.1.1.2 +++ Gnu-Mach/i386/i386at/rtc.c 2020/09/02 04:46:53 1.1.1.3 @@ -48,13 +48,14 @@ WITH THE USE OR PERFORMANCE OF THIS SOFT #include #include -#include +#include #include +#include #include -static unsigned char rtc[RTC_NREG]; static int first_rtcopen_ever = 1; +void rtcinit() { outb(RTC_ADDR, RTC_A); @@ -73,7 +74,7 @@ unsigned char *regs; first_rtcopen_ever = 0; } outb(RTC_ADDR, RTC_D); - if (inb(RTC_DATA) & RTC_VRT == 0) return(-1); + if ((inb(RTC_DATA) & RTC_VRT) == 0) return(-1); outb(RTC_ADDR, RTC_A); while (inb(RTC_DATA) & RTC_UIP) /* busy wait */ outb(RTC_ADDR, RTC_A); @@ -81,6 +82,7 @@ unsigned char *regs; return(0); } +void rtcput(regs) unsigned char *regs; { @@ -105,12 +107,14 @@ extern struct timezone tz; static int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; +int yeartoday(year) int year; { return((year%4) ? 365 : 366); } +int hexdectodec(n) char n; { @@ -124,7 +128,7 @@ int n; return((char)(((n/10)<<4)&0xF0) | ((n%10)&0x0F)); } - +int readtodc(tp) u_int *tp; { @@ -134,11 +138,7 @@ readtodc(tp) int i, days = 0; spl_t ospl; -#ifdef MACH_KERNEL ospl = splclock(); -#else /* MACH_KERNEL */ - ospl = spl5(); -#endif /* MACH_KERNEL */ if (rtcget(&rtclk)) { splx(ospl); return(-1); @@ -165,18 +165,13 @@ readtodc(tp) days += yeartoday(i); n += days * 3600 * 24; -#ifdef MACH_KERNEL -#else /* MACH_KERNEL */ - n += tz.tz_minuteswest * 60; - if (tz.tz_dsttime) - n -= 3600; -#endif /* MACH_KERNEL */ *tp = n; return(0); } +int writetodc() { struct rtc_st rtclk; @@ -184,24 +179,14 @@ writetodc() int diff, i, j; spl_t ospl; -#ifdef MACH_KERNEL ospl = splclock(); -#else /* MACH_KERNEL */ - ospl = spl5(); -#endif /* MACH_KERNEL */ if (rtcget(&rtclk)) { splx(ospl); return(-1); } splx(ospl); -#ifdef MACH_KERNEL diff = 0; -#else /* MACH_KERNEL */ - diff = tz.tz_minuteswest * 60; - if (tz.tz_dsttime) - diff -= 3600; -#endif /* MACH_KERNEL */ n = (time.tv_sec - diff) % (3600 * 24); /* hrs+mins+secs */ rtclk.rtc_sec = dectohexdec(n%60); n /= 60; @@ -225,11 +210,7 @@ writetodc() rtclk.rtc_dom = dectohexdec(++n); -#ifdef MACH_KERNEL ospl = splclock(); -#else /* MACH_KERNEL */ - ospl = spl5(); -#endif /* MACH_KERNEL */ rtcput(&rtclk); splx(ospl);