blob: 276ea7e8144ae3cfc8e58b7819ae59c126f90578 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_IO_APIC_H
2#define __ASM_IO_APIC_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <asm/types.h>
5#include <asm/mpspec.h>
6
7/*
8 * Intel IO-APIC support for SMP and UP systems.
9 *
10 * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
11 */
12
13#ifdef CONFIG_X86_IO_APIC
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#define IO_APIC_BASE(idx) \
16 ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \
17 + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
18
19/*
20 * The structure of the IO-APIC:
21 */
22union IO_APIC_reg_00 {
23 u32 raw;
24 struct {
25 u32 __reserved_2 : 14,
26 LTS : 1,
27 delivery_type : 1,
28 __reserved_1 : 8,
29 ID : 8;
30 } __attribute__ ((packed)) bits;
31};
32
33union IO_APIC_reg_01 {
34 u32 raw;
35 struct {
36 u32 version : 8,
37 __reserved_2 : 7,
38 PRQ : 1,
39 entries : 8,
40 __reserved_1 : 8;
41 } __attribute__ ((packed)) bits;
42};
43
44union IO_APIC_reg_02 {
45 u32 raw;
46 struct {
47 u32 __reserved_2 : 24,
48 arbitration : 4,
49 __reserved_1 : 4;
50 } __attribute__ ((packed)) bits;
51};
52
53union IO_APIC_reg_03 {
54 u32 raw;
55 struct {
56 u32 boot_DT : 1,
57 __reserved_1 : 31;
58 } __attribute__ ((packed)) bits;
59};
60
61/*
62 * # of IO-APICs and # of IRQ routing registers
63 */
64extern int nr_ioapics;
65extern int nr_ioapic_registers[MAX_IO_APICS];
66
67enum ioapic_irq_destination_types {
68 dest_Fixed = 0,
69 dest_LowestPrio = 1,
70 dest_SMI = 2,
71 dest__reserved_1 = 3,
72 dest_NMI = 4,
73 dest_INIT = 5,
74 dest__reserved_2 = 6,
75 dest_ExtINT = 7
76};
77
78struct IO_APIC_route_entry {
79 __u32 vector : 8,
80 delivery_mode : 3, /* 000: FIXED
81 * 001: lowest prio
82 * 111: ExtINT
83 */
84 dest_mode : 1, /* 0: physical, 1: logical */
85 delivery_status : 1,
86 polarity : 1,
87 irr : 1,
88 trigger : 1, /* 0: edge, 1: level */
89 mask : 1, /* 0: enabled, 1: disabled */
90 __reserved_2 : 15;
91
92 union { struct { __u32
93 __reserved_1 : 24,
94 physical_dest : 4,
95 __reserved_2 : 4;
96 } physical;
97
98 struct { __u32
99 __reserved_1 : 24,
100 logical_dest : 8;
101 } logical;
102 } dest;
103
104} __attribute__ ((packed));
105
106/*
107 * MP-BIOS irq configuration table structures:
108 */
109
110/* I/O APIC entries */
111extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
112
113/* # of MP IRQ source entries */
114extern int mp_irq_entries;
115
116/* MP IRQ source entries */
117extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
118
119/* non-0 if default (table-less) MP configuration */
120extern int mpc_default_type;
121
122static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
123{
124 *IO_APIC_BASE(apic) = reg;
125 return *(IO_APIC_BASE(apic)+4);
126}
127
128static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
129{
130 *IO_APIC_BASE(apic) = reg;
131 *(IO_APIC_BASE(apic)+4) = value;
132}
133
134/*
135 * Re-write a value: to be used for read-modify-write
136 * cycles where the read already set up the index register.
137 *
138 * Older SiS APIC requires we rewrite the index regiser
139 */
140extern int sis_apic_bug;
141static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value)
142{
143 if (sis_apic_bug)
144 *IO_APIC_BASE(apic) = reg;
145 *(IO_APIC_BASE(apic)+4) = value;
146}
147
148/* 1 if "noapic" boot option passed */
149extern int skip_ioapic_setup;
150
Rusty Russell1a3f2392006-09-26 10:52:32 +0200151static inline void disable_ioapic_setup(void)
152{
153 skip_ioapic_setup = 1;
154}
155
156static inline int ioapic_setup_disabled(void)
157{
158 return skip_ioapic_setup;
159}
160
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161/*
162 * If we use the IO-APIC for IRQ routing, disable automatic
163 * assignment of PCI IRQ's.
164 */
165#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
166
Len Brown888ba6c2005-08-24 12:07:20 -0400167#ifdef CONFIG_ACPI
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168extern int io_apic_get_unique_id (int ioapic, int apic_id);
169extern int io_apic_get_version (int ioapic);
170extern int io_apic_get_redir_entries (int ioapic);
171extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low);
Kimball Murraye0c1e9b2006-05-08 15:17:16 +0200172extern int timer_uses_ioapic_pin_0;
Len Brown888ba6c2005-08-24 12:07:20 -0400173#endif /* CONFIG_ACPI */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
175extern int (*ioapic_renumber_irq)(int ioapic, int irq);
176
177#else /* !CONFIG_X86_IO_APIC */
178#define io_apic_assign_pci_irqs 0
Rusty Russell1a3f2392006-09-26 10:52:32 +0200179static inline void disable_ioapic_setup(void) { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180#endif
181
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182#endif