machclock.h revision 023e71de9e5670cebc23dd51162833661d3d2d3b
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_MACHCLOCK_H
#define _SYS_MACHCLOCK_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _ASM
/*
* Macro to clear the NPT (non-privileged trap) bit in the %tick/%stick
* register. Uses %g1-%g4.
*/
#define CLEARTICKNPT \
#endif /* _ASM */
#if defined(CPU_MODULE)
/*
* Constants used to convert hi-res timestamps into nanoseconds
*/
/*
* At least 3.9MHz, for slower %stick-based systems.
*/
#define NSEC_SHIFT 8
/*
* At least 62.5 MHz, for faster %tick-based systems.
*/
#define NSEC_SHIFT 4
#define VTRACE_SHIFT 4
#else
#error "Compiling for CPU_MODULE but no CPU specified"
#endif
/*
* NOTE: the macros below assume that the various time-related variables
* (hrestime, hrestime_adj, hres_last_tick, timedelta, nsec_scale, etc)
* are all stored together on a 64-byte boundary. The primary motivation
* is cache performance, but we also take advantage of a convenient side
* effect: these variables all have the same high 22 address bits, so only
* one sethi is needed to access them all.
*/
/*
* GET_HRESTIME() returns the value of hrestime, hrestime_adj and the
* number of nanoseconds since the last clock tick ('nslt'). It also
* sets 'nano' to the value NANOSEC (one billion).
*
* This macro assumes that all registers are globals or outs so they can
* safely contain 64-bit data, and that it's safe to use the label "5:".
* Further, this macro calls the NATIVE_TIME_TO_NSEC_SCALE which in turn
* uses the labels "6:" and "7:"; labels "5:", "6:" and "7:" must not
* be used across invocations of this macro.
*/
/* membar #LoadLoad; (see comment (2) above) */ \
/* CSTYLED */ \
/*
* Similar to above, but returns current gethrtime() value in 'base'.
*/
/* membar #LoadLoad; (see comment (2) above) */ \
/* CSTYLED */ \
#endif /* CPU_MODULE */
#ifndef _ASM
#ifdef _KERNEL
/*
* Hardware watchdog variables and knobs
*/
extern int watchdog_enable;
extern int watchdog_available;
extern int watchdog_activated;
extern uint_t watchdog_timeout_seconds;
/*
* tod module name and operations
*/
struct tod_ops {
timestruc_t (*tod_get)(void);
void (*tod_set)(timestruc_t);
uint_t (*tod_clear_watchdog_timer)(void);
void (*tod_set_power_alarm)(timestruc_t);
void (*tod_clear_power_alarm)(void);
uint64_t (*tod_get_cpufrequency)(void);
};
extern char *tod_module_name;
/*
* These defines allow common code to use TOD functions independant
* of hardware platform.
*/
#endif /* _KERNEL */
#endif /* _ASM */
#ifdef __cplusplus
}
#endif
#endif /* !_SYS_MACHCLOCK_H */