direct-io.hg

view xen/include/asm-x86/hvm/vpt.h @ 15388:50358c4b37f4

hvm: Support injection of virtual NMIs and clean up ExtInt handling in general.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Jun 20 11:50:16 2007 +0100 (2007-06-20)
parents 8ad38aaaeb89
children
line source
1 /*
2 * vpt.h: Virtual Platform Timer definitions
3 *
4 * Copyright (c) 2004, Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place - Suite 330, Boston, MA 02111-1307 USA.
18 */
20 #ifndef __ASM_X86_HVM_VPT_H__
21 #define __ASM_X86_HVM_VPT_H__
23 #include <xen/config.h>
24 #include <xen/init.h>
25 #include <xen/lib.h>
26 #include <xen/time.h>
27 #include <xen/errno.h>
28 #include <xen/time.h>
29 #include <xen/timer.h>
30 #include <xen/list.h>
31 #include <asm/hvm/vpic.h>
32 #include <asm/hvm/irq.h>
33 #include <public/hvm/save.h>
35 struct HPETState;
36 struct HPET_timer_fn_info {
37 struct HPETState *hs;
38 unsigned int tn;
39 };
41 typedef struct HPETState {
42 struct hvm_hw_hpet hpet;
43 struct vcpu *vcpu;
44 uint64_t tsc_freq;
45 uint64_t mc_offset;
46 struct timer timers[HPET_TIMER_NUM];
47 struct HPET_timer_fn_info timer_fn_info[HPET_TIMER_NUM];
48 spinlock_t lock;
49 } HPETState;
52 /*
53 * Abstract layer of periodic time, one short time.
54 */
55 typedef void time_cb(struct vcpu *v, void *opaque);
57 struct periodic_time {
58 struct list_head list;
59 char enabled;
60 char one_shot; /* one shot time */
61 u8 irq;
62 struct vcpu *vcpu; /* vcpu timer interrupt delivers to */
63 u32 pending_intr_nr; /* the couner for pending timer interrupts */
64 u64 period; /* frequency in ns */
65 u64 period_cycles; /* frequency in cpu cycles */
66 s_time_t scheduled; /* scheduled timer interrupt */
67 u64 last_plt_gtime; /* platform time when last IRQ is injected */
68 struct timer timer; /* ac_timer */
69 time_cb *cb;
70 void *priv; /* point back to platform time source */
71 };
74 #define PIT_FREQ 1193181
75 #define PIT_BASE 0x40
77 typedef struct PITState {
78 /* Hardware state */
79 struct hvm_hw_pit hw;
80 /* Last time the counters read zero, for calcuating counter reads */
81 int64_t count_load_time[3];
82 /* irq handling */
83 struct periodic_time pt[3];
84 spinlock_t lock;
85 } PITState;
87 typedef struct RTCState {
88 /* Hardware state */
89 struct hvm_hw_rtc hw;
90 /* RTC's idea of the current time */
91 struct tm current_tm;
92 /* second update */
93 int64_t next_second_time;
94 struct timer second_timer;
95 struct timer second_timer2;
96 struct periodic_time pt;
97 int32_t time_offset_seconds;
98 spinlock_t lock;
99 } RTCState;
101 #define FREQUENCE_PMTIMER 3579545 /* Timer should run at 3.579545 MHz */
102 typedef struct PMTState {
103 struct hvm_hw_pmtimer pm; /* 32bit timer value */
104 struct vcpu *vcpu; /* Keeps sync with this vcpu's guest-time */
105 uint64_t last_gtime; /* Last (guest) time we updated the timer */
106 uint64_t scale; /* Multiplier to get from tsc to timer ticks */
107 struct timer timer; /* To make sure we send SCIs */
108 spinlock_t lock;
109 } PMTState;
111 struct pl_time { /* platform time */
112 struct PITState vpit;
113 struct RTCState vrtc;
114 struct HPETState vhpet;
115 struct PMTState vpmt;
116 };
118 #define ticks_per_sec(v) (v->domain->arch.hvm_domain.tsc_frequency)
120 void pt_freeze_time(struct vcpu *v);
121 void pt_thaw_time(struct vcpu *v);
122 void pt_update_irq(struct vcpu *v);
123 void pt_intr_post(struct vcpu *v, int vector, enum hvm_intack src);
124 void pt_reset(struct vcpu *v);
125 void pt_migrate(struct vcpu *v);
126 void create_periodic_time(
127 struct vcpu *v, struct periodic_time *pt, uint64_t period,
128 uint8_t irq, char one_shot, time_cb *cb, void *data);
129 void destroy_periodic_time(struct periodic_time *pt);
131 int pv_pit_handler(int port, int data, int write);
132 void pit_init(struct vcpu *v, unsigned long cpu_khz);
133 void pit_stop_channel0_irq(PITState * pit);
134 void pit_deinit(struct domain *d);
135 void rtc_init(struct vcpu *v, int base);
136 void rtc_migrate_timers(struct vcpu *v);
137 void rtc_deinit(struct domain *d);
138 int is_rtc_periodic_irq(void *opaque);
139 void pmtimer_init(struct vcpu *v);
140 void pmtimer_deinit(struct domain *d);
142 void hpet_migrate_timers(struct vcpu *v);
143 void hpet_init(struct vcpu *v);
144 void hpet_deinit(struct domain *d);
146 #endif /* __ASM_X86_HVM_VPT_H__ */