1 /*
2  *  Copyright (C) 2001  MandrakeSoft S.A.
3  *
4  *    MandrakeSoft S.A.
5  *    43, rue d'Aboukir
6  *    75002 Paris - France
7  *    http://www.linux-mandrake.com/
8  *    http://www.mandrakesoft.com/
9  *
10  *  This library is free software; you can redistribute it and/or
11  *  modify it under the terms of the GNU Lesser General Public
12  *  License as published by the Free Software Foundation; either
13  *  version 2 of the License, or (at your option) any later version.
14  *
15  *  This library is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  *  Lesser General Public License for more details.
19  *
20  *  You should have received a copy of the GNU Lesser General Public
21  *  License along with this library; If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef __ASM_X86_HVM_VIOAPIC_H__
25 #define __ASM_X86_HVM_VIOAPIC_H__
26 
27 #include <xen/types.h>
28 #include <xen/smp.h>
29 #include <public/hvm/save.h>
30 
31 #define VIOAPIC_VERSION_ID 0x11 /* IOAPIC version */
32 
33 #define VIOAPIC_EDGE_TRIG  0
34 #define VIOAPIC_LEVEL_TRIG 1
35 
36 #define VIOAPIC_DEFAULT_BASE_ADDRESS  0xfec00000
37 #define VIOAPIC_MEM_LENGTH            0x100
38 
39 /* Direct registers. */
40 #define VIOAPIC_REG_SELECT  0x00
41 #define VIOAPIC_REG_WINDOW  0x10
42 #define VIOAPIC_REG_EOI     0x40
43 
44 /* Indirect registers. */
45 #define VIOAPIC_REG_APIC_ID 0x00 /* x86 IOAPIC only */
46 #define VIOAPIC_REG_VERSION 0x01
47 #define VIOAPIC_REG_ARB_ID  0x02 /* x86 IOAPIC only */
48 #define VIOAPIC_REG_RTE0    0x10
49 
50 struct hvm_vioapic {
51     struct domain *domain;
52     uint32_t nr_pins;
53     unsigned int base_gsi;
54     union {
55         XEN_HVM_VIOAPIC(,);
56         struct hvm_hw_vioapic domU;
57     };
58 };
59 
60 #define hvm_vioapic_size(cnt) offsetof(struct hvm_vioapic, redirtbl[cnt])
61 #define domain_vioapic(d, i) ((d)->arch.hvm_domain.vioapic[i])
62 #define vioapic_domain(v) ((v)->domain)
63 
64 int vioapic_init(struct domain *d);
65 void vioapic_deinit(struct domain *d);
66 void vioapic_reset(struct domain *d);
67 void vioapic_irq_positive_edge(struct domain *d, unsigned int irq);
68 void vioapic_update_EOI(struct domain *d, u8 vector);
69 
70 int vioapic_get_mask(const struct domain *d, unsigned int gsi);
71 int vioapic_get_vector(const struct domain *d, unsigned int gsi);
72 int vioapic_get_trigger_mode(const struct domain *d, unsigned int gsi);
73 
74 #endif /* __ASM_X86_HVM_VIOAPIC_H__ */
75