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 | |
---|
52 | struct 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 | |
---|
60 | static inline uint32_t vlapic_get_reg(struct vlapic *vlapic, uint32_t reg) |
---|
61 | { |
---|
62 | return *((uint32_t *)(&vlapic->regs->data[reg])); |
---|
63 | } |
---|
64 | |
---|
65 | static 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 | |
---|
71 | int vlapic_set_irq(struct vlapic *vlapic, uint8_t vec, uint8_t trig); |
---|
72 | |
---|
73 | int vlapic_find_highest_irr(struct vlapic *vlapic); |
---|
74 | |
---|
75 | int vlapic_has_interrupt(struct vcpu *v); |
---|
76 | int cpu_get_apic_interrupt(struct vcpu *v, int *mode); |
---|
77 | |
---|
78 | int vlapic_init(struct vcpu *v); |
---|
79 | void vlapic_destroy(struct vcpu *v); |
---|
80 | |
---|
81 | void vlapic_reset(struct vlapic *vlapic); |
---|
82 | |
---|
83 | void vlapic_msr_set(struct vlapic *vlapic, uint64_t value); |
---|
84 | |
---|
85 | int vlapic_accept_pic_intr(struct vcpu *v); |
---|
86 | |
---|
87 | struct vlapic *apic_round_robin( |
---|
88 | struct domain *d, uint8_t vector, uint32_t bitmap); |
---|
89 | |
---|
90 | int vlapic_match_logical_addr(struct vlapic *vlapic, uint8_t mda); |
---|
91 | |
---|
92 | int is_lvtt(struct vcpu *v, int vector); |
---|
93 | int is_lvtt_enabled(struct vcpu *v); |
---|
94 | |
---|
95 | #endif /* __ASM_X86_HVM_VLAPIC_H__ */ |
---|