ia64/xen-unstable

annotate xen/include/asm-x86/hvm/vpt.h @ 19848:5839491bbf20

[IA64] replace MAX_VCPUS with d->max_vcpus where necessary.

don't use MAX_VCPUS, and use vcpu::max_vcpus.
The changeset of 2f9e1348aa98 introduced max_vcpus to allow more vcpus
per guest. This patch is ia64 counter part.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Mon Jun 29 11:26:05 2009 +0900 (2009-06-29)
parents 82bbce59b65d
children
rev   line source
kfraser@11969 1 /*
kfraser@11969 2 * vpt.h: Virtual Platform Timer definitions
kfraser@11969 3 *
kfraser@11969 4 * Copyright (c) 2004, Intel Corporation.
kfraser@11969 5 *
kfraser@11969 6 * This program is free software; you can redistribute it and/or modify it
kfraser@11969 7 * under the terms and conditions of the GNU General Public License,
kfraser@11969 8 * version 2, as published by the Free Software Foundation.
kfraser@11969 9 *
kfraser@11969 10 * This program is distributed in the hope it will be useful, but WITHOUT
kfraser@11969 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
kfraser@11969 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
kfraser@11969 13 * more details.
kfraser@11969 14 *
kfraser@11969 15 * You should have received a copy of the GNU General Public License along with
kfraser@11969 16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
kfraser@11969 17 * Place - Suite 330, Boston, MA 02111-1307 USA.
kfraser@11969 18 */
kfraser@11969 19
kfraser@11969 20 #ifndef __ASM_X86_HVM_VPT_H__
kfraser@11969 21 #define __ASM_X86_HVM_VPT_H__
kfraser@11969 22
kfraser@11969 23 #include <xen/config.h>
kfraser@11969 24 #include <xen/init.h>
kfraser@11969 25 #include <xen/lib.h>
kfraser@11969 26 #include <xen/time.h>
kfraser@11969 27 #include <xen/errno.h>
kfraser@11969 28 #include <xen/time.h>
kfraser@11969 29 #include <xen/timer.h>
kfraser@13132 30 #include <xen/list.h>
kfraser@11969 31 #include <asm/hvm/vpic.h>
kfraser@15393 32 #include <asm/hvm/irq.h>
Tim@13541 33 #include <public/hvm/save.h>
kfraser@13151 34
kfraser@13132 35 /*
kfraser@13132 36 * Abstract layer of periodic time, one short time.
kfraser@13132 37 */
kfraser@13132 38 typedef void time_cb(struct vcpu *v, void *opaque);
kfraser@13132 39
kfraser@13132 40 struct periodic_time {
kfraser@13132 41 struct list_head list;
keir@16598 42 bool_t on_list;
keir@16598 43 bool_t one_shot;
keir@16598 44 bool_t do_not_freeze;
keir@16603 45 bool_t irq_issued;
keir@17586 46 bool_t warned_timeout_too_short;
keir@16603 47 #define PTSRC_isa 1 /* ISA time source */
keir@16603 48 #define PTSRC_lapic 2 /* LAPIC time source */
keir@16603 49 u8 source; /* PTSRC_ */
kfraser@13133 50 u8 irq;
kfraser@13132 51 struct vcpu *vcpu; /* vcpu timer interrupt delivers to */
keir@16598 52 u32 pending_intr_nr; /* pending timer interrupts */
kfraser@13133 53 u64 period; /* frequency in ns */
kfraser@13132 54 u64 period_cycles; /* frequency in cpu cycles */
kfraser@13132 55 s_time_t scheduled; /* scheduled timer interrupt */
kfraser@13132 56 u64 last_plt_gtime; /* platform time when last IRQ is injected */
kfraser@13132 57 struct timer timer; /* ac_timer */
kfraser@13132 58 time_cb *cb;
Tim@13847 59 void *priv; /* point back to platform time source */
kfraser@13132 60 };
kfraser@13132 61
kfraser@13151 62
keir@18118 63 #define PIT_FREQ 1193182
kfraser@13151 64 #define PIT_BASE 0x40
kfraser@13151 65
Tim@13541 66 typedef struct PITState {
Tim@13541 67 /* Hardware state */
Tim@13541 68 struct hvm_hw_pit hw;
Tim@13847 69 /* Last time the counters read zero, for calcuating counter reads */
Tim@13847 70 int64_t count_load_time[3];
keir@16058 71 /* Channel 0 IRQ handling. */
keir@16058 72 struct periodic_time pt0;
keir@15367 73 spinlock_t lock;
kfraser@11969 74 } PITState;
kfraser@11969 75
keir@18702 76 struct hpet_registers {
keir@18702 77 /* Memory-mapped, software visible registers */
keir@18702 78 uint64_t capability; /* capabilities */
keir@18702 79 uint64_t config; /* configuration */
keir@18702 80 uint64_t isr; /* interrupt status reg */
keir@18702 81 uint64_t mc64; /* main counter */
keir@18702 82 struct { /* timers */
keir@18702 83 uint64_t config; /* configuration/cap */
keir@18702 84 uint64_t cmp; /* comparator */
keir@18702 85 uint64_t fsb; /* FSB route, not supported now */
keir@18702 86 } timers[HPET_TIMER_NUM];
keir@18702 87
keir@18702 88 /* Hidden register state */
keir@18702 89 uint64_t period[HPET_TIMER_NUM]; /* Last value written to comparator */
keir@18702 90 uint64_t comparator64[HPET_TIMER_NUM]; /* 64 bit running comparator */
keir@18702 91 };
keir@18702 92
keir@18702 93 typedef struct HPETState {
keir@18702 94 struct hpet_registers hpet;
keir@18702 95 struct vcpu *vcpu;
keir@18702 96 uint64_t stime_freq;
keir@18702 97 uint64_t hpet_to_ns_scale; /* hpet ticks to ns (multiplied by 2^10) */
keir@18702 98 uint64_t hpet_to_ns_limit; /* max hpet ticks convertable to ns */
keir@18702 99 uint64_t mc_offset;
keir@18702 100 struct periodic_time pt[HPET_TIMER_NUM];
keir@18702 101 spinlock_t lock;
keir@18702 102 } HPETState;
keir@18702 103
kfraser@11969 104 typedef struct RTCState {
Tim@13767 105 /* Hardware state */
Tim@13767 106 struct hvm_hw_rtc hw;
Tim@13767 107 /* RTC's idea of the current time */
kfraser@11969 108 struct tm current_tm;
kfraser@11969 109 /* second update */
kfraser@11969 110 int64_t next_second_time;
kfraser@11969 111 struct timer second_timer;
kfraser@11969 112 struct timer second_timer2;
kfraser@13132 113 struct periodic_time pt;
keir@15367 114 spinlock_t lock;
kfraser@11969 115 } RTCState;
kfraser@11969 116
Tim@13879 117 #define FREQUENCE_PMTIMER 3579545 /* Timer should run at 3.579545 MHz */
kfraser@11969 118 typedef struct PMTState {
Tim@13879 119 struct hvm_hw_pmtimer pm; /* 32bit timer value */
Tim@13879 120 struct vcpu *vcpu; /* Keeps sync with this vcpu's guest-time */
Tim@13879 121 uint64_t last_gtime; /* Last (guest) time we updated the timer */
Tim@13879 122 uint64_t scale; /* Multiplier to get from tsc to timer ticks */
Tim@14554 123 struct timer timer; /* To make sure we send SCIs */
keir@15367 124 spinlock_t lock;
kfraser@11969 125 } PMTState;
kfraser@11969 126
kfraser@13132 127 struct pl_time { /* platform time */
kfraser@13132 128 struct PITState vpit;
kfraser@13132 129 struct RTCState vrtc;
kfraser@13151 130 struct HPETState vhpet;
kfraser@13132 131 struct PMTState vpmt;
keir@17720 132 /* guest_time = Xen sys time + stime_offset */
keir@17720 133 int64_t stime_offset;
keir@17720 134 /* Ensures monotonicity in appropriate timer modes. */
keir@17720 135 uint64_t last_guest_time;
keir@17720 136 spinlock_t pl_time_lock;
kfraser@11969 137 };
kfraser@11969 138
keir@16245 139 void pt_save_timer(struct vcpu *v);
keir@16245 140 void pt_restore_timer(struct vcpu *v);
kfraser@13132 141 void pt_update_irq(struct vcpu *v);
keir@16028 142 void pt_intr_post(struct vcpu *v, struct hvm_intack intack);
kfraser@13132 143 void pt_reset(struct vcpu *v);
kfraser@15356 144 void pt_migrate(struct vcpu *v);
keir@16598 145
keir@16598 146 /* Is given periodic timer active? */
keir@16598 147 #define pt_active(pt) ((pt)->on_list)
keir@16598 148
keir@16598 149 /*
keir@16598 150 * Create/destroy a periodic (or one-shot!) timer.
keir@16603 151 * The given periodic timer structure must be initialised with zero bytes,
keir@16603 152 * except for the 'source' field which must be initialised with the
keir@16603 153 * correct PTSRC_ value. The initialised timer structure can then be passed
keir@18702 154 * to {create,destroy}_periodic_time() any number of times and in any order.
keir@16598 155 * Note that, for a given periodic timer, invocations of these functions MUST
keir@16598 156 * be serialised.
keir@16598 157 */
kfraser@15356 158 void create_periodic_time(
keir@18702 159 struct vcpu *v, struct periodic_time *pt, uint64_t delta,
keir@18702 160 uint64_t period, uint8_t irq, time_cb *cb, void *data);
kfraser@13132 161 void destroy_periodic_time(struct periodic_time *pt);
kfraser@13132 162
kfraser@13033 163 int pv_pit_handler(int port, int data, int write);
keir@17682 164 void pit_reset(struct domain *d);
keir@17682 165
kfraser@11969 166 void pit_init(struct vcpu *v, unsigned long cpu_khz);
kfraser@13151 167 void pit_stop_channel0_irq(PITState * pit);
kfraser@13132 168 void pit_deinit(struct domain *d);
keir@17951 169 void rtc_init(struct domain *d);
kfraser@13132 170 void rtc_migrate_timers(struct vcpu *v);
kfraser@11969 171 void rtc_deinit(struct domain *d);
keir@17682 172 void rtc_reset(struct domain *d);
keir@17951 173 void rtc_update_clock(struct domain *d);
keir@17682 174
Tim@14554 175 void pmtimer_init(struct vcpu *v);
Tim@14554 176 void pmtimer_deinit(struct domain *d);
keir@17682 177 void pmtimer_reset(struct domain *d);
kfraser@11969 178
kfraser@13151 179 void hpet_init(struct vcpu *v);
kfraser@13151 180 void hpet_deinit(struct domain *d);
keir@17682 181 void hpet_reset(struct domain *d);
kfraser@13151 182
kfraser@11969 183 #endif /* __ASM_X86_HVM_VPT_H__ */