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