xref: /illumos-gate/usr/src/uts/sun4u/sys/machclock.h (revision 25cf1a30)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_MACHCLOCK_H
27 #define	_SYS_MACHCLOCK_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #ifdef _ASM
36 /*
37  * Macro to clear the NPT (non-privileged trap) bit in the %tick/%stick
38  * register.  Uses %g1-%g4.
39  */
40 #define	CLEARTICKNPT				\
41 	sethi	%hi(cpu_clearticknpt), %g1;	\
42 	jmp	%g1 + %lo(cpu_clearticknpt);	\
43 	rd	%pc, %g4
44 
45 #endif /* _ASM */
46 
47 #if defined(CPU_MODULE)
48 
49 /*
50  * Constants used to convert hi-res timestamps into nanoseconds
51  * (see <sys/clock.h> file for more information)
52  */
53 
54 #if defined(CHEETAH) || defined(HUMMINGBIRD) || defined(OLYMPUS_C)
55 
56 /*
57  * At least 3.9MHz, for slower %stick-based systems.
58  */
59 #define	NSEC_SHIFT	8
60 #define	VTRACE_SHIFT	8
61 
62 #elif defined(SPITFIRE)
63 
64 /*
65  * At least 62.5 MHz, for faster %tick-based systems.
66  */
67 #define	NSEC_SHIFT	4
68 #define	VTRACE_SHIFT	4
69 
70 #else
71 #error "Compiling for CPU_MODULE but no CPU specified"
72 #endif
73 
74 #endif /* CPU_MODULE */
75 
76 #ifndef _ASM
77 
78 #ifdef	_KERNEL
79 
80 /*
81  * Hardware watchdog variables and knobs
82  */
83 
84 #define	CLK_WATCHDOG_DEFAULT	10	/* 10 seconds */
85 
86 extern int	watchdog_enable;
87 extern int	watchdog_available;
88 extern int	watchdog_activated;
89 extern uint_t	watchdog_timeout_seconds;
90 
91 /*
92  * tod module name and operations
93  */
94 struct tod_ops {
95 	timestruc_t	(*tod_get)(void);
96 	void		(*tod_set)(timestruc_t);
97 	uint_t		(*tod_set_watchdog_timer)(uint_t);
98 	uint_t		(*tod_clear_watchdog_timer)(void);
99 	void		(*tod_set_power_alarm)(timestruc_t);
100 	void		(*tod_clear_power_alarm)(void);
101 	uint64_t	(*tod_get_cpufrequency)(void);
102 };
103 
104 extern struct tod_ops	tod_ops;
105 extern char		*tod_module_name;
106 
107 #endif	/* _KERNEL */
108 
109 #endif	/* _ASM */
110 
111 #ifdef	__cplusplus
112 }
113 #endif
114 
115 #endif	/* !_SYS_MACHCLOCK_H */
116