2019-05-28 10:10:25 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2008-02-19 23:57:17 +01:00
|
|
|
/*
|
2009-01-28 19:11:44 +01:00
|
|
|
* Default generic APIC driver. This handles up to 8 CPUs.
|
|
|
|
*
|
2008-02-19 23:57:17 +01:00
|
|
|
* Copyright 2003 Andi Kleen, SuSE Labs.
|
|
|
|
*
|
2005-04-16 15:20:36 -07:00
|
|
|
* Generic x86 APIC driver probe layer.
|
2008-02-19 23:57:17 +01:00
|
|
|
*/
|
2016-07-13 20:18:56 -04:00
|
|
|
#include <linux/export.h>
|
2006-09-26 10:52:32 +02:00
|
|
|
#include <linux/errno.h>
|
2009-01-28 19:11:44 +01:00
|
|
|
#include <linux/smp.h>
|
|
|
|
|
2023-08-08 15:03:56 -07:00
|
|
|
#include <xen/xen.h>
|
|
|
|
|
2020-08-06 14:34:32 +02:00
|
|
|
#include <asm/io_apic.h>
|
2019-07-22 20:47:11 +02:00
|
|
|
#include <asm/apic.h>
|
2009-01-28 19:32:55 +01:00
|
|
|
#include <asm/acpi.h>
|
|
|
|
|
2019-07-22 20:47:14 +02:00
|
|
|
#include "local.h"
|
2009-01-28 19:32:55 +01:00
|
|
|
|
2023-08-14 10:18:44 +02:00
|
|
|
static u32 default_get_apic_id(u32 x)
|
|
|
|
{
|
|
|
|
unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
|
|
|
|
|
|
|
|
if (APIC_XAPIC(ver) || boot_cpu_has(X86_FEATURE_EXTD_APICID))
|
|
|
|
return (x >> 24) & 0xFF;
|
|
|
|
else
|
|
|
|
return (x >> 24) & 0x0F;
|
|
|
|
}
|
|
|
|
|
2009-01-28 19:11:44 +01:00
|
|
|
/* should be called last. */
|
|
|
|
static int probe_default(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-08-08 16:29:06 -07:00
|
|
|
static struct apic apic_default __ro_after_init = {
|
2009-01-28 19:11:44 +01:00
|
|
|
|
|
|
|
.name = "default",
|
|
|
|
.probe = probe_default,
|
|
|
|
|
2020-10-24 22:35:08 +01:00
|
|
|
.dest_mode_logical = true,
|
2009-01-28 19:11:44 +01:00
|
|
|
|
|
|
|
.disable_esr = 0,
|
|
|
|
|
|
|
|
.init_apic_ldr = default_init_apic_ldr,
|
|
|
|
.cpu_present_to_apicid = default_cpu_present_to_apicid,
|
|
|
|
|
2023-08-08 15:04:10 -07:00
|
|
|
.max_apic_id = 0xFE,
|
2009-01-28 19:11:44 +01:00
|
|
|
.get_apic_id = default_get_apic_id,
|
|
|
|
|
2017-09-13 23:29:37 +02:00
|
|
|
.calc_dest_apicid = apic_flat_calc_apicid,
|
2009-01-28 19:11:44 +01:00
|
|
|
|
2015-11-04 22:57:08 +00:00
|
|
|
.send_IPI = default_send_IPI_single,
|
2009-01-29 19:31:49 -08:00
|
|
|
.send_IPI_mask = default_send_IPI_mask_logical,
|
|
|
|
.send_IPI_mask_allbutself = default_send_IPI_mask_allbutself_logical,
|
2009-01-28 19:11:44 +01:00
|
|
|
.send_IPI_allbutself = default_send_IPI_allbutself,
|
|
|
|
.send_IPI_all = default_send_IPI_all,
|
2009-01-30 23:42:18 +01:00
|
|
|
.send_IPI_self = default_send_IPI_self,
|
2009-01-28 19:11:44 +01:00
|
|
|
|
2009-02-16 23:02:14 -08:00
|
|
|
.read = native_apic_mem_read,
|
|
|
|
.write = native_apic_mem_write,
|
2023-08-08 15:04:15 -07:00
|
|
|
.eoi = native_apic_mem_eoi,
|
2009-02-16 23:02:14 -08:00
|
|
|
.icr_read = native_apic_icr_read,
|
|
|
|
.icr_write = native_apic_icr_write,
|
2023-08-08 15:04:04 -07:00
|
|
|
.wait_icr_idle = apic_mem_wait_icr_idle,
|
2023-08-08 15:04:06 -07:00
|
|
|
.safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout,
|
2009-01-28 19:11:44 +01:00
|
|
|
};
|
|
|
|
|
2011-05-20 17:51:17 -07:00
|
|
|
apic_driver(apic_default);
|
|
|
|
|
2016-08-08 16:29:06 -07:00
|
|
|
struct apic *apic __ro_after_init = &apic_default;
|
2009-02-17 12:33:20 +01:00
|
|
|
EXPORT_SYMBOL_GPL(apic);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-09-26 10:52:32 +02:00
|
|
|
static int cmdline_apic __initdata;
|
|
|
|
static int __init parse_apic(char *arg)
|
|
|
|
{
|
2011-05-20 17:51:18 -07:00
|
|
|
struct apic **drv;
|
2006-09-26 10:52:32 +02:00
|
|
|
|
|
|
|
if (!arg)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-05-20 17:51:18 -07:00
|
|
|
for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
|
|
|
|
if (!strcmp((*drv)->name, arg)) {
|
2023-08-08 15:04:18 -07:00
|
|
|
apic_install_driver(*drv);
|
2006-09-26 10:52:32 +02:00
|
|
|
cmdline_apic = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2006-12-07 02:14:11 +01:00
|
|
|
|
|
|
|
/* Parsed again by __setup for debug/verbose */
|
|
|
|
return 0;
|
2006-09-26 10:52:32 +02:00
|
|
|
}
|
|
|
|
early_param("apic", parse_apic);
|
2005-09-03 15:56:31 -07:00
|
|
|
|
2023-08-08 15:04:01 -07:00
|
|
|
void __init x86_32_probe_apic(void)
|
2008-02-19 23:57:17 +01:00
|
|
|
{
|
2006-09-26 10:52:32 +02:00
|
|
|
if (!cmdline_apic) {
|
2011-05-20 17:51:18 -07:00
|
|
|
struct apic **drv;
|
|
|
|
|
|
|
|
for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
|
|
|
|
if ((*drv)->probe()) {
|
2023-08-08 15:04:18 -07:00
|
|
|
apic_install_driver(*drv);
|
2006-09-26 10:52:32 +02:00
|
|
|
break;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
}
|
2006-09-26 10:52:32 +02:00
|
|
|
/* Not visible without early console */
|
2011-05-20 17:51:18 -07:00
|
|
|
if (drv == __apicdrivers_end)
|
2006-09-26 10:52:32 +02:00
|
|
|
panic("Didn't find an APIC driver");
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
2008-02-19 23:57:17 +01:00
|
|
|
}
|