1 /*- 2 * Copyright (c) 1982, 1986 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 * 7 * @(#)clock.h 7.3 (Berkeley) 05/08/91 8 */ 9 10 /* 11 * VAX clock registers 12 */ 13 14 #define ICCS_RUN 0x00000001 15 #define ICCS_TRANS 0x00000010 16 #define ICCS_SS 0x00000020 17 #define ICCS_IE 0x00000040 18 #define ICCS_INT 0x00000080 19 #define ICCS_ERR 0x80000000 20 21 #define SECDAY ((unsigned)(24*60*60)) /* seconds per day */ 22 #define SECYR ((unsigned)(365*SECDAY)) /* per common year */ 23 /* 24 * TODRZERO is the what the TODR should contain when the ``year'' begins. 25 * The TODR should always contain a number between 0 and SECYR+SECDAY. 26 */ 27 #define TODRZERO ((unsigned)(1<<28)) 28 29 #define YRREF 1970 30 #define LEAPYEAR(year) ((year)%4==0) /* good till time becomes negative */ 31 32 /* 33 * Has the time-of-day clock wrapped around? 34 */ 35 #define clkwrap() (((unsigned)mfpr(TODR) - TODRZERO)/100 > SECYR+SECDAY) 36 37 /* 38 * Software clock is software interrupt level 8, 39 * implemented as mtpr(SIRR, 0x8) in asm.sed. 40 */ 41 42 #ifndef LOCORE 43 /* 44 * 8200s and 630s have a clock chip like those found in digital alarm 45 * clocks and watches. Converting this to and from system times is 46 * painful, so we do it in only one place. The routine chiptotime() 47 * converts a chiptime to the right value for time.tv_sec, and 48 * timetochip converts time.tv_sec back. 49 */ 50 struct chiptime { 51 int sec; 52 int min; 53 int hour; 54 int day; 55 int mon; 56 int year; 57 }; 58 59 /* 60 * Clock read routine return values. 61 */ 62 #define CLKREAD_OK 0 /* success, time.tv_sec set */ 63 #define CLKREAD_WARN 1 /* clock appears wrong but time set anyway */ 64 #define CLKREAD_BAD 2 /* clock is bad, no time available */ 65 #endif 66