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