Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * NOOP APIC driver.
0004  *
0005  * Does almost nothing and should be substituted by a real apic driver via
0006  * probe routine.
0007  *
0008  * Though in case if apic is disabled (for some reason) we try
0009  * to not uglify the caller's code and allow to call (some) apic routines
0010  * like self-ipi, etc...
0011  */
0012 #include <linux/cpumask.h>
0013 #include <linux/thread_info.h>
0014 
0015 #include <asm/apic.h>
0016 
0017 static void noop_init_apic_ldr(void) { }
0018 static void noop_send_IPI(int cpu, int vector) { }
0019 static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector) { }
0020 static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) { }
0021 static void noop_send_IPI_allbutself(int vector) { }
0022 static void noop_send_IPI_all(int vector) { }
0023 static void noop_send_IPI_self(int vector) { }
0024 static void noop_apic_wait_icr_idle(void) { }
0025 static void noop_apic_icr_write(u32 low, u32 id) { }
0026 
0027 static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip)
0028 {
0029     return -1;
0030 }
0031 
0032 static u32 noop_safe_apic_wait_icr_idle(void)
0033 {
0034     return 0;
0035 }
0036 
0037 static u64 noop_apic_icr_read(void)
0038 {
0039     return 0;
0040 }
0041 
0042 static int noop_phys_pkg_id(int cpuid_apic, int index_msb)
0043 {
0044     return 0;
0045 }
0046 
0047 static unsigned int noop_get_apic_id(unsigned long x)
0048 {
0049     return 0;
0050 }
0051 
0052 static int noop_probe(void)
0053 {
0054     /*
0055      * NOOP apic should not ever be
0056      * enabled via probe routine
0057      */
0058     return 0;
0059 }
0060 
0061 static int noop_apic_id_registered(void)
0062 {
0063     /*
0064      * if we would be really "pedantic"
0065      * we should pass read_apic_id() here
0066      * but since NOOP suppose APIC ID = 0
0067      * lets save a few cycles
0068      */
0069     return physid_isset(0, phys_cpu_present_map);
0070 }
0071 
0072 static u32 noop_apic_read(u32 reg)
0073 {
0074     WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic);
0075     return 0;
0076 }
0077 
0078 static void noop_apic_write(u32 reg, u32 v)
0079 {
0080     WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic);
0081 }
0082 
0083 #ifdef CONFIG_X86_32
0084 static int noop_x86_32_early_logical_apicid(int cpu)
0085 {
0086     return BAD_APICID;
0087 }
0088 #endif
0089 
0090 struct apic apic_noop __ro_after_init = {
0091     .name               = "noop",
0092     .probe              = noop_probe,
0093     .acpi_madt_oem_check        = NULL,
0094 
0095     .apic_id_valid          = default_apic_id_valid,
0096     .apic_id_registered     = noop_apic_id_registered,
0097 
0098     .delivery_mode          = APIC_DELIVERY_MODE_FIXED,
0099     .dest_mode_logical      = true,
0100 
0101     .disable_esr            = 0,
0102 
0103     .check_apicid_used      = default_check_apicid_used,
0104     .init_apic_ldr          = noop_init_apic_ldr,
0105     .ioapic_phys_id_map     = default_ioapic_phys_id_map,
0106     .setup_apic_routing     = NULL,
0107     .cpu_present_to_apicid      = default_cpu_present_to_apicid,
0108     .apicid_to_cpu_present      = physid_set_mask_of_physid,
0109 
0110     .check_phys_apicid_present  = default_check_phys_apicid_present,
0111 
0112     .phys_pkg_id            = noop_phys_pkg_id,
0113 
0114     .get_apic_id            = noop_get_apic_id,
0115     .set_apic_id            = NULL,
0116 
0117     .calc_dest_apicid       = apic_flat_calc_apicid,
0118 
0119     .send_IPI           = noop_send_IPI,
0120     .send_IPI_mask          = noop_send_IPI_mask,
0121     .send_IPI_mask_allbutself   = noop_send_IPI_mask_allbutself,
0122     .send_IPI_allbutself        = noop_send_IPI_allbutself,
0123     .send_IPI_all           = noop_send_IPI_all,
0124     .send_IPI_self          = noop_send_IPI_self,
0125 
0126     .wakeup_secondary_cpu       = noop_wakeup_secondary_cpu,
0127 
0128     .inquire_remote_apic        = NULL,
0129 
0130     .read               = noop_apic_read,
0131     .write              = noop_apic_write,
0132     .eoi_write          = noop_apic_write,
0133     .icr_read           = noop_apic_icr_read,
0134     .icr_write          = noop_apic_icr_write,
0135     .wait_icr_idle          = noop_apic_wait_icr_idle,
0136     .safe_wait_icr_idle     = noop_safe_apic_wait_icr_idle,
0137 
0138 #ifdef CONFIG_X86_32
0139     .x86_32_early_logical_apicid    = noop_x86_32_early_logical_apicid,
0140 #endif
0141 };