xref: /titanic_51/usr/src/uts/sun4u/sys/machclock.h (revision 2df1fe9ca32bb227b9158c67f5c00b54c20b10fd)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
525cf1a30Sjl139090  * Common Development and Distribution License (the "License").
625cf1a30Sjl139090  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*2df1fe9cSrandyf  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _SYS_MACHCLOCK_H
277c478bd9Sstevel@tonic-gate #define	_SYS_MACHCLOCK_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef _ASM
367c478bd9Sstevel@tonic-gate /*
377c478bd9Sstevel@tonic-gate  * Macro to clear the NPT (non-privileged trap) bit in the %tick/%stick
387c478bd9Sstevel@tonic-gate  * register.  Uses %g1-%g4.
397c478bd9Sstevel@tonic-gate  */
407c478bd9Sstevel@tonic-gate #define	CLEARTICKNPT				\
417c478bd9Sstevel@tonic-gate 	sethi	%hi(cpu_clearticknpt), %g1;	\
427c478bd9Sstevel@tonic-gate 	jmp	%g1 + %lo(cpu_clearticknpt);	\
437c478bd9Sstevel@tonic-gate 	rd	%pc, %g4
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #endif /* _ASM */
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #if defined(CPU_MODULE)
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * Constants used to convert hi-res timestamps into nanoseconds
517c478bd9Sstevel@tonic-gate  * (see <sys/clock.h> file for more information)
527c478bd9Sstevel@tonic-gate  */
537c478bd9Sstevel@tonic-gate 
5425cf1a30Sjl139090 #if defined(CHEETAH) || defined(HUMMINGBIRD) || defined(OLYMPUS_C)
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * At least 3.9MHz, for slower %stick-based systems.
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate #define	NSEC_SHIFT	8
607c478bd9Sstevel@tonic-gate #define	VTRACE_SHIFT	8
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate #elif defined(SPITFIRE)
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * At least 62.5 MHz, for faster %tick-based systems.
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate #define	NSEC_SHIFT	4
687c478bd9Sstevel@tonic-gate #define	VTRACE_SHIFT	4
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate #else
717c478bd9Sstevel@tonic-gate #error "Compiling for CPU_MODULE but no CPU specified"
727c478bd9Sstevel@tonic-gate #endif
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate #endif /* CPU_MODULE */
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate #ifndef _ASM
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /*
817c478bd9Sstevel@tonic-gate  * Hardware watchdog variables and knobs
827c478bd9Sstevel@tonic-gate  */
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate #define	CLK_WATCHDOG_DEFAULT	10	/* 10 seconds */
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate extern int	watchdog_enable;
877c478bd9Sstevel@tonic-gate extern int	watchdog_available;
887c478bd9Sstevel@tonic-gate extern int	watchdog_activated;
897c478bd9Sstevel@tonic-gate extern uint_t	watchdog_timeout_seconds;
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /*
927c478bd9Sstevel@tonic-gate  * tod module name and operations
937c478bd9Sstevel@tonic-gate  */
947c478bd9Sstevel@tonic-gate struct tod_ops {
957c478bd9Sstevel@tonic-gate 	timestruc_t	(*tod_get)(void);
967c478bd9Sstevel@tonic-gate 	void		(*tod_set)(timestruc_t);
977c478bd9Sstevel@tonic-gate 	uint_t		(*tod_set_watchdog_timer)(uint_t);
987c478bd9Sstevel@tonic-gate 	uint_t		(*tod_clear_watchdog_timer)(void);
997c478bd9Sstevel@tonic-gate 	void		(*tod_set_power_alarm)(timestruc_t);
1007c478bd9Sstevel@tonic-gate 	void		(*tod_clear_power_alarm)(void);
1017c478bd9Sstevel@tonic-gate 	uint64_t	(*tod_get_cpufrequency)(void);
1027c478bd9Sstevel@tonic-gate };
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate extern struct tod_ops	tod_ops;
1057c478bd9Sstevel@tonic-gate extern char		*tod_module_name;
1067c478bd9Sstevel@tonic-gate 
107*2df1fe9cSrandyf /*
108*2df1fe9cSrandyf  * These defines allow common code to use TOD functions independant
109*2df1fe9cSrandyf  * of hardware platform.
110*2df1fe9cSrandyf  */
111*2df1fe9cSrandyf #define	TODOP_GET(top)		((top).tod_get())
112*2df1fe9cSrandyf #define	TODOP_SET(top, ts)	((top).tod_set(ts))
113*2df1fe9cSrandyf #define	TODOP_SETWD(top, nsec)	((top).tod_set_watchdog_timer(nsec))
114*2df1fe9cSrandyf #define	TODOP_CLRWD(top)	((top).tod_clear_watchdog_timer())
115*2df1fe9cSrandyf #define	TODOP_SETWAKE(top, ts)	((top).tod_set_power_alarm(ts))
116*2df1fe9cSrandyf #define	TODOP_CLRWAKE(top)	((top).tod_clear_power_alarm())
117*2df1fe9cSrandyf 
1187c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate #endif	/* _ASM */
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1237c478bd9Sstevel@tonic-gate }
1247c478bd9Sstevel@tonic-gate #endif
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate #endif	/* !_SYS_MACHCLOCK_H */
127