vmi_time.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #ifndef _ASM_X86_VMI_TIME_H
  25. #define _ASM_X86_VMI_TIME_H
  26. /*
  27. * Raw VMI call indices for timer functions
  28. */
  29. #define VMI_CALL_GetCycleFrequency 66
  30. #define VMI_CALL_GetCycleCounter 67
  31. #define VMI_CALL_SetAlarm 68
  32. #define VMI_CALL_CancelAlarm 69
  33. #define VMI_CALL_GetWallclockTime 70
  34. #define VMI_CALL_WallclockUpdated 71
  35. /* Cached VMI timer operations */
  36. extern struct vmi_timer_ops {
  37. u64 (*get_cycle_frequency)(void);
  38. u64 (*get_cycle_counter)(int);
  39. u64 (*get_wallclock)(void);
  40. int (*wallclock_updated)(void);
  41. void (*set_alarm)(u32 flags, u64 expiry, u64 period);
  42. void (*cancel_alarm)(u32 flags);
  43. } vmi_timer_ops;
  44. /* Prototypes */
  45. extern void __init vmi_time_init(void);
  46. extern unsigned long vmi_get_wallclock(void);
  47. extern int vmi_set_wallclock(unsigned long now);
  48. extern unsigned long long vmi_sched_clock(void);
  49. extern unsigned long vmi_tsc_khz(void);
  50. #ifdef CONFIG_X86_LOCAL_APIC
  51. extern void __devinit vmi_time_bsp_init(void);
  52. extern void __devinit vmi_time_ap_init(void);
  53. #endif
  54. /*
  55. * When run under a hypervisor, a vcpu is always in one of three states:
  56. * running, halted, or ready. The vcpu is in the 'running' state if it
  57. * is executing. When the vcpu executes the halt interface, the vcpu
  58. * enters the 'halted' state and remains halted until there is some work
  59. * pending for the vcpu (e.g. an alarm expires, host I/O completes on
  60. * behalf of virtual I/O). At this point, the vcpu enters the 'ready'
  61. * state (waiting for the hypervisor to reschedule it). Finally, at any
  62. * time when the vcpu is not in the 'running' state nor the 'halted'
  63. * state, it is in the 'ready' state.
  64. *
  65. * Real time is advances while the vcpu is 'running', 'ready', or
  66. * 'halted'. Stolen time is the time in which the vcpu is in the
  67. * 'ready' state. Available time is the remaining time -- the vcpu is
  68. * either 'running' or 'halted'.
  69. *
  70. * All three views of time are accessible through the VMI cycle
  71. * counters.
  72. */
  73. /* The cycle counters. */
  74. #define VMI_CYCLES_REAL 0
  75. #define VMI_CYCLES_AVAILABLE 1
  76. #define VMI_CYCLES_STOLEN 2
  77. /* The alarm interface 'flags' bits */
  78. #define VMI_ALARM_COUNTERS 2
  79. #define VMI_ALARM_COUNTER_MASK 0x000000ff
  80. #define VMI_ALARM_WIRED_IRQ0 0x00000000
  81. #define VMI_ALARM_WIRED_LVTT 0x00010000
  82. #define VMI_ALARM_IS_ONESHOT 0x00000000
  83. #define VMI_ALARM_IS_PERIODIC 0x00000100
  84. #define CONFIG_VMI_ALARM_HZ 100
  85. #endif /* _ASM_X86_VMI_TIME_H */