dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / arch / x86 / kernel / platform / i86pc / include / sys / clock.h
blob55b9c4ef466f54cc732af76c4d1846d9e37c5ab8
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_CLOCK_H
27 #define _SYS_CLOCK_H
29 #pragma ident "%Z%%M% %I% %E% SMI"
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 #ifdef _KERNEL
37 #ifndef _ASM
39 #include <sys/psw.h>
40 #include <sys/time.h>
41 #include <sys/processor.h>
42 #if defined(__GNUC__) && defined(_ASM_INLINES)
43 #include <asm/clock.h>
44 #endif
45 #include <sys/machclock.h>
47 extern time_t ggmtl(void);
48 extern void sgmtl(time_t);
49 extern void rtcsync(void);
51 extern void unlock_hres_lock(void);
52 extern void hres_tick(void);
53 extern void (*hrtime_tick)(void);
55 #ifndef __xpv
56 extern void tsc_hrtimeinit(uint64_t cpu_freq_hz);
57 extern void tsc_sync_master(processorid_t);
58 extern void tsc_sync_slave(void);
59 #endif
62 * Careful: this can always return zero on some systems. Use the system hrtime
63 * routines if you want a meaningful time.
65 extern hrtime_t tsc_read(void);
67 extern hrtime_t __rdtsc_insn(void);
69 extern int tsc_gethrtime_enable;
71 #define ADJ_SHIFT 4 /* used in get_hrestime */
73 #define YRBASE 00 /* 1900 - what year 0 in chip represents */
75 #endif /* !_ASM */
77 #define CBE_HIGH_PIL 14
78 #define CBE_LOCK_PIL LOCK_LEVEL
79 #define CBE_LOW_PIL 2
82 * CLOCK_LOCK() sets the LSB (bit 0) of the hres_lock. The rest of the
83 * 31bits are used as the counter. This lock is acquired
84 * around "hrestime" and "timedelta". This lock is acquired to make
85 * sure that level-14 accounts for changes to this variable in that
86 * interrupt itself. The level-14 interrupt code also acquires this
87 * lock.
88 * (Note: It is assumed that the lock_set_spl() uses only bit 0 of the lock.)
90 * CLOCK_UNLOCK() increments the lower bytes straight, thus clearing the
91 * lock and also incrementing the counter. This way gethrtime()
92 * can figure out if the value in the lock got changed or not.
94 #define HRES_LOCK_OFFSET 0 /* byte 0 has the lock bit(bit 0 in the byte) */
96 #define CLOCK_LOCK(oldsplp) \
97 lock_set_spl((lock_t *)&hres_lock + HRES_LOCK_OFFSET, \
98 ipltospl(XC_HI_PIL), oldsplp)
100 #define CLOCK_UNLOCK(spl) \
101 unlock_hres_lock(); \
102 splx(spl); \
103 LOCKSTAT_RECORD0(LS_CLOCK_UNLOCK_RELEASE, \
104 (lock_t *)&hres_lock + HRES_LOCK_OFFSET);
106 #endif /* KERNEL */
108 #ifdef __cplusplus
110 #endif
112 #endif /* _SYS_CLOCK_H */