ia64/xen-unstable

view xen/include/asm-x86/hvm/vioapic.h @ 11075:f393ced88d14

[HVM] Fix some IOAPIC and LAPIC device model bugs.

Fix some boundary checking errors.
Fix the confusion using variables 'level' and 'trig_mode'.
Also fix some other misc mistakes and do some cleanup.

Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
author kfraser@localhost.localdomain
date Thu Aug 10 10:47:37 2006 +0100 (2006-08-10)
parents f1b361b05bf3
children c620b16d4063
line source
1 /*
2 *
3 * Copyright (C) 2001 MandrakeSoft S.A.
4 *
5 * MandrakeSoft S.A.
6 * 43, rue d'Aboukir
7 * 75002 Paris - France
8 * http://www.linux-mandrake.com/
9 * http://www.mandrakesoft.com/
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
26 #ifndef __ASM_X86_HVM_IOAPIC_H__
27 #define __ASM_X86_HVM_IOAPIC_H__
29 #include <xen/config.h>
30 #include <xen/types.h>
31 #include <xen/smp.h>
33 #ifndef __ia64__
34 #define IOAPIC_VERSION_ID 0x11
35 #else
36 #define IOAPIC_VERSION_ID 0x21
37 #endif
39 #define IOAPIC_NUM_PINS 24
40 #define MAX_LAPIC_NUM 32
42 #define IOAPIC_LEVEL_TRIGGER 1
44 #define IOAPIC_DEFAULT_BASE_ADDRESS 0xfec00000
45 #define IOAPIC_MEM_LENGTH 0x100
47 #define IOAPIC_ENABLE_MASK 0x0
48 #define IOAPIC_ENABLE_FLAG (1 << IOAPIC_ENABLE_MASK)
49 #define IOAPICEnabled(s) (s->flags & IOAPIC_ENABLE_FLAG)
51 #define IOAPIC_REG_SELECT 0x0
52 #define IOAPIC_REG_WINDOW 0x10
54 #ifdef __ia64__
55 #define IOAPIC_REG_ASSERTION 0x20
56 #define IOAPIC_REG_EOI 0x40
57 #endif
59 #ifndef __ia64__
60 #define IOAPIC_REG_APIC_ID 0x0
61 #define IOAPIC_REG_ARB_ID 0x2
62 #endif
64 #define IOAPIC_REG_VERSION 0x1
66 typedef union RedirStatus
67 {
68 uint64_t value;
69 struct {
70 uint8_t vector;
71 uint8_t deliver_mode:3;
72 uint8_t destmode:1;
73 uint8_t delivestatus:1;
74 uint8_t polarity:1;
75 uint8_t remoteirr:1;
76 uint8_t trigmod:1;
77 uint8_t mask:1; /* interrupt mask*/
78 uint8_t reserve:7;
79 #ifndef __ia64__
80 uint8_t reserved[4];
81 uint8_t dest_id;
82 #else
83 uint8_t reserved[3];
84 uint16_t dest_id;
85 #endif
86 } RedirForm;
87 } RedirStatus;
89 typedef struct hvm_vioapic {
90 uint32_t irr;
91 uint32_t isr; /* This is used for level trigger */
92 uint32_t imr;
93 uint32_t ioregsel;
94 uint32_t flags;
95 uint32_t lapic_count;
96 uint32_t id;
97 uint32_t arb_id;
98 unsigned long base_address;
99 RedirStatus redirtbl[IOAPIC_NUM_PINS];
100 struct vlapic *lapic_info[MAX_LAPIC_NUM];
101 struct domain *domain;
102 } hvm_vioapic_t;
104 hvm_vioapic_t *hvm_vioapic_init(struct domain *d);
106 void hvm_vioapic_do_irqs_clear(struct domain *d, uint16_t irqs);
107 void hvm_vioapic_do_irqs(struct domain *d, uint16_t irqs);
108 void hvm_vioapic_set_irq(struct domain *d, int irq, int level);
110 int hvm_vioapic_add_lapic(struct vlapic *vlapic, struct vcpu *v);
112 void ioapic_update_EOI(struct domain *d, int vector);
114 #ifdef HVM_DOMAIN_SAVE_RESTORE
115 void ioapic_save(QEMUFile* f, void* opaque);
116 int ioapic_load(QEMUFile* f, void* opaque, int version_id);
117 #endif
119 #endif /* __ASM_X86_HVM_IOAPIC_H__ */