direct-io.hg

view xen/include/asm-x86/hvm/vpit.h @ 9672:5765497cf75e

Sync PIT device model with latest qemu and move it to hypervisor.
Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Apr 19 18:38:14 2006 +0100 (2006-04-19)
parents 2a7a46dd3bd6
children da7fe04d8e80
line source
1 /*
2 * vpit.h: Virtual PIT 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_VPIT_H__
21 #define __ASM_X86_HVM_VPIT_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/timer.h>
29 #include <asm/hvm/vpic.h>
31 #define PIT_FREQ 1193181
33 #define PIT_BASE 0x40
34 #define HVM_PIT_ACCEL_MODE 2
36 typedef struct PITChannelState {
37 int count; /* can be 65536 */
38 u16 latched_count;
39 u8 count_latched;
40 u8 status_latched;
41 u8 status;
42 u8 read_state;
43 u8 write_state;
44 u8 write_latch;
45 u8 rw_mode;
46 u8 mode;
47 u8 bcd; /* not supported */
48 u8 gate; /* timer start */
49 s64 count_load_time;
50 /* irq handling */
51 s64 next_transition_time;
52 int irq;
53 struct hvm_time_info *hvm_time;
54 u32 period; /* period(ns) based on count */
55 } PITChannelState;
57 struct hvm_time_info {
58 /* extra info for the mode 2 channel */
59 struct timer pit_timer;
60 struct vcpu *vcpu; /* which vcpu the ac_timer bound to */
61 u64 period_cycles; /* pit frequency in cpu cycles */
62 s_time_t count_advance; /* accumulated count advance since last fire */
63 s_time_t count_point; /* last point accumulating count advance */
64 unsigned int pending_intr_nr; /* the couner for pending timer interrupts */
65 int first_injected; /* flag to prevent shadow window */
66 s64 cache_tsc_offset; /* cache of VMCS TSC_OFFSET offset */
67 u64 last_pit_gtime; /* guest time when last pit is injected */
68 };
70 typedef struct hvm_virpit {
71 PITChannelState channels[3];
72 struct hvm_time_info time_info;
73 int speaker_data_on;
74 int dummy_refresh_clock;
75 }hvm_virpit;
78 static __inline__ s_time_t get_pit_scheduled(
79 struct vcpu *v,
80 struct hvm_virpit *vpit)
81 {
82 struct PITChannelState *s = &(vpit->channels[0]);
83 if ( is_irq_enabled(v, 0) ) {
84 return s->next_transition_time;
85 }
86 else
87 return -1;
88 }
90 /* to hook the ioreq packet to get the PIT initialization info */
91 extern void pit_init(struct hvm_virpit *pit, struct vcpu *v);
92 extern void pickup_deactive_ticks(struct hvm_virpit *vpit);
94 #endif /* __ASM_X86_HVM_VPIT_H__ */