|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1988 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution is only permitted until one year after the first shipment ! 6: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and ! 7: * binary forms are permitted provided that: (1) source distributions retain ! 8: * this entire copyright notice and comment, and (2) distributions including ! 9: * binaries display the following acknowledgement: This product includes ! 10: * software developed by the University of California, Berkeley and its ! 11: * contributors'' in the documentation or other materials provided with the ! 12: * distribution and in all advertising materials mentioning features or use ! 13: * of this software. Neither the name of the University nor the names of ! 14: * its contributors may be used to endorse or promote products derived from ! 15: * this software without specific prior written permission. ! 16: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 17: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 18: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 19: * ! 20: * @(#)clock.c 7.3 (Berkeley) 6/28/90 ! 21: */ ! 22: ! 23: #include "param.h" ! 24: #include "time.h" ! 25: #include "kernel.h" ! 26: ! 27: #include "pte.h" ! 28: #include "cpu.h" ! 29: #include "mtpr.h" ! 30: #include "clock.h" ! 31: #include "cp.h" ! 32: ! 33: /* ! 34: * Machine-dependent clock routines. ! 35: * ! 36: * Startrtclock restarts the real-time clock, which provides ! 37: * hardclock interrupts to kern_clock.c. ! 38: * ! 39: * Inittodr initializes any time of day hardware which provides ! 40: * date functions. Its primary function is to use some file ! 41: * system information in case the hardare clock lost state. ! 42: */ ! 43: ! 44: /* ! 45: * Start the real-time clock by initializing the ! 46: * interval timer on the console processor card ! 47: * according to hz. ! 48: */ ! 49: startrtclock() ! 50: { ! 51: register int t; ! 52: static struct cphdr cpclock; /* must be in data space */ ! 53: ! 54: cpclock.cp_unit = CPCLOCK; ! 55: cpclock.cp_comm = CPWRITE; ! 56: if (hz == 0) { ! 57: extern int tickadj; /* XXX */ ! 58: hz = 60; ! 59: tick = 1000000 / hz; ! 60: tickadj = 240000 / (60 * hz); ! 61: printf("clock set to %dhz\n", hz); ! 62: } ! 63: cpclock.cp_count = hztocount(hz); ! 64: if (cnlast) { ! 65: /* try to insure last cmd was taken by cp */ ! 66: for (t = 30000; (cnlast->cp_unit&CPTAKE) == 0 && t > 0; t--) ! 67: uncache(&cnlast->cp_unit); ! 68: cnlast = 0; ! 69: } ! 70: mtpr(CPMDCB, kvtophys(&cpclock)); ! 71: for (t = 30000; (cpclock.cp_unit&CPDONE) == 0 && t > 0; t--) ! 72: uncache(&cpclock.cp_unit); ! 73: } ! 74: ! 75: /* ! 76: * Initialze the time of day register, based on ! 77: * the time base which is, e.g. from a filesystem. ! 78: */ ! 79: inittodr(base) ! 80: time_t base; ! 81: { ! 82: ! 83: if (base < 5*SECYR) { ! 84: printf("WARNING: preposterous time in file system "); ! 85: time.tv_sec = 6*SECYR + 186*SECDAY + SECDAY/2; ! 86: } else ! 87: time.tv_sec = base; ! 88: printf("CHECK AND RESET THE DATE!\n"); ! 89: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.