source: trunk/packages/xen-common/xen-common/xen/include/asm-x86/hvm/vlapic.h @ 34

Last change on this file since 34 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

File size: 3.1 KB
Line 
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 */
20
21#ifndef __ASM_X86_HVM_VLAPIC_H__
22#define __ASM_X86_HVM_VLAPIC_H__
23
24#include <asm/msr.h>
25#include <public/hvm/ioreq.h>
26#include <asm/hvm/vpt.h>
27
28#define MAX_VECTOR      256
29
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)
34
35#define VLAPIC_ID(vlapic)   \
36    (GET_APIC_ID(vlapic_get_reg(vlapic, APIC_ID)))
37
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))
51
52struct vlapic {
53    struct hvm_hw_lapic      hw;
54    struct hvm_hw_lapic_regs *regs;
55    struct periodic_time     pt;
56    s_time_t                 timer_last_update;
57    struct page_info         *regs_page;
58};
59
60static inline uint32_t vlapic_get_reg(struct vlapic *vlapic, uint32_t reg)
61{
62    return *((uint32_t *)(&vlapic->regs->data[reg]));
63}
64
65static inline void vlapic_set_reg(
66    struct vlapic *vlapic, uint32_t reg, uint32_t val)
67{
68    *((uint32_t *)(&vlapic->regs->data[reg])) = val;
69}
70
71int vlapic_set_irq(struct vlapic *vlapic, uint8_t vec, uint8_t trig);
72
73int vlapic_find_highest_irr(struct vlapic *vlapic);
74
75int vlapic_has_interrupt(struct vcpu *v);
76int cpu_get_apic_interrupt(struct vcpu *v, int *mode);
77
78int  vlapic_init(struct vcpu *v);
79void vlapic_destroy(struct vcpu *v);
80
81void vlapic_reset(struct vlapic *vlapic);
82
83void vlapic_msr_set(struct vlapic *vlapic, uint64_t value);
84
85int vlapic_accept_pic_intr(struct vcpu *v);
86
87struct vlapic *apic_round_robin(
88    struct domain *d, uint8_t vector, uint32_t bitmap);
89
90int vlapic_match_logical_addr(struct vlapic *vlapic, uint8_t mda);
91
92int is_lvtt(struct vcpu *v, int vector);
93int is_lvtt_enabled(struct vcpu *v);
94
95#endif /* __ASM_X86_HVM_VLAPIC_H__ */
Note: See TracBrowser for help on using the repository browser.