blob: 7df1b48fa35a661b8439eb28f26a5162f946bae9 [file] [log] [blame]
Ingo Molnaref7471b2009-01-27 23:12:02 +01001#ifndef _ASM_X86_GENAPIC_H
2#define _ASM_X86_GENAPIC_H
3
4#include <linux/cpumask.h>
5
6/*
7 * Copyright 2004 James Cleverdon, IBM.
8 * Subject to the GNU Public License, v.2
9 *
10 * Generic APIC sub-arch data struct.
11 *
12 * Hacked for x86-64 by James Cleverdon from i386 architecture code by
13 * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
14 * James Cleverdon.
15 */
16
17struct genapic {
18 char *name;
19
20 int (*probe)(void);
21 int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id);
22 int (*apic_id_registered)(void);
23
24 u32 int_delivery_mode;
25 u32 int_dest_mode;
26
27 const struct cpumask *(*target_cpus)(void);
28
29 int ESR_DISABLE;
30
31 int apic_destination_logical;
32 unsigned long (*check_apicid_used)(physid_mask_t bitmap, int apicid);
33 unsigned long (*check_apicid_present)(int apicid);
34
35 int no_balance_irq;
36 int no_ioapic_check;
37
38 void (*vector_allocation_domain)(int cpu, struct cpumask *retmask);
39 void (*init_apic_ldr)(void);
40
41 physid_mask_t (*ioapic_phys_id_map)(physid_mask_t map);
42
43 void (*setup_apic_routing)(void);
44 int (*multi_timer_check)(int apic, int irq);
45 int (*apicid_to_node)(int logical_apicid);
46 int (*cpu_to_logical_apicid)(int cpu);
47 int (*cpu_present_to_apicid)(int mps_cpu);
48 physid_mask_t (*apicid_to_cpu_present)(int phys_apicid);
49 void (*setup_portio_remap)(void);
50 int (*check_phys_apicid_present)(int boot_cpu_physical_apicid);
51 void (*enable_apic_mode)(void);
52#ifdef CONFIG_X86_32
53 u32 (*phys_pkg_id)(u32 cpuid_apic, int index_msb);
54#else
55 unsigned int (*phys_pkg_id)(int index_msb);
56#endif
57
58 /*
59 * When one of the next two hooks returns 1 the genapic
60 * is switched to this. Essentially they are additional
61 * probe functions:
62 */
63 int (*mps_oem_check)(struct mpc_table *mpc, char *oem,
64 char *productid);
65
66 unsigned int (*get_apic_id)(unsigned long x);
67 unsigned long (*set_apic_id)(unsigned int id);
68 unsigned long apic_id_mask;
69
70 unsigned int (*cpu_mask_to_apicid)(const struct cpumask *cpumask);
71 unsigned int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask,
72 const struct cpumask *andmask);
73
74#ifdef CONFIG_SMP
75 /* ipi */
76 void (*send_IPI_mask)(const struct cpumask *mask, int vector);
77 void (*send_IPI_mask_allbutself)(const struct cpumask *mask,
78 int vector);
79 void (*send_IPI_allbutself)(int vector);
80 void (*send_IPI_all)(int vector);
81 void (*send_IPI_self)(int vector);
82#endif
83 /* wakeup_secondary_cpu */
84 int (*wakeup_cpu)(int apicid, unsigned long start_eip);
85
86 int trampoline_phys_low;
87 int trampoline_phys_high;
88 void (*wait_for_init_deassert)(atomic_t *deassert);
89 void (*smp_callin_clear_local_apic)(void);
90 void (*store_NMI_vector)(unsigned short *high, unsigned short *low);
91 void (*restore_NMI_vector)(unsigned short *high, unsigned short *low);
92 void (*inquire_remote_apic)(int apicid);
93};
94
Thomas Gleixner96a388d2007-10-11 11:20:03 +020095#ifdef CONFIG_X86_32
Ingo Molnarced733e2009-01-27 23:15:06 +010096
97#include <asm/mpspec.h>
98#include <asm/atomic.h>
99
100#define APICFUNC(x) .x = x,
101
102/* More functions could be probably marked IPIFUNC and save some space
103 in UP GENERICARCH kernels, but I don't have the nerve right now
104 to untangle this mess. -AK */
105#ifdef CONFIG_SMP
106#define IPIFUNC(x) APICFUNC(x)
Thomas Gleixner96a388d2007-10-11 11:20:03 +0200107#else
Ingo Molnarced733e2009-01-27 23:15:06 +0100108#define IPIFUNC(x)
Thomas Gleixner96a388d2007-10-11 11:20:03 +0200109#endif
Ingo Molnaref7471b2009-01-27 23:12:02 +0100110
Ingo Molnarced733e2009-01-27 23:15:06 +0100111#define APIC_INIT(aname, aprobe) \
112{ \
113 .name = aname, \
114 .probe = aprobe, \
115 .int_delivery_mode = INT_DELIVERY_MODE, \
116 .int_dest_mode = INT_DEST_MODE, \
117 .no_balance_irq = NO_BALANCE_IRQ, \
118 .ESR_DISABLE = esr_disable, \
119 .apic_destination_logical = APIC_DEST_LOGICAL, \
120 APICFUNC(apic_id_registered) \
121 APICFUNC(target_cpus) \
122 APICFUNC(check_apicid_used) \
123 APICFUNC(check_apicid_present) \
124 APICFUNC(init_apic_ldr) \
125 APICFUNC(ioapic_phys_id_map) \
126 APICFUNC(setup_apic_routing) \
127 APICFUNC(multi_timer_check) \
128 APICFUNC(apicid_to_node) \
129 APICFUNC(cpu_to_logical_apicid) \
130 APICFUNC(cpu_present_to_apicid) \
131 APICFUNC(apicid_to_cpu_present) \
132 APICFUNC(setup_portio_remap) \
133 APICFUNC(check_phys_apicid_present) \
134 APICFUNC(mps_oem_check) \
135 APICFUNC(get_apic_id) \
136 .apic_id_mask = APIC_ID_MASK, \
137 APICFUNC(cpu_mask_to_apicid) \
138 APICFUNC(cpu_mask_to_apicid_and) \
139 APICFUNC(vector_allocation_domain) \
140 APICFUNC(acpi_madt_oem_check) \
141 IPIFUNC(send_IPI_mask) \
142 IPIFUNC(send_IPI_allbutself) \
143 IPIFUNC(send_IPI_all) \
144 APICFUNC(enable_apic_mode) \
145 APICFUNC(phys_pkg_id) \
146 .trampoline_phys_low = TRAMPOLINE_PHYS_LOW, \
147 .trampoline_phys_high = TRAMPOLINE_PHYS_HIGH, \
148 APICFUNC(wait_for_init_deassert) \
149 APICFUNC(smp_callin_clear_local_apic) \
150 APICFUNC(store_NMI_vector) \
151 APICFUNC(restore_NMI_vector) \
152 APICFUNC(inquire_remote_apic) \
153}
154
155extern struct genapic *genapic;
156extern void es7000_update_genapic_to_cluster(void);
157
158#else /* CONFIG_X86_64: */
159
160extern struct genapic *genapic;
161
162extern struct genapic apic_flat;
163extern struct genapic apic_physflat;
164extern struct genapic apic_x2apic_cluster;
165extern struct genapic apic_x2apic_phys;
166extern int acpi_madt_oem_check(char *, char *);
167
168extern void apic_send_IPI_self(int vector);
169
170extern struct genapic apic_x2apic_uv_x;
171DECLARE_PER_CPU(int, x2apic_extra_bits);
172
173extern void setup_apic_routing(void);
174
175#endif /* CONFIG_X86_64 */
176
Ingo Molnaref7471b2009-01-27 23:12:02 +0100177#endif /* _ASM_X86_GENAPIC_64_H */