Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[sfrench/cifs-2.6.git] / include / asm-i386 / vmi_time.h
1 /*
2  * VMI Time wrappers
3  *
4  * Copyright (C) 2006, VMware, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14  * NON INFRINGEMENT.  See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * Send feedback to dhecht@vmware.com
22  *
23  */
24
25 #ifndef __VMI_TIME_H
26 #define __VMI_TIME_H
27
28 /*
29  * Raw VMI call indices for timer functions
30  */
31 #define VMI_CALL_GetCycleFrequency      66
32 #define VMI_CALL_GetCycleCounter        67
33 #define VMI_CALL_SetAlarm               68
34 #define VMI_CALL_CancelAlarm            69
35 #define VMI_CALL_GetWallclockTime       70
36 #define VMI_CALL_WallclockUpdated       71
37
38 /* Cached VMI timer operations */
39 extern struct vmi_timer_ops {
40         u64 (*get_cycle_frequency)(void);
41         u64 (*get_cycle_counter)(int);
42         u64 (*get_wallclock)(void);
43         int (*wallclock_updated)(void);
44         void (*set_alarm)(u32 flags, u64 expiry, u64 period);
45         void (*cancel_alarm)(u32 flags);
46 } vmi_timer_ops;
47
48 /* Prototypes */
49 extern void __init vmi_time_init(void);
50 extern unsigned long vmi_get_wallclock(void);
51 extern int vmi_set_wallclock(unsigned long now);
52 extern unsigned long long vmi_get_sched_cycles(void);
53 extern unsigned long vmi_cpu_khz(void);
54
55 #ifdef CONFIG_X86_LOCAL_APIC
56 extern void __init vmi_timer_setup_boot_alarm(void);
57 extern void __devinit vmi_timer_setup_secondary_alarm(void);
58 extern void apic_vmi_timer_interrupt(void);
59 #endif
60
61 #ifdef CONFIG_NO_IDLE_HZ
62 extern int vmi_stop_hz_timer(void);
63 extern void vmi_account_time_restart_hz_timer(void);
64 #else
65 static inline int vmi_stop_hz_timer(void)
66 {
67         return 0;
68 }
69 static inline void vmi_account_time_restart_hz_timer(void)
70 {
71 }
72 #endif
73
74 /*
75  * When run under a hypervisor, a vcpu is always in one of three states:
76  * running, halted, or ready.  The vcpu is in the 'running' state if it
77  * is executing.  When the vcpu executes the halt interface, the vcpu
78  * enters the 'halted' state and remains halted until there is some work
79  * pending for the vcpu (e.g. an alarm expires, host I/O completes on
80  * behalf of virtual I/O).  At this point, the vcpu enters the 'ready'
81  * state (waiting for the hypervisor to reschedule it).  Finally, at any
82  * time when the vcpu is not in the 'running' state nor the 'halted'
83  * state, it is in the 'ready' state.
84  *
85  * Real time is advances while the vcpu is 'running', 'ready', or
86  * 'halted'.  Stolen time is the time in which the vcpu is in the
87  * 'ready' state.  Available time is the remaining time -- the vcpu is
88  * either 'running' or 'halted'.
89  *
90  * All three views of time are accessible through the VMI cycle
91  * counters.
92  */
93
94 /* The cycle counters. */
95 #define VMI_CYCLES_REAL         0
96 #define VMI_CYCLES_AVAILABLE    1
97 #define VMI_CYCLES_STOLEN       2
98
99 /* The alarm interface 'flags' bits */
100 #define VMI_ALARM_COUNTERS      2
101
102 #define VMI_ALARM_COUNTER_MASK  0x000000ff
103
104 #define VMI_ALARM_WIRED_IRQ0    0x00000000
105 #define VMI_ALARM_WIRED_LVTT    0x00010000
106
107 #define VMI_ALARM_IS_ONESHOT    0x00000000
108 #define VMI_ALARM_IS_PERIODIC   0x00000100
109
110 #define CONFIG_VMI_ALARM_HZ     100
111
112 #endif