4 * Does almost nothing and should be substituted by a real apic driver via
7 * Though in case if apic is disabled (for some reason) we try
8 * to not uglify the caller's code and allow to call (some) apic routines
9 * like self-ipi, etc... and issue a warning if an operation is not allowed
12 #include <linux/threads.h>
13 #include <linux/cpumask.h>
14 #include <linux/module.h>
15 #include <linux/string.h>
16 #include <linux/kernel.h>
17 #include <linux/ctype.h>
18 #include <linux/init.h>
19 #include <linux/errno.h>
20 #include <asm/fixmap.h>
21 #include <asm/mpspec.h>
22 #include <asm/apicdef.h>
24 #include <asm/setup.h>
26 #include <linux/smp.h>
29 #include <linux/interrupt.h>
34 * some operations should never be reached with
35 * noop apic if it's not turned off, this mostly
36 * means the caller forgot to disable apic (or
37 * check the apic presence) before doing a call
39 static void warn_apic_enabled(void)
41 WARN_ONCE((cpu_has_apic || !disable_apic),
42 "APIC: Called for NOOP operation with apic enabled\n");
46 * To check operations but do not bloat source code
48 #define NOOP_FUNC(func) func { warn_apic_enabled(); }
49 #define NOOP_FUNC_RET(func, ret) func { warn_apic_enabled(); return ret; }
51 NOOP_FUNC(static void noop_init_apic_ldr(void))
52 NOOP_FUNC(static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector))
53 NOOP_FUNC(static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector))
54 NOOP_FUNC(static void noop_send_IPI_allbutself(int vector))
55 NOOP_FUNC(static void noop_send_IPI_all(int vector))
56 NOOP_FUNC(static void noop_send_IPI_self(int vector))
57 NOOP_FUNC_RET(static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip), -1)
58 NOOP_FUNC(static void noop_apic_write(u32 reg, u32 v))
59 NOOP_FUNC(void noop_apic_wait_icr_idle(void))
60 NOOP_FUNC_RET(static u32 noop_safe_apic_wait_icr_idle(void), 0)
61 NOOP_FUNC_RET(static u64 noop_apic_icr_read(void), 0)
62 NOOP_FUNC(static void noop_apic_icr_write(u32 low, u32 id))
63 NOOP_FUNC_RET(static physid_mask_t noop_ioapic_phys_id_map(physid_mask_t phys_map), phys_map)
64 NOOP_FUNC_RET(static int noop_cpu_to_logical_apicid(int cpu), 1)
65 NOOP_FUNC_RET(static int noop_default_phys_pkg_id(int cpuid_apic, int index_msb), 0)
66 NOOP_FUNC_RET(static unsigned int noop_get_apic_id(unsigned long x), 0)
68 static int noop_probe(void)
70 /* should not ever be enabled this way */
74 static int noop_apic_id_registered(void)
77 return physid_isset(read_apic_id(), phys_cpu_present_map);
80 static const struct cpumask *noop_target_cpus(void)
88 static unsigned long noop_check_apicid_used(physid_mask_t bitmap, int apicid)
91 return physid_isset(apicid, bitmap);
94 static unsigned long noop_check_apicid_present(int bit)
97 return physid_isset(bit, phys_cpu_present_map);
100 static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask)
104 pr_warning("APIC: Vector allocated for non-BSP cpu\n");
105 cpumask_clear(retmask);
106 cpumask_set_cpu(cpu, retmask);
109 int noop_apicid_to_node(int logical_apicid)
113 /* we're always on node 0 */
117 static u32 noop_apic_read(u32 reg)
120 * noop-read is always safe until we have
123 WARN_ON_ONCE((cpu_has_apic && !disable_apic));
127 struct apic apic_noop = {
130 .acpi_madt_oem_check = NULL,
132 .apic_id_registered = noop_apic_id_registered,
134 .irq_delivery_mode = dest_LowestPrio,
135 /* logical delivery broadcast to all CPUs: */
138 .target_cpus = noop_target_cpus,
140 .dest_logical = APIC_DEST_LOGICAL,
141 .check_apicid_used = noop_check_apicid_used,
142 .check_apicid_present = noop_check_apicid_present,
144 .vector_allocation_domain = noop_vector_allocation_domain,
145 .init_apic_ldr = noop_init_apic_ldr,
147 .ioapic_phys_id_map = noop_ioapic_phys_id_map,
148 .setup_apic_routing = NULL,
149 .multi_timer_check = NULL,
150 .apicid_to_node = noop_apicid_to_node,
152 .cpu_to_logical_apicid = noop_cpu_to_logical_apicid,
153 .cpu_present_to_apicid = default_cpu_present_to_apicid,
154 .apicid_to_cpu_present = default_apicid_to_cpu_present,
156 .setup_portio_remap = NULL,
157 .check_phys_apicid_present = default_check_phys_apicid_present,
158 .enable_apic_mode = NULL,
160 .phys_pkg_id = noop_default_phys_pkg_id,
162 .mps_oem_check = NULL,
164 .get_apic_id = noop_get_apic_id,
166 .apic_id_mask = 0x0F << 24,
168 .cpu_mask_to_apicid = default_cpu_mask_to_apicid,
169 .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
171 .send_IPI_mask = noop_send_IPI_mask,
172 .send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself,
173 .send_IPI_allbutself = noop_send_IPI_allbutself,
174 .send_IPI_all = noop_send_IPI_all,
175 .send_IPI_self = noop_send_IPI_self,
177 .wakeup_secondary_cpu = noop_wakeup_secondary_cpu,
180 .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
181 .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
183 .wait_for_init_deassert = NULL,
185 .smp_callin_clear_local_apic = NULL,
186 .inquire_remote_apic = NULL,
188 .read = noop_apic_read,
189 .write = noop_apic_write,
190 .icr_read = noop_apic_icr_read,
191 .icr_write = noop_apic_icr_write,
192 .wait_icr_idle = noop_apic_wait_icr_idle,
193 .safe_wait_icr_idle = noop_safe_apic_wait_icr_idle,