dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / arch / x86 / kernel / platform / i86pc / include / sys / apic_timer.h
blob7f7285fb83160e7f00e04a1dc020ba6a06a11ee6
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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
25 * Copyright (c) 2010, Intel Corporation.
26 * All rights reserved.
29 #ifndef _SYS_APIC_TIMER_H
30 #define _SYS_APIC_TIMER_H
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 #include <sys/time.h>
38 #define IA32_DEADLINE_TSC_MSR 0x6E0
40 /* Timer Vector Table register */
41 #define APIC_LOCAL_TIMER 0xc8
43 /* timer vector table */
44 #define AV_PERIODIC 0x20000 /* Set timer mode to periodic */
45 #define AV_DEADLINE 0x40000 /* Set timer mode to deadline */
47 #define APIC_TIMER_MODE_ONESHOT 0x0
48 #define APIC_TIMER_MODE_PERIODIC 0x1
49 #define APIC_TIMER_MODE_DEADLINE 0x2 /* TSC-Deadline timer mode */
51 extern int apic_oneshot;
52 extern uint_t apic_nsec_per_intr;
53 extern uint_t apic_hertz_count;
54 extern uint64_t apic_ticks_per_SFnsecs;
57 * Use scaled-fixed-point arithmetic to calculate apic ticks.
58 * Round when dividing (by adding half of divisor to dividend)
59 * for one extra bit of precision.
62 #define SF (1ULL<<20) /* Scaling Factor: scale by 2^20 */
63 #define APIC_TICKS_TO_NSECS(ticks) ((((int64_t)(ticks) * SF) + \
64 apic_ticks_per_SFnsecs / 2) / \
65 apic_ticks_per_SFnsecs);
66 #define APIC_NSECS_TO_TICKS(nsecs) (((int64_t)(nsecs) * \
67 apic_ticks_per_SFnsecs + (SF/2)) / SF)
69 extern int apic_timer_init(int);
70 extern void apic_timer_reprogram(hrtime_t);
71 extern void apic_timer_enable(void);
72 extern void apic_timer_disable(void);
74 #ifdef __cplusplus
76 #endif
78 #endif /* _SYS_APIC_TIMER_H */