--- Gnu-Mach/i386/i386at/rtc.c 2020/09/02 04:36:58 1.1.1.1 +++ Gnu-Mach/i386/i386at/rtc.c 2020/09/02 04:46:53 1.1.1.3 @@ -1,25 +1,25 @@ -/* +/* * Mach Operating System * Copyright (c) 1991,1990,1989 Carnegie Mellon University * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ @@ -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); @@ -72,15 +73,16 @@ unsigned char *regs; rtcinit(); first_rtcopen_ever = 0; } - outb(RTC_ADDR, RTC_D); - if (inb(RTC_DATA) & RTC_VRT == 0) return(-1); - outb(RTC_ADDR, RTC_A); + outb(RTC_ADDR, RTC_D); + 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); + outb(RTC_ADDR, RTC_A); load_rtc(regs); return(0); -} +} +void rtcput(regs) unsigned char *regs; { @@ -93,10 +95,10 @@ unsigned char *regs; outb(RTC_ADDR, RTC_B); x = inb(RTC_DATA); outb(RTC_ADDR, RTC_B); - outb(RTC_DATA, x | RTC_SET); + outb(RTC_DATA, x | RTC_SET); save_rtc(regs); outb(RTC_ADDR, RTC_B); - outb(RTC_DATA, x & ~RTC_SET); + outb(RTC_DATA, x & ~RTC_SET); } @@ -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);