#include <linux/perf_event.h>
#include <linux/kernel_stat.h>
#include <linux/mc146818rtc.h>
#include <linux/acpi_pmtmr.h>
#include <linux/bitmap.h>
#include <linux/clockchips.h>
#include <linux/interrupt.h>
#include <linux/memblock.h>
#include <linux/ftrace.h>
#include <linux/ioport.h>
#include <linux/export.h>
#include <linux/syscore_ops.h>
#include <linux/delay.h>
#include <linux/timex.h>
#include <linux/i8253.h>
#include <linux/dmar.h>
#include <linux/init.h>
#include <linux/cpu.h>
#include <linux/dmi.h>
#include <linux/smp.h>
#include <linux/mm.h>
#include <xen/xen.h>
#include <asm/trace/irq_vectors.h>
#include <asm/irq_remapping.h>
#include <asm/pc-conf-reg.h>
#include <asm/perf_event.h>
#include <asm/x86_init.h>
#include <linux/atomic.h>
#include <asm/barrier.h>
#include <asm/mpspec.h>
#include <asm/i8259.h>
#include <asm/proto.h>
#include <asm/traps.h>
#include <asm/apic.h>
#include <asm/acpi.h>
#include <asm/io_apic.h>
#include <asm/desc.h>
#include <asm/hpet.h>
#include <asm/mtrr.h>
#include <asm/time.h>
#include <asm/smp.h>
#include <asm/mce.h>
#include <asm/tsc.h>
#include <asm/hypervisor.h>
#include <asm/cpu_device_id.h>
#include <asm/intel-family.h>
#include <asm/irq_regs.h>
#include <asm/cpu.h>
#include "local.h"
u32 boot_cpu_physical_apicid __ro_after_init = …;
EXPORT_SYMBOL_GPL(…);
u8 boot_cpu_apic_version __ro_after_init;
static int apic_extnmi __ro_after_init = …;
static bool virt_ext_dest_id __ro_after_init;
unsigned long apic_mmio_base __ro_after_init;
static inline bool apic_accessible(void)
{ … }
#ifdef CONFIG_X86_32
static int enabled_via_apicbase __ro_after_init;
static inline void imcr_pic_to_apic(void)
{
pc_conf_set(PC_CONF_MPS_IMCR, 0x01);
}
static inline void imcr_apic_to_pic(void)
{
pc_conf_set(PC_CONF_MPS_IMCR, 0x00);
}
#endif
static int force_enable_local_apic __initdata;
static int __init parse_lapic(char *arg)
{ … }
early_param(…);
#ifdef CONFIG_X86_64
static int apic_calibrate_pmtmr __initdata;
static __init int setup_apicpmtimer(char *s)
{ … }
__setup(…);
#endif
static unsigned long mp_lapic_addr __ro_after_init;
bool apic_is_disabled __ro_after_init;
static int disable_apic_timer __initdata;
int local_apic_timer_c2_ok __ro_after_init;
EXPORT_SYMBOL_GPL(…);
int apic_verbosity __ro_after_init;
int pic_mode __ro_after_init;
int smp_found_config __ro_after_init;
static struct resource lapic_resource = …;
unsigned int lapic_timer_period = …;
static void apic_pm_activate(void);
static inline int lapic_get_version(void)
{ … }
static inline int lapic_is_integrated(void)
{ … }
static int modern_apic(void)
{ … }
static void __init apic_disable(void)
{ … }
void native_apic_icr_write(u32 low, u32 id)
{ … }
u64 native_apic_icr_read(void)
{ … }
int lapic_get_maxlvt(void)
{ … }
#define APIC_DIVISOR …
#define TSC_DIVISOR …
#define I82489DX_BASE_DIVIDER …
static void __setup_APIC_LVTT(unsigned int clocks, int oneshot, int irqen)
{ … }
static atomic_t eilvt_offsets[APIC_EILVT_NR_MAX];
static inline int eilvt_entry_is_changeable(unsigned int old, unsigned int new)
{ … }
static unsigned int reserve_eilvt_offset(int offset, unsigned int new)
{ … }
int setup_APIC_eilvt(u8 offset, u8 vector, u8 msg_type, u8 mask)
{ … }
EXPORT_SYMBOL_GPL(…);
static int lapic_next_event(unsigned long delta,
struct clock_event_device *evt)
{ … }
static int lapic_next_deadline(unsigned long delta,
struct clock_event_device *evt)
{ … }
static int lapic_timer_shutdown(struct clock_event_device *evt)
{ … }
static inline int
lapic_timer_set_periodic_oneshot(struct clock_event_device *evt, bool oneshot)
{ … }
static int lapic_timer_set_periodic(struct clock_event_device *evt)
{ … }
static int lapic_timer_set_oneshot(struct clock_event_device *evt)
{ … }
static void lapic_timer_broadcast(const struct cpumask *mask)
{ … }
static struct clock_event_device lapic_clockevent = …;
static DEFINE_PER_CPU(struct clock_event_device, lapic_events);
static const struct x86_cpu_id deadline_match[] __initconst = …;
static __init bool apic_validate_deadline_timer(void)
{ … }
static void setup_APIC_timer(void)
{ … }
static void __lapic_update_tsc_freq(void *info)
{ … }
void lapic_update_tsc_freq(void)
{ … }
#define LAPIC_CAL_LOOPS …
static __initdata int lapic_cal_loops = …;
static __initdata long lapic_cal_t1, lapic_cal_t2;
static __initdata unsigned long long lapic_cal_tsc1, lapic_cal_tsc2;
static __initdata u32 lapic_cal_pm1, lapic_cal_pm2;
static __initdata unsigned long lapic_cal_j1, lapic_cal_j2;
static void __init lapic_cal_handler(struct clock_event_device *dev)
{ … }
static int __init
calibrate_by_pmtimer(u32 deltapm, long *delta, long *deltatsc)
{ … }
static int __init lapic_init_clockevent(void)
{ … }
bool __init apic_needs_pit(void)
{ … }
static int __init calibrate_APIC_clock(void)
{ … }
void __init setup_boot_APIC_clock(void)
{ … }
void setup_secondary_APIC_clock(void)
{ … }
static void local_apic_timer_interrupt(void)
{ … }
DEFINE_IDTENTRY_SYSVEC(sysvec_apic_timer_interrupt)
{ … }
void clear_local_APIC(void)
{ … }
void apic_soft_disable(void)
{ … }
void disable_local_APIC(void)
{ … }
void lapic_shutdown(void)
{ … }
void __init sync_Arb_IDs(void)
{ … }
enum apic_intr_mode_id apic_intr_mode __ro_after_init;
static int __init __apic_intr_mode_select(void)
{ … }
void __init apic_intr_mode_select(void)
{ … }
void __init init_bsp_APIC(void)
{ … }
static void __init apic_bsp_setup(bool upmode);
void __init apic_intr_mode_init(void)
{ … }
static void lapic_setup_esr(void)
{ … }
#define APIC_IR_REGS …
#define APIC_IR_BITS …
#define APIC_IR_MAPSIZE …
apic_ir;
static bool apic_check_and_ack(union apic_ir *irr, union apic_ir *isr)
{ … }
static void apic_pending_intr_clear(void)
{ … }
static void setup_local_APIC(void)
{ … }
static void end_local_APIC_setup(void)
{ … }
void apic_ap_setup(void)
{ … }
static __init void apic_read_boot_cpu_id(bool x2apic)
{ … }
#ifdef CONFIG_X86_X2APIC
int x2apic_mode;
EXPORT_SYMBOL_GPL(…);
enum { … };
static int x2apic_state;
static bool x2apic_hw_locked(void)
{ … }
static void __x2apic_disable(void)
{ … }
static void __x2apic_enable(void)
{ … }
static int __init setup_nox2apic(char *str)
{ … }
early_param(…);
void x2apic_setup(void)
{ … }
static __init void apic_set_fixmap(bool read_apic);
static __init void x2apic_disable(void)
{ … }
static __init void x2apic_enable(void)
{ … }
static __init void try_to_enable_x2apic(int remap_mode)
{ … }
void __init check_x2apic(void)
{ … }
#else
void __init check_x2apic(void)
{
if (!apic_is_x2apic_enabled())
return;
pr_err("Kernel does not support x2APIC, please recompile with CONFIG_X86_X2APIC.\n");
pr_err("Disabling APIC, expect reduced performance and functionality.\n");
apic_is_disabled = true;
setup_clear_cpu_cap(X86_FEATURE_APIC);
}
static inline void try_to_enable_x2apic(int remap_mode) { }
static inline void __x2apic_enable(void) { }
#endif
void __init enable_IR_x2apic(void)
{ … }
#ifdef CONFIG_X86_64
static bool __init detect_init_APIC(void)
{ … }
#else
static bool __init apic_verify(unsigned long addr)
{
u32 features, h, l;
features = cpuid_edx(1);
if (!(features & (1 << X86_FEATURE_APIC))) {
pr_warn("Could not enable APIC!\n");
return false;
}
set_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC);
if (boot_cpu_data.x86 >= 6) {
rdmsr(MSR_IA32_APICBASE, l, h);
if (l & MSR_IA32_APICBASE_ENABLE)
addr = l & MSR_IA32_APICBASE_BASE;
}
register_lapic_address(addr);
pr_info("Found and enabled local APIC!\n");
return true;
}
bool __init apic_force_enable(unsigned long addr)
{
u32 h, l;
if (apic_is_disabled)
return false;
if (boot_cpu_data.x86 >= 6) {
rdmsr(MSR_IA32_APICBASE, l, h);
if (!(l & MSR_IA32_APICBASE_ENABLE)) {
pr_info("Local APIC disabled by BIOS -- reenabling.\n");
l &= ~MSR_IA32_APICBASE_BASE;
l |= MSR_IA32_APICBASE_ENABLE | addr;
wrmsr(MSR_IA32_APICBASE, l, h);
enabled_via_apicbase = 1;
}
}
return apic_verify(addr);
}
static bool __init detect_init_APIC(void)
{
if (apic_is_disabled)
return false;
switch (boot_cpu_data.x86_vendor) {
case X86_VENDOR_AMD:
if ((boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model > 1) ||
(boot_cpu_data.x86 >= 15))
break;
goto no_apic;
case X86_VENDOR_HYGON:
break;
case X86_VENDOR_INTEL:
if (boot_cpu_data.x86 == 6 || boot_cpu_data.x86 == 15 ||
(boot_cpu_data.x86 == 5 && boot_cpu_has(X86_FEATURE_APIC)))
break;
goto no_apic;
default:
goto no_apic;
}
if (!boot_cpu_has(X86_FEATURE_APIC)) {
if (!force_enable_local_apic) {
pr_info("Local APIC disabled by BIOS -- "
"you can enable it with \"lapic\"\n");
return false;
}
if (!apic_force_enable(APIC_DEFAULT_PHYS_BASE))
return false;
} else {
if (!apic_verify(APIC_DEFAULT_PHYS_BASE))
return false;
}
apic_pm_activate();
return true;
no_apic:
pr_info("No local APIC present or hardware disabled\n");
return false;
}
#endif
void __init init_apic_mappings(void)
{ … }
static __init void apic_set_fixmap(bool read_apic)
{ … }
void __init register_lapic_address(unsigned long address)
{ … }
static noinline void handle_spurious_interrupt(u8 vector)
{ … }
DEFINE_IDTENTRY_IRQ(spurious_interrupt)
{ … }
DEFINE_IDTENTRY_SYSVEC(sysvec_spurious_apic_interrupt)
{ … }
DEFINE_IDTENTRY_SYSVEC(sysvec_error_interrupt)
{ … }
static void __init connect_bsp_APIC(void)
{ … }
void disconnect_bsp_APIC(int virt_wire_setup)
{ … }
void __irq_msi_compose_msg(struct irq_cfg *cfg, struct msi_msg *msg,
bool dmar)
{ … }
u32 x86_msi_msg_get_destid(struct msi_msg *msg, bool extid)
{ … }
EXPORT_SYMBOL_GPL(…);
static void __init apic_bsp_up_setup(void)
{ … }
static void __init apic_bsp_setup(bool upmode)
{ … }
#ifdef CONFIG_UP_LATE_INIT
void __init up_late_init(void)
{
if (apic_intr_mode == APIC_PIC)
return;
x86_init.timers.setup_percpu_clockev();
}
#endif
#ifdef CONFIG_PM
static struct { … } apic_pm_state;
static int lapic_suspend(void)
{ … }
static void lapic_resume(void)
{ … }
static struct syscore_ops lapic_syscore_ops = …;
static void apic_pm_activate(void)
{ … }
static int __init init_lapic_sysfs(void)
{ … }
core_initcall(init_lapic_sysfs);
#else
static void apic_pm_activate(void) { }
#endif
#ifdef CONFIG_X86_64
static int multi_checked;
static int multi;
static int set_multi(const struct dmi_system_id *d)
{ … }
static const struct dmi_system_id multi_dmi_table[] = …;
static void dmi_check_multi(void)
{ … }
int apic_is_clustered_box(void)
{ … }
#endif
static int __init setup_disableapic(char *arg)
{ … }
early_param(…);
static int __init setup_nolapic(char *arg)
{ … }
early_param(…);
static int __init parse_lapic_timer_c2_ok(char *arg)
{ … }
early_param(…);
static int __init parse_disable_apic_timer(char *arg)
{ … }
early_param(…);
static int __init parse_nolapic_timer(char *arg)
{ … }
early_param(…);
static int __init apic_set_verbosity(char *arg)
{ … }
early_param(…);
static int __init lapic_insert_resource(void)
{ … }
late_initcall(lapic_insert_resource);
static int __init apic_set_extnmi(char *arg)
{ … }
early_param(…);