123254Smckusick /* 229175Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 323254Smckusick * All rights reserved. The Berkeley software License Agreement 423254Smckusick * specifies the terms and conditions for redistribution. 523254Smckusick * 6*34230Skarels * @(#)clock.h 7.2 (Berkeley) 05/07/88 723254Smckusick */ 851Sbill 951Sbill /* 1051Sbill * VAX clock registers 1151Sbill */ 1251Sbill 132633Swnj #define ICCS_RUN 0x00000001 142633Swnj #define ICCS_TRANS 0x00000010 152633Swnj #define ICCS_SS 0x00000020 162633Swnj #define ICCS_IE 0x00000040 172633Swnj #define ICCS_INT 0x00000080 1851Sbill #define ICCS_ERR 0x80000000 1951Sbill 20880Sbill #define SECDAY ((unsigned)(24*60*60)) /* seconds per day */ 21880Sbill #define SECYR ((unsigned)(365*SECDAY)) /* per common year */ 22880Sbill /* 23880Sbill * TODRZERO is the what the TODR should contain when the ``year'' begins. 24880Sbill * The TODR should always contain a number between 0 and SECYR+SECDAY. 25880Sbill */ 26880Sbill #define TODRZERO ((unsigned)(1<<28)) 2751Sbill 28880Sbill #define YRREF 1970 292307Swnj #define LEAPYEAR(year) ((year)%4==0) /* good till time becomes negative */ 30880Sbill 31880Sbill /* 328987Sroot * Has the time-of-day clock wrapped around? 33880Sbill */ 34880Sbill #define clkwrap() (((unsigned)mfpr(TODR) - TODRZERO)/100 > SECYR+SECDAY) 352447Swnj 362447Swnj /* 378050Sroot * Software clock is software interrupt level 8, 388050Sroot * implemented as mtpr(SIRR, 0x8) in asm.sed. 392447Swnj */ 40*34230Skarels 41*34230Skarels #ifndef LOCORE 42*34230Skarels /* 43*34230Skarels * 8200s and 630s have a clock chip like those found in digital alarm 44*34230Skarels * clocks and watches. Converting this to and from system times is 45*34230Skarels * painful, so we do it in only one place. The routine chiptotime() 46*34230Skarels * converts a chiptime to the right value for time.tv_sec, and 47*34230Skarels * timetochip converts time.tv_sec back. 48*34230Skarels */ 49*34230Skarels struct chiptime { 50*34230Skarels int sec; 51*34230Skarels int min; 52*34230Skarels int hour; 53*34230Skarels int day; 54*34230Skarels int mon; 55*34230Skarels int year; 56*34230Skarels }; 57*34230Skarels 58*34230Skarels /* 59*34230Skarels * Clock read routine return values. 60*34230Skarels */ 61*34230Skarels #define CLKREAD_OK 0 /* success, time.tv_sec set */ 62*34230Skarels #define CLKREAD_WARN 1 /* clock appears wrong but time set anyway */ 63*34230Skarels #define CLKREAD_BAD 2 /* clock is bad, no time available */ 64*34230Skarels #endif 65