apic_noop.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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/module.h>
  14. #include <linux/string.h>
  15. #include <linux/kernel.h>
  16. #include <linux/ctype.h>
  17. #include <linux/init.h>
  18. #include <linux/errno.h>
  19. #include <asm/fixmap.h>
  20. #include <asm/mpspec.h>
  21. #include <asm/apicdef.h>
  22. #include <asm/apic.h>
  23. #include <asm/setup.h>
  24. #include <linux/smp.h>
  25. #include <asm/ipi.h>
  26. #include <linux/interrupt.h>
  27. #include <asm/acpi.h>
  28. #include <asm/e820.h>
  29. static void noop_init_apic_ldr(void) { }
  30. static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector) { }
  31. static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) { }
  32. static void noop_send_IPI_allbutself(int vector) { }
  33. static void noop_send_IPI_all(int vector) { }
  34. static void noop_send_IPI_self(int vector) { }
  35. static void noop_apic_wait_icr_idle(void) { }
  36. static void noop_apic_icr_write(u32 low, u32 id) { }
  37. static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip)
  38. {
  39. return -1;
  40. }
  41. static u32 noop_safe_apic_wait_icr_idle(void)
  42. {
  43. return 0;
  44. }
  45. static u64 noop_apic_icr_read(void)
  46. {
  47. return 0;
  48. }
  49. static physid_mask_t noop_ioapic_phys_id_map(physid_mask_t phys_map)
  50. {
  51. return phys_map;
  52. }
  53. static int noop_cpu_to_logical_apicid(int cpu)
  54. {
  55. return 0;
  56. }
  57. static int noop_phys_pkg_id(int cpuid_apic, int index_msb)
  58. {
  59. return 0;
  60. }
  61. static unsigned int noop_get_apic_id(unsigned long x)
  62. {
  63. return 0;
  64. }
  65. static int noop_probe(void)
  66. {
  67. /*
  68. * NOOP apic should not ever be
  69. * enabled via probe routine
  70. */
  71. return 0;
  72. }
  73. static int noop_apic_id_registered(void)
  74. {
  75. /*
  76. * if we would be really "pedantic"
  77. * we should pass read_apic_id() here
  78. * but since NOOP suppose APIC ID = 0
  79. * lets save a few cycles
  80. */
  81. return physid_isset(0, phys_cpu_present_map);
  82. }
  83. static const struct cpumask *noop_target_cpus(void)
  84. {
  85. /* only BSP here */
  86. return cpumask_of(0);
  87. }
  88. static unsigned long noop_check_apicid_used(physid_mask_t bitmap, int apicid)
  89. {
  90. return physid_isset(apicid, bitmap);
  91. }
  92. static unsigned long noop_check_apicid_present(int bit)
  93. {
  94. return physid_isset(bit, phys_cpu_present_map);
  95. }
  96. static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask)
  97. {
  98. if (cpu != 0)
  99. pr_warning("APIC: Vector allocated for non-BSP cpu\n");
  100. cpumask_clear(retmask);
  101. cpumask_set_cpu(cpu, retmask);
  102. }
  103. int noop_apicid_to_node(int logical_apicid)
  104. {
  105. /* we're always on node 0 */
  106. return 0;
  107. }
  108. static u32 noop_apic_read(u32 reg)
  109. {
  110. WARN_ON_ONCE((cpu_has_apic && !disable_apic));
  111. return 0;
  112. }
  113. static void noop_apic_write(u32 reg, u32 v)
  114. {
  115. WARN_ON_ONCE((cpu_has_apic || !disable_apic));
  116. }
  117. struct apic apic_noop = {
  118. .name = "noop",
  119. .probe = noop_probe,
  120. .acpi_madt_oem_check = NULL,
  121. .apic_id_registered = noop_apic_id_registered,
  122. .irq_delivery_mode = dest_LowestPrio,
  123. /* logical delivery broadcast to all CPUs: */
  124. .irq_dest_mode = 1,
  125. .target_cpus = noop_target_cpus,
  126. .disable_esr = 0,
  127. .dest_logical = APIC_DEST_LOGICAL,
  128. .check_apicid_used = noop_check_apicid_used,
  129. .check_apicid_present = noop_check_apicid_present,
  130. .vector_allocation_domain = noop_vector_allocation_domain,
  131. .init_apic_ldr = noop_init_apic_ldr,
  132. .ioapic_phys_id_map = noop_ioapic_phys_id_map,
  133. .setup_apic_routing = NULL,
  134. .multi_timer_check = NULL,
  135. .apicid_to_node = noop_apicid_to_node,
  136. .cpu_to_logical_apicid = noop_cpu_to_logical_apicid,
  137. .cpu_present_to_apicid = default_cpu_present_to_apicid,
  138. #ifdef CONFIG_X86_32
  139. .apicid_to_cpu_present = default_apicid_to_cpu_present,
  140. #else
  141. .apicid_to_cpu_present = NULL,
  142. #endif
  143. .setup_portio_remap = NULL,
  144. .check_phys_apicid_present = default_check_phys_apicid_present,
  145. .enable_apic_mode = NULL,
  146. .phys_pkg_id = noop_phys_pkg_id,
  147. .mps_oem_check = NULL,
  148. .get_apic_id = noop_get_apic_id,
  149. .set_apic_id = NULL,
  150. .apic_id_mask = 0x0F << 24,
  151. .cpu_mask_to_apicid = default_cpu_mask_to_apicid,
  152. .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
  153. .send_IPI_mask = noop_send_IPI_mask,
  154. .send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself,
  155. .send_IPI_allbutself = noop_send_IPI_allbutself,
  156. .send_IPI_all = noop_send_IPI_all,
  157. .send_IPI_self = noop_send_IPI_self,
  158. .wakeup_secondary_cpu = noop_wakeup_secondary_cpu,
  159. /* should be safe */
  160. .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
  161. .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
  162. .wait_for_init_deassert = NULL,
  163. .smp_callin_clear_local_apic = NULL,
  164. .inquire_remote_apic = NULL,
  165. .read = noop_apic_read,
  166. .write = noop_apic_write,
  167. .icr_read = noop_apic_icr_read,
  168. .icr_write = noop_apic_icr_write,
  169. .wait_icr_idle = noop_apic_wait_icr_idle,
  170. .safe_wait_icr_idle = noop_safe_apic_wait_icr_idle,
  171. };