--- 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:49:23 1.1.1.4 @@ -48,14 +48,15 @@ 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; +static boolean_t first_rtcopen_ever = TRUE; -rtcinit() +void +rtcinit(void) { outb(RTC_ADDR, RTC_A); outb(RTC_DATA, RTC_DIV2 | RTC_RATE6); @@ -65,15 +66,14 @@ rtcinit() int -rtcget(regs) -unsigned char *regs; +rtcget(unsigned char *regs) { if (first_rtcopen_ever) { rtcinit(); - first_rtcopen_ever = 0; + first_rtcopen_ever = FALSE; } 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,14 +81,14 @@ unsigned char *regs; return(0); } -rtcput(regs) -unsigned char *regs; +void +rtcput(unsigned char *regs) { - register unsigned char x; + unsigned char x; if (first_rtcopen_ever) { rtcinit(); - first_rtcopen_ever = 0; + first_rtcopen_ever = FALSE; } outb(RTC_ADDR, RTC_B); x = inb(RTC_DATA); @@ -101,32 +101,29 @@ unsigned char *regs; extern struct timeval time; -extern struct timezone tz; static int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; -yeartoday(year) -int year; +int +yeartoday(int year) { return((year%4) ? 365 : 366); } -hexdectodec(n) -char n; +int +hexdectodec(char n) { return(((n>>4)&0x0F)*10 + (n&0x0F)); } char -dectohexdec(n) -int n; +dectohexdec(int n) { return((char)(((n/10)<<4)&0xF0) | ((n%10)&0x0F)); } - -readtodc(tp) - u_int *tp; +int +readtodc(u_int *tp) { struct rtc_st rtclk; time_t n; @@ -134,11 +131,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,43 +158,28 @@ 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); } -writetodc() +int +writetodc(void) { struct rtc_st rtclk; time_t n; 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 +203,7 @@ writetodc() rtclk.rtc_dom = dectohexdec(++n); -#ifdef MACH_KERNEL ospl = splclock(); -#else /* MACH_KERNEL */ - ospl = spl5(); -#endif /* MACH_KERNEL */ rtcput(&rtclk); splx(ospl);