1 #ifndef __ASM_IO_APIC_H
2 #define __ASM_IO_APIC_H
5 #include <asm/mpspec.h>
8 * Intel IO-APIC support for SMP and UP systems.
10 * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
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
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
33 static inline int use_pci_vector(void) {return 0;}
34 static inline void disable_edge_ioapic_irq(unsigned int irq
) { }
35 static inline void mask_and_ack_level_ioapic_irq(unsigned int irq
) { }
36 static inline void end_edge_ioapic_irq (unsigned int irq
) { }
37 #define startup_level_ioapic startup_level_ioapic_irq
38 #define shutdown_level_ioapic mask_IO_APIC_irq
39 #define enable_level_ioapic unmask_IO_APIC_irq
40 #define disable_level_ioapic mask_IO_APIC_irq
41 #define mask_and_ack_level_ioapic mask_and_ack_level_ioapic_irq
42 #define end_level_ioapic end_level_ioapic_irq
43 #define set_ioapic_affinity set_ioapic_affinity_irq
45 #define startup_edge_ioapic startup_edge_ioapic_irq
46 #define shutdown_edge_ioapic disable_edge_ioapic_irq
47 #define enable_edge_ioapic unmask_IO_APIC_irq
48 #define disable_edge_ioapic disable_edge_ioapic_irq
49 #define ack_edge_ioapic ack_edge_ioapic_irq
50 #define end_edge_ioapic end_edge_ioapic_irq
53 #define APIC_MISMATCH_DEBUG
55 #define IO_APIC_BASE(idx) \
56 ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \
57 + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
60 * The structure of the IO-APIC:
62 union IO_APIC_reg_00
{
65 u32 __reserved_2
: 14,
70 } __attribute__ ((packed
)) bits
;
73 union IO_APIC_reg_01
{
81 } __attribute__ ((packed
)) bits
;
84 union IO_APIC_reg_02
{
87 u32 __reserved_2
: 24,
90 } __attribute__ ((packed
)) bits
;
93 union IO_APIC_reg_03
{
98 } __attribute__ ((packed
)) bits
;
102 * # of IO-APICs and # of IRQ routing registers
104 extern int nr_ioapics
;
105 extern int nr_ioapic_registers
[MAX_IO_APICS
];
107 enum ioapic_irq_destination_types
{
111 dest__reserved_1
= 3,
114 dest__reserved_2
= 6,
118 struct IO_APIC_route_entry
{
120 delivery_mode
: 3, /* 000: FIXED
124 dest_mode
: 1, /* 0: physical, 1: logical */
128 trigger
: 1, /* 0: edge, 1: level */
129 mask
: 1, /* 0: enabled, 1: disabled */
132 union { struct { __u32
144 } __attribute__ ((packed
));
147 * MP-BIOS irq configuration table structures:
150 /* I/O APIC entries */
151 extern struct mpc_config_ioapic mp_ioapics
[MAX_IO_APICS
];
153 /* # of MP IRQ source entries */
154 extern int mp_irq_entries
;
156 /* MP IRQ source entries */
157 extern struct mpc_config_intsrc mp_irqs
[MAX_IRQ_SOURCES
];
159 /* non-0 if default (table-less) MP configuration */
160 extern int mpc_default_type
;
162 static inline unsigned int io_apic_read(unsigned int apic
, unsigned int reg
)
164 *IO_APIC_BASE(apic
) = reg
;
165 return *(IO_APIC_BASE(apic
)+4);
168 static inline void io_apic_write(unsigned int apic
, unsigned int reg
, unsigned int value
)
170 *IO_APIC_BASE(apic
) = reg
;
171 *(IO_APIC_BASE(apic
)+4) = value
;
175 * Re-write a value: to be used for read-modify-write
176 * cycles where the read already set up the index register.
178 static inline void io_apic_modify(unsigned int apic
, unsigned int value
)
180 *(IO_APIC_BASE(apic
)+4) = value
;
184 * Synchronize the IO-APIC and the CPU by doing
185 * a dummy read from the IO-APIC
187 static inline void io_apic_sync(unsigned int apic
)
189 (void) *(IO_APIC_BASE(apic
)+4);
192 /* 1 if "noapic" boot option passed */
193 extern int skip_ioapic_setup
;
196 * If we use the IO-APIC for IRQ routing, disable automatic
197 * assignment of PCI IRQ's.
199 #define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
202 extern int io_apic_get_version (int ioapic
);
203 extern int io_apic_get_redir_entries (int ioapic
);
204 extern int io_apic_set_pci_routing (int ioapic
, int pin
, int irq
, int, int);
205 extern int timer_uses_ioapic_pin_0
;
208 extern int sis_apic_bug
; /* dummy */
210 extern int assign_irq_vector(int irq
);
212 void enable_NMI_through_LVT0 (void * dummy
);
214 extern spinlock_t i8259A_lock
;