95 lines
2.7 KiB
C
95 lines
2.7 KiB
C
/* @(#)clock.h 1.1 94/10/31 SMI */
|
|
|
|
#ifndef _sun4c_clock_h
|
|
#define _sun4c_clock_h
|
|
|
|
/*
|
|
* Copyright (c) 1988 by Sun Microsystems, Inc.
|
|
*/
|
|
|
|
/*
|
|
* Definitions and structures for the hi resolution counters
|
|
* on sun4c machines. These counters are normally used to generate
|
|
* 100hz clock interrupts, but are fully programmable for whatever
|
|
* purpose desired.
|
|
*/
|
|
#define OBIO_COUNTER_ADDR 0xF3000000 /* addr in obio space */
|
|
#define COUNTER_ADDR 0xFFFF7000 /* virtual addr we map to */
|
|
#ifndef LOCORE
|
|
struct counterregs {
|
|
u_int counter10;
|
|
u_int limit10;
|
|
u_int counter14;
|
|
u_int limit14;
|
|
};
|
|
#define COUNTER ((struct counterregs *)(COUNTER_ADDR))
|
|
#endif !LOCORE
|
|
|
|
#define CTR_LIMIT_BIT 0x80000000 /* limit bit mask */
|
|
#define CTR_USEC_MASK 0x7FFFFC00 /* counter/limit mask */
|
|
#define CTR_USEC_SHIFT 10 /* counter/limit shift */
|
|
|
|
/*
|
|
* Definitions for the Mostek 48T02 clock chip. We use this chip as
|
|
* our TOD clock. Clock interrupts are generated by a separate timer
|
|
* circuit.
|
|
*/
|
|
|
|
#define SECDAY ((unsigned)(24*60*60)) /* seconds per day */
|
|
#define SECYR ((unsigned)(365*SECDAY)) /* seconds per common year */
|
|
|
|
/*
|
|
* The 48T02 uses year % 4 to figure out if
|
|
* we have a leap year, we do the same here.
|
|
*/
|
|
#define SECYEAR(yr) ((((unsigned)(yr) % 4) == 0)? SECYR + SECDAY : SECYR)
|
|
|
|
/*
|
|
* The year register counts from 0 to 99.
|
|
* Unix time is the number of seconds
|
|
* since the year YRREF. The 2 digit year
|
|
* value stored in the chip represents the
|
|
* the number of years beyond YRBASE.
|
|
* Note that YRBASE must be < YRREF and
|
|
* (YRBASE % 4) == 0 to do leap years correct.
|
|
* Note that we can only keep time up to the year 2068.
|
|
*/
|
|
#define YRREF 70 /* 1970 - where UNIX time begins */
|
|
#define YRBASE 68 /* 1968 - what year 0 in chip represents */
|
|
|
|
#define CLOCK_ADDR 0xFFFF87F8 /* virtual address we map clock to be at */
|
|
|
|
#ifndef LOCORE
|
|
struct mostek48T02 {
|
|
u_char clk_ctrl; /* ctrl register */
|
|
u_char clk_sec; /* counter - seconds 0-59 */
|
|
u_char clk_min; /* counter - minutes 0-59 */
|
|
u_char clk_hour; /* counter - hours 0-23 */
|
|
u_char clk_weekday; /* counter - weekday 1-7 */
|
|
u_char clk_day; /* counter - day 1-31 */
|
|
u_char clk_month; /* counter - month 1-12 */
|
|
u_char clk_year; /* counter - year 0-99 */
|
|
};
|
|
#define CLOCK ((struct mostek48T02 *)(CLOCK_ADDR))
|
|
#endif !LOCORE
|
|
|
|
/*
|
|
* Bit masks for various operations and register limits.
|
|
*/
|
|
#define CLK_CTRL_WRITE 0x80
|
|
#define CLK_CTRL_READ 0x40
|
|
#define CLK_CTRL_SIGN 0x20
|
|
|
|
#define CLK_STOP 0x80
|
|
#define CLK_KICK 0x80
|
|
#define CLK_FREQT 0x40
|
|
|
|
#define CLK_MONTH_MASK 0x1f
|
|
#define CLK_DAY_MASK 0x3f
|
|
#define CLK_WEEKDAY_MASK 0x07
|
|
#define CLK_HOUR_MASK 0x3f
|
|
#define CLK_MIN_MASK 0x7f
|
|
#define CLK_SEC_MASK 0x7f
|
|
|
|
#endif /* !_sun4c_clock_h */
|