Blame view

include/kvm/arm_arch_timer.h 2.65 KB
53e724067   Marc Zyngier   ARM: KVM: arch_ti...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  /*
   * Copyright (C) 2012 ARM Ltd.
   * Author: Marc Zyngier <marc.zyngier@arm.com>
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   */
  
  #ifndef __ASM_ARM_KVM_ARCH_TIMER_H
  #define __ASM_ARM_KVM_ARCH_TIMER_H
  
  #include <linux/clocksource.h>
  #include <linux/hrtimer.h>
  #include <linux/workqueue.h>
fbb4aeec5   Jintack Lim   KVM: arm/arm64: A...
25
  struct arch_timer_context {
53e724067   Marc Zyngier   ARM: KVM: arch_ti...
26
  	/* Registers: control register, timer value */
fbb4aeec5   Jintack Lim   KVM: arm/arm64: A...
27
28
29
30
31
32
33
34
  	u32				cnt_ctl;
  	u64				cnt_cval;
  
  	/* Timer IRQ */
  	struct kvm_irq_level		irq;
  
  	/* Active IRQ state caching */
  	bool				active_cleared_last;
90de943a4   Jintack Lim   KVM: arm/arm64: M...
35
36
37
  
  	/* Virtual offset */
  	u64			cntvoff;
fbb4aeec5   Jintack Lim   KVM: arm/arm64: A...
38
  };
53e724067   Marc Zyngier   ARM: KVM: arch_ti...
39

fbb4aeec5   Jintack Lim   KVM: arm/arm64: A...
40
41
  struct arch_timer_cpu {
  	struct arch_timer_context	vtimer;
009a5701b   Jintack Lim   KVM: arm/arm64: A...
42
  	struct arch_timer_context	ptimer;
53e724067   Marc Zyngier   ARM: KVM: arch_ti...
43
44
45
46
47
48
49
50
51
  
  	/* Background timer used when the guest is not running */
  	struct hrtimer			timer;
  
  	/* Work queued with the above timer expires */
  	struct work_struct		expired;
  
  	/* Background timer active */
  	bool				armed;
41a54482c   Christoffer Dall   KVM: arm/arm64: M...
52
53
  	/* Is the timer enabled */
  	bool			enabled;
53e724067   Marc Zyngier   ARM: KVM: arch_ti...
54
  };
53e724067   Marc Zyngier   ARM: KVM: arch_ti...
55
  int kvm_timer_hyp_init(void);
41a54482c   Christoffer Dall   KVM: arm/arm64: M...
56
  int kvm_timer_enable(struct kvm_vcpu *vcpu);
85e69ad7f   Christoffer Dall   KVM: arm/arm64: M...
57
  int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu);
53e724067   Marc Zyngier   ARM: KVM: arch_ti...
58
59
60
  void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu);
  void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu);
  void kvm_timer_sync_hwstate(struct kvm_vcpu *vcpu);
d9e139778   Alexander Graf   KVM: arm/arm64: S...
61
62
  bool kvm_timer_should_notify_user(struct kvm_vcpu *vcpu);
  void kvm_timer_update_run(struct kvm_vcpu *vcpu);
53e724067   Marc Zyngier   ARM: KVM: arch_ti...
63
  void kvm_timer_vcpu_terminate(struct kvm_vcpu *vcpu);
1df08ba0a   Alex BennĂ©e   arm64: KVM: allow...
64
65
66
  
  u64 kvm_arm_timer_get_reg(struct kvm_vcpu *, u64 regid);
  int kvm_arm_timer_set_reg(struct kvm_vcpu *, u64 regid, u64 value);
99a1db7a2   Christoffer Dall   KVM: arm/arm64: A...
67
68
69
  int kvm_arm_timer_set_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr);
  int kvm_arm_timer_get_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr);
  int kvm_arm_timer_has_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr);
9171fa2e0   Jintack Lim   KVM: arm/arm64: D...
70
  bool kvm_timer_should_fire(struct arch_timer_context *timer_ctx);
d35268da6   Christoffer Dall   arm/arm64: KVM: a...
71
72
  void kvm_timer_schedule(struct kvm_vcpu *vcpu);
  void kvm_timer_unschedule(struct kvm_vcpu *vcpu);
1a7484788   Christoffer Dall   arm/arm64: KVM: F...
73

7b6b46311   Jintack Lim   KVM: arm/arm64: E...
74
  u64 kvm_phys_timer_read(void);
9b4a30044   Marc Zyngier   KVM: arm/arm64: t...
75
  void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu);
488f94d72   Jintack Lim   KVM: arm64: Acces...
76
  void kvm_timer_init_vhe(void);
fbb4aeec5   Jintack Lim   KVM: arm/arm64: A...
77
78
  
  #define vcpu_vtimer(v)	(&(v)->arch.timer_cpu.vtimer)
009a5701b   Jintack Lim   KVM: arm/arm64: A...
79
  #define vcpu_ptimer(v)	(&(v)->arch.timer_cpu.ptimer)
53e724067   Marc Zyngier   ARM: KVM: arch_ti...
80
  #endif