ia64/xen-unstable

view xen/include/asm-x86/hvm/vlapic.h @ 16603:4553bc1087d9

hvm: Reduce vpt.c dependencies on external timer details.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 12 15:41:20 2007 +0000 (2007-12-12)
parents 9eff4c97053b
children 3ee37b6279b7
line source
1 /*
2 * hvm_vlapic.h: virtualize LAPIC definitions.
3 *
4 * Copyright (c) 2004, Intel Corporation.
5 * Copyright (c) 2006 Keir Fraser, XenSource Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18 * Place - Suite 330, Boston, MA 02111-1307 USA.
19 */
21 #ifndef __ASM_X86_HVM_VLAPIC_H__
22 #define __ASM_X86_HVM_VLAPIC_H__
24 #include <asm/msr.h>
25 #include <public/hvm/ioreq.h>
26 #include <asm/hvm/vpt.h>
28 #define MAX_VECTOR 256
30 #define vcpu_vlapic(vcpu) (&(vcpu)->arch.hvm_vcpu.vlapic)
31 #define vlapic_vcpu(vpic) (container_of((vpic), struct vcpu, \
32 arch.hvm_vcpu.vlapic))
33 #define vlapic_domain(vpic) (vlapic_vcpu(vlapic)->domain)
35 #define VLAPIC_ID(vlapic) \
36 (GET_APIC_ID(vlapic_get_reg((vlapic), APIC_ID)))
38 /*
39 * APIC can be disabled in two ways:
40 * 1. 'Hardware disable': via IA32_APIC_BASE_MSR[11]
41 * CPU should behave as if it does not have an APIC.
42 * 2. 'Software disable': via APIC_SPIV[8].
43 * APIC is visible but does not respond to interrupt messages.
44 */
45 #define VLAPIC_HW_DISABLED 0x1
46 #define VLAPIC_SW_DISABLED 0x2
47 #define vlapic_sw_disabled(vlapic) ((vlapic)->hw.disabled & VLAPIC_SW_DISABLED)
48 #define vlapic_hw_disabled(vlapic) ((vlapic)->hw.disabled & VLAPIC_HW_DISABLED)
49 #define vlapic_disabled(vlapic) ((vlapic)->hw.disabled)
50 #define vlapic_enabled(vlapic) (!vlapic_disabled(vlapic))
52 #define vlapic_base_address(vlapic) \
53 ((vlapic)->hw.apic_base_msr & MSR_IA32_APICBASE_BASE)
55 struct vlapic {
56 struct hvm_hw_lapic hw;
57 struct hvm_hw_lapic_regs *regs;
58 struct periodic_time pt;
59 s_time_t timer_last_update;
60 struct page_info *regs_page;
61 };
63 static inline uint32_t vlapic_get_reg(struct vlapic *vlapic, uint32_t reg)
64 {
65 return *((uint32_t *)(&vlapic->regs->data[reg]));
66 }
68 static inline void vlapic_set_reg(
69 struct vlapic *vlapic, uint32_t reg, uint32_t val)
70 {
71 *((uint32_t *)(&vlapic->regs->data[reg])) = val;
72 }
74 int vlapic_set_irq(struct vlapic *vlapic, uint8_t vec, uint8_t trig);
76 int vlapic_find_highest_irr(struct vlapic *vlapic);
78 int vlapic_has_pending_irq(struct vcpu *v);
79 int vlapic_ack_pending_irq(struct vcpu *v, int vector);
81 int vlapic_init(struct vcpu *v);
82 void vlapic_destroy(struct vcpu *v);
84 void vlapic_reset(struct vlapic *vlapic);
86 void vlapic_msr_set(struct vlapic *vlapic, uint64_t value);
88 int vlapic_accept_pic_intr(struct vcpu *v);
90 struct vlapic *apic_round_robin(
91 struct domain *d, uint8_t vector, uint32_t bitmap);
93 int vlapic_match_logical_addr(struct vlapic *vlapic, uint8_t mda);
95 #endif /* __ASM_X86_HVM_VLAPIC_H__ */