Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel'
[palacios.git] / kitten / include / arch-x86_64 / io_apic.h
1 #ifndef __ASM_IO_APIC_H
2 #define __ASM_IO_APIC_H
3
4 #include <lwk/spinlock.h>
5 #include <arch/types.h>
6 #include <arch/mpspec.h>
7
8 /*
9  * Intel IO-APIC support for SMP and UP systems.
10  *
11  * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
12  */
13
14 static inline int use_pci_vector(void)  {return 1;}
15 static inline void disable_edge_ioapic_vector(unsigned int vector) { }
16 static inline void mask_and_ack_level_ioapic_vector(unsigned int vector) { }
17 static inline void end_edge_ioapic_vector (unsigned int vector) { }
18 #define startup_level_ioapic    startup_level_ioapic_vector
19 #define shutdown_level_ioapic   mask_IO_APIC_vector
20 #define enable_level_ioapic     unmask_IO_APIC_vector
21 #define disable_level_ioapic    mask_IO_APIC_vector
22 #define mask_and_ack_level_ioapic mask_and_ack_level_ioapic_vector
23 #define end_level_ioapic        end_level_ioapic_vector
24 #define set_ioapic_affinity     set_ioapic_affinity_vector
25
26 #define startup_edge_ioapic     startup_edge_ioapic_vector
27 #define shutdown_edge_ioapic    disable_edge_ioapic_vector
28 #define enable_edge_ioapic      unmask_IO_APIC_vector
29 #define disable_edge_ioapic     disable_edge_ioapic_vector
30 #define ack_edge_ioapic         ack_edge_ioapic_vector
31 #define end_edge_ioapic         end_edge_ioapic_vector
32
33 #define APIC_MISMATCH_DEBUG
34
35 #define IO_APIC_BASE(idx) \
36                 ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \
37                 + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
38
39 /*
40  * The structure of the IO-APIC:
41  */
42 union IO_APIC_reg_00 {
43         u32     raw;
44         struct {
45                 u32     __reserved_2    : 14,
46                         LTS             :  1,
47                         delivery_type   :  1,
48                         __reserved_1    :  8,
49                         ID              :  8;
50         } __attribute__ ((packed)) bits;
51 };
52
53 union IO_APIC_reg_01 {
54         u32     raw;
55         struct {
56                 u32     version         :  8,
57                 __reserved_2    :  7,
58                 PRQ             :  1,
59                 entries         :  8,
60                 __reserved_1    :  8;
61         } __attribute__ ((packed)) bits;
62 };
63
64 union IO_APIC_reg_02 {
65         u32     raw;
66         struct {
67                 u32     __reserved_2    : 24,
68                 arbitration     :  4,
69                 __reserved_1    :  4;
70         } __attribute__ ((packed)) bits;
71 };
72
73 union IO_APIC_reg_03 {
74         u32     raw;
75         struct {
76                 u32     boot_DT         :  1,
77                         __reserved_1    : 31;
78         } __attribute__ ((packed)) bits;
79 };
80
81 /*
82  * # of IO-APICs and # of IRQ routing registers
83  */
84 extern int nr_ioapics;
85 extern int nr_ioapic_registers[MAX_IO_APICS];
86
87 enum ioapic_trigger_modes {
88         ioapic_edge_sensitive  = 0,
89         ioapic_level_sensitive = 1
90 };
91
92 enum ioapic_pin_polarities {
93         ioapic_active_high = 0,
94         ioapic_active_low  = 1
95 };
96
97 enum ioapic_destination_modes {
98         ioapic_physical_dest = 0,
99         ioapic_logical_dest  = 1
100 };
101
102 enum ioapic_delivery_modes {
103         ioapic_fixed           = 0,
104         ioapic_lowest_priority = 1,
105         ioapic_SMI             = 2,
106         ioapic_NMI             = 4,
107         ioapic_INIT            = 5,
108         ioapic_ExtINT          = 7
109 };
110
111 struct IO_APIC_route_entry {
112         __u32   vector          :  8,
113                 delivery_mode   :  3,   /* 000: FIXED
114                                          * 001: lowest prio
115                                          * 111: ExtINT
116                                          */
117                 dest_mode       :  1,   /* 0: physical, 1: logical */
118                 delivery_status :  1,
119                 polarity        :  1,
120                 irr             :  1,
121                 trigger         :  1,   /* 0: edge, 1: level */
122                 mask            :  1,   /* 0: enabled, 1: disabled */
123                 __reserved_2    : 15;
124
125         __u32   __reserved_3    : 24,
126                 dest            :  8;
127 } __attribute__ ((packed));
128
129 /*
130  * MP-BIOS irq configuration table structures:
131  */
132
133 /* I/O APIC entries */
134 extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
135
136 /* # of MP IRQ source entries */
137 extern int mp_irq_entries;
138
139 /* MP IRQ source entries */
140 extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
141
142 /* non-0 if default (table-less) MP configuration */
143 extern int mpc_default_type;
144
145 static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
146 {
147         *IO_APIC_BASE(apic) = reg;
148         return *(IO_APIC_BASE(apic)+4);
149 }
150
151 static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
152 {
153         *IO_APIC_BASE(apic) = reg;
154         *(IO_APIC_BASE(apic)+4) = value;
155 }
156
157 /*
158  * Re-write a value: to be used for read-modify-write
159  * cycles where the read already set up the index register.
160  */
161 static inline void io_apic_modify(unsigned int apic, unsigned int value)
162 {
163         *(IO_APIC_BASE(apic)+4) = value;
164 }
165
166 /*
167  * Synchronize the IO-APIC and the CPU by doing
168  * a dummy read from the IO-APIC
169  */
170 static inline void io_apic_sync(unsigned int apic)
171 {
172         (void) *(IO_APIC_BASE(apic)+4);
173 }
174
175 /* 1 if "noapic" boot option passed */
176 extern int skip_ioapic_setup;
177
178 /*
179  * If we use the IO-APIC for IRQ routing, disable automatic
180  * assignment of PCI IRQ's.
181  */
182 #define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
183
184 #ifdef CONFIG_ACPI
185 extern int io_apic_get_version (int ioapic);
186 extern int io_apic_get_redir_entries (int ioapic);
187 extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int, int);
188 extern int timer_uses_ioapic_pin_0;
189 #endif
190
191 extern int sis_apic_bug; /* dummy */ 
192
193 extern int assign_irq_vector(int irq);
194
195 void enable_NMI_through_LVT0 (void * dummy);
196
197 extern spinlock_t i8259A_lock;
198
199 extern unsigned int ioapic_num;
200 extern unsigned int ioapic_id[MAX_IO_APICS];
201 extern unsigned long ioapic_phys_addr[MAX_IO_APICS];
202
203 extern void __init ioapic_map(void);
204 extern void __init ioapic_init(void);
205 extern void ioapic_dump(void);
206
207
208 #endif