Don't allow the clock chip to be reset if the time hasn't been initialized.

This commit is contained in:
mycroft 1994-07-25 00:19:47 +00:00
parent acb695e52e
commit 8328e78454
1 changed files with 12 additions and 1 deletions

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91 * from: @(#)clock.c 7.2 (Berkeley) 5/12/91
* $Id: clock.c,v 1.24 1994/05/05 05:36:30 cgd Exp $ * $Id: clock.c,v 1.25 1994/07/25 00:19:47 mycroft Exp $
*/ */
/* /*
* Mach Operating System * Mach Operating System
@ -365,6 +365,8 @@ dectohexdec(n)
return((char)(((n/10)<<4)&0xF0) | ((n%10)&0x0F)); return((char)(((n/10)<<4)&0xF0) | ((n%10)&0x0F));
} }
static int timeset;
/* /*
* Initialize the time of day register, based on the time base which is, e.g. * Initialize the time of day register, based on the time base which is, e.g.
* from a filesystem. * from a filesystem.
@ -390,6 +392,8 @@ inittodr(base)
} }
splx(s); splx(s);
timeset = 1;
sec = hexdectodec(rtclk.rtc_sec); sec = hexdectodec(rtclk.rtc_sec);
min = hexdectodec(rtclk.rtc_min); min = hexdectodec(rtclk.rtc_min);
hr = hexdectodec(rtclk.rtc_hr); hr = hexdectodec(rtclk.rtc_hr);
@ -428,6 +432,13 @@ resettodr()
int diff, i, j; int diff, i, j;
int s; int s;
/*
* We might have been called by boot() due to a crash early
* on. Don't reset the clock chip in this case.
*/
if (!timeset)
return;
s = splclock(); s = splclock();
if (rtcget(&rtclk)) if (rtcget(&rtclk))
bzero(&rtclk, sizeof(rtclk)); bzero(&rtclk, sizeof(rtclk));