1 #ifndef __ASM_IO_APIC_H
2 #define __ASM_IO_APIC_H
4 #include <linux/config.h>
8 * Intel IO-APIC support for SMP and UP systems.
10 * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
13 #ifdef CONFIG_X86_IO_APIC
15 #define APIC_MISMATCH_DEBUG
17 #define IO_APIC_BASE(idx) \
18 ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \
19 + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
22 * The structure of the IO-APIC:
24 struct IO_APIC_reg_00 {
25 __u32 __reserved_2 : 14,
31 } __attribute__ ((packed));
33 struct IO_APIC_reg_01 {
39 } __attribute__ ((packed));
41 struct IO_APIC_reg_02 {
42 __u32 __reserved_2 : 24,
45 } __attribute__ ((packed));
47 struct IO_APIC_reg_03 {
50 } __attribute__ ((packed));
53 * # of IO-APICs and # of IRQ routing registers
55 extern int nr_ioapics;
56 extern int nr_ioapic_registers[MAX_IO_APICS];
58 enum ioapic_irq_destination_types {
69 struct IO_APIC_route_entry {
71 delivery_mode : 3, /* 000: FIXED
75 dest_mode : 1, /* 0: physical, 1: logical */
79 trigger : 1, /* 0: edge, 1: level */
80 mask : 1, /* 0: enabled, 1: disabled */
83 union { struct { __u32
95 } __attribute__ ((packed));
98 * MP-BIOS irq configuration table structures:
101 /* I/O APIC entries */
102 extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
104 /* # of MP IRQ source entries */
105 extern int mp_irq_entries;
107 /* MP IRQ source entries */
108 extern struct mpc_config_intsrc *mp_irqs;
110 /* non-0 if default (table-less) MP configuration */
111 extern int mpc_default_type;
113 static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
115 *IO_APIC_BASE(apic) = reg;
116 return *(IO_APIC_BASE(apic)+4);
119 static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
121 *IO_APIC_BASE(apic) = reg;
122 *(IO_APIC_BASE(apic)+4) = value;
126 * Synchronize the IO-APIC and the CPU by doing
127 * a dummy read from the IO-APIC
129 static inline void io_apic_sync(unsigned int apic)
131 (void) *(IO_APIC_BASE(apic)+4);
135 * If we use the IO-APIC for IRQ routing, disable automatic
136 * assignment of PCI IRQ's.
138 #define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup)
140 #ifdef CONFIG_ACPI_BOOT
141 extern int io_apic_get_unique_id (int ioapic, int apic_id);
142 extern int io_apic_get_version (int ioapic);
143 extern int io_apic_get_redir_entries (int ioapic);
144 extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low);
147 extern int skip_ioapic_setup; /* 1 for "noapic" */
149 static inline void disable_ioapic_setup(void)
151 skip_ioapic_setup = 1;
154 static inline int ioapic_setup_disabled(void)
156 return skip_ioapic_setup;
159 #else /* !CONFIG_X86_IO_APIC */
160 #define io_apic_assign_pci_irqs 0
162 static inline void disable_ioapic_setup(void)
165 #endif /* !CONFIG_X86_IO_APIC */