xref: /csrg-svn/sys/vax/include/clock.h (revision 49436)
1*49436Sbostic /*-
2*49436Sbostic  * Copyright (c) 1982, 1986 The Regents of the University of California.
3*49436Sbostic  * All rights reserved.
423254Smckusick  *
5*49436Sbostic  * %sccs.include.proprietary.c%
6*49436Sbostic  *
7*49436Sbostic  *	@(#)clock.h	7.3 (Berkeley) 05/08/91
823254Smckusick  */
951Sbill 
1051Sbill /*
1151Sbill  * VAX clock registers
1251Sbill  */
1351Sbill 
142633Swnj #define	ICCS_RUN	0x00000001
152633Swnj #define	ICCS_TRANS	0x00000010
162633Swnj #define	ICCS_SS		0x00000020
172633Swnj #define	ICCS_IE		0x00000040
182633Swnj #define	ICCS_INT	0x00000080
1951Sbill #define	ICCS_ERR	0x80000000
2051Sbill 
21880Sbill #define	SECDAY		((unsigned)(24*60*60))		/* seconds per day */
22880Sbill #define	SECYR		((unsigned)(365*SECDAY))	/* per common year */
23880Sbill /*
24880Sbill  * TODRZERO is the what the TODR should contain when the ``year'' begins.
25880Sbill  * The TODR should always contain a number between 0 and SECYR+SECDAY.
26880Sbill  */
27880Sbill #define	TODRZERO	((unsigned)(1<<28))
2851Sbill 
29880Sbill #define	YRREF		1970
302307Swnj #define	LEAPYEAR(year)	((year)%4==0)	/* good till time becomes negative */
31880Sbill 
32880Sbill /*
338987Sroot  * Has the time-of-day clock wrapped around?
34880Sbill  */
35880Sbill #define	clkwrap()	(((unsigned)mfpr(TODR) - TODRZERO)/100 > SECYR+SECDAY)
362447Swnj 
372447Swnj /*
388050Sroot  * Software clock is software interrupt level 8,
398050Sroot  * implemented as mtpr(SIRR, 0x8) in asm.sed.
402447Swnj  */
4134230Skarels 
4234230Skarels #ifndef LOCORE
4334230Skarels /*
4434230Skarels  * 8200s and 630s have a clock chip like those found in digital alarm
4534230Skarels  * clocks and watches.  Converting this to and from system times is
4634230Skarels  * painful, so we do it in only one place.  The routine chiptotime()
4734230Skarels  * converts a chiptime to the right value for time.tv_sec, and
4834230Skarels  * timetochip converts time.tv_sec back.
4934230Skarels  */
5034230Skarels struct chiptime {
5134230Skarels 	int	sec;
5234230Skarels 	int	min;
5334230Skarels 	int	hour;
5434230Skarels 	int	day;
5534230Skarels 	int	mon;
5634230Skarels 	int	year;
5734230Skarels };
5834230Skarels 
5934230Skarels /*
6034230Skarels  * Clock read routine return values.
6134230Skarels  */
6234230Skarels #define	CLKREAD_OK	0	/* success, time.tv_sec set */
6334230Skarels #define	CLKREAD_WARN	1	/* clock appears wrong but time set anyway */
6434230Skarels #define	CLKREAD_BAD	2	/* clock is bad, no time available */
6534230Skarels #endif
66