apic_noop.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * NOOP APIC driver.
  3. *
  4. * Does almost nothing and should be substituted by a real apic driver via
  5. * probe routine.
  6. *
  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...
  10. */
  11. #include <linux/threads.h>
  12. #include <linux/cpumask.h>
  13. #include <linux/string.h>
  14. #include <linux/kernel.h>
  15. #include <linux/ctype.h>
  16. #include <linux/errno.h>
  17. #include <asm/fixmap.h>
  18. #include <asm/mpspec.h>
  19. #include <asm/apicdef.h>
  20. #include <asm/apic.h>
  21. #include <asm/setup.h>
  22. #include <linux/smp.h>
  23. #include <asm/ipi.h>
  24. #include <linux/interrupt.h>
  25. #include <asm/acpi.h>
  26. #include <asm/e820.h>
  27. static void noop_init_apic_ldr(void) { }
  28. static void noop_send_IPI(int cpu, int vector) { }
  29. static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector) { }
  30. static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) { }
  31. static void noop_send_IPI_allbutself(int vector) { }
  32. static void noop_send_IPI_all(int vector) { }
  33. static void noop_send_IPI_self(int vector) { }
  34. static void noop_apic_wait_icr_idle(void) { }
  35. static void noop_apic_icr_write(u32 low, u32 id) { }
  36. static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip)
  37. {
  38. return -1;
  39. }
  40. static u32 noop_safe_apic_wait_icr_idle(void)
  41. {
  42. return 0;
  43. }
  44. static u64 noop_apic_icr_read(void)
  45. {
  46. return 0;
  47. }
  48. static int noop_phys_pkg_id(int cpuid_apic, int index_msb)
  49. {
  50. return 0;
  51. }
  52. static unsigned int noop_get_apic_id(unsigned long x)
  53. {
  54. return 0;
  55. }
  56. static int noop_probe(void)
  57. {
  58. /*
  59. * NOOP apic should not ever be
  60. * enabled via probe routine
  61. */
  62. return 0;
  63. }
  64. static int noop_apic_id_registered(void)
  65. {
  66. /*
  67. * if we would be really "pedantic"
  68. * we should pass read_apic_id() here
  69. * but since NOOP suppose APIC ID = 0
  70. * lets save a few cycles
  71. */
  72. return physid_isset(0, phys_cpu_present_map);
  73. }
  74. static const struct cpumask *noop_target_cpus(void)
  75. {
  76. /* only BSP here */
  77. return cpumask_of(0);
  78. }
  79. static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask,
  80. const struct cpumask *mask)
  81. {
  82. if (cpu != 0)
  83. pr_warning("APIC: Vector allocated for non-BSP cpu\n");
  84. cpumask_copy(retmask, cpumask_of(cpu));
  85. }
  86. static u32 noop_apic_read(u32 reg)
  87. {
  88. WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic);
  89. return 0;
  90. }
  91. static void noop_apic_write(u32 reg, u32 v)
  92. {
  93. WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic);
  94. }
  95. struct apic apic_noop __ro_after_init = {
  96. .name = "noop",
  97. .probe = noop_probe,
  98. .acpi_madt_oem_check = NULL,
  99. .apic_id_valid = default_apic_id_valid,
  100. .apic_id_registered = noop_apic_id_registered,
  101. .irq_delivery_mode = dest_LowestPrio,
  102. /* logical delivery broadcast to all CPUs: */
  103. .irq_dest_mode = 1,
  104. .target_cpus = noop_target_cpus,
  105. .disable_esr = 0,
  106. .dest_logical = APIC_DEST_LOGICAL,
  107. .check_apicid_used = default_check_apicid_used,
  108. .vector_allocation_domain = noop_vector_allocation_domain,
  109. .init_apic_ldr = noop_init_apic_ldr,
  110. .ioapic_phys_id_map = default_ioapic_phys_id_map,
  111. .setup_apic_routing = NULL,
  112. .cpu_present_to_apicid = default_cpu_present_to_apicid,
  113. .apicid_to_cpu_present = physid_set_mask_of_physid,
  114. .check_phys_apicid_present = default_check_phys_apicid_present,
  115. .phys_pkg_id = noop_phys_pkg_id,
  116. .get_apic_id = noop_get_apic_id,
  117. .set_apic_id = NULL,
  118. .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and,
  119. .send_IPI = noop_send_IPI,
  120. .send_IPI_mask = noop_send_IPI_mask,
  121. .send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself,
  122. .send_IPI_allbutself = noop_send_IPI_allbutself,
  123. .send_IPI_all = noop_send_IPI_all,
  124. .send_IPI_self = noop_send_IPI_self,
  125. .wakeup_secondary_cpu = noop_wakeup_secondary_cpu,
  126. .inquire_remote_apic = NULL,
  127. .read = noop_apic_read,
  128. .write = noop_apic_write,
  129. .eoi_write = noop_apic_write,
  130. .icr_read = noop_apic_icr_read,
  131. .icr_write = noop_apic_icr_write,
  132. .wait_icr_idle = noop_apic_wait_icr_idle,
  133. .safe_wait_icr_idle = noop_safe_apic_wait_icr_idle,
  134. #ifdef CONFIG_X86_32
  135. .x86_32_early_logical_apicid = noop_x86_32_early_logical_apicid,
  136. #endif
  137. };