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 <public/hvm/save.h>
29 
30 #define VIOAPIC_VERSION_ID 0x11 /* IOAPIC version */
31 
32 #define VIOAPIC_EDGE_TRIG  0
33 #define VIOAPIC_LEVEL_TRIG 1
34 
35 #define VIOAPIC_DEFAULT_BASE_ADDRESS  0xfec00000
36 #define VIOAPIC_MEM_LENGTH            0x100
37 
38 /* Direct registers. */
39 #define VIOAPIC_REG_SELECT  0x00
40 #define VIOAPIC_REG_WINDOW  0x10
41 #define VIOAPIC_REG_EOI     0x40
42 
43 /* Indirect registers. */
44 #define VIOAPIC_REG_APIC_ID 0x00 /* x86 IOAPIC only */
45 #define VIOAPIC_REG_VERSION 0x01
46 #define VIOAPIC_REG_ARB_ID  0x02 /* x86 IOAPIC only */
47 #define VIOAPIC_REG_RTE0    0x10
48 
49 struct hvm_vioapic {
50     struct domain *domain;
51     uint32_t nr_pins;
52     unsigned int base_gsi;
53     union {
54         XEN_HVM_VIOAPIC(,);
55         struct hvm_hw_vioapic domU;
56     };
57 };
58 
59 #define hvm_vioapic_size(cnt) offsetof(struct hvm_vioapic, redirtbl[cnt])
60 #define domain_vioapic(d, i) ((d)->arch.hvm.vioapic[i])
61 #define vioapic_domain(v) ((v)->domain)
62 
63 int vioapic_init(struct domain *d);
64 void vioapic_deinit(struct domain *d);
65 void vioapic_reset(struct domain *d);
66 void vioapic_irq_positive_edge(struct domain *d, unsigned int irq);
67 void vioapic_update_EOI(struct domain *d, u8 vector);
68 
69 int vioapic_get_mask(const struct domain *d, unsigned int gsi);
70 int vioapic_get_vector(const struct domain *d, unsigned int gsi);
71 int vioapic_get_trigger_mode(const struct domain *d, unsigned int gsi);
72 
73 #endif /* __ASM_X86_HVM_VIOAPIC_H__ */
74