mach_apic.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #ifndef _ASM_X86_MACH_DEFAULT_MACH_APIC_H
  2. #define _ASM_X86_MACH_DEFAULT_MACH_APIC_H
  3. #ifdef CONFIG_X86_LOCAL_APIC
  4. #include <mach_apicdef.h>
  5. #include <asm/smp.h>
  6. #define APIC_DFR_VALUE (APIC_DFR_FLAT)
  7. static inline const struct cpumask *default_target_cpus(void)
  8. {
  9. #ifdef CONFIG_SMP
  10. return cpu_online_mask;
  11. #else
  12. return cpumask_of(0);
  13. #endif
  14. }
  15. #define NO_BALANCE_IRQ (0)
  16. #ifdef CONFIG_X86_64
  17. #include <asm/genapic.h>
  18. #define init_apic_ldr (apic->init_apic_ldr)
  19. #define cpu_mask_to_apicid (apic->cpu_mask_to_apicid)
  20. #define cpu_mask_to_apicid_and (apic->cpu_mask_to_apicid_and)
  21. #define phys_pkg_id (apic->phys_pkg_id)
  22. #define vector_allocation_domain (apic->vector_allocation_domain)
  23. #define read_apic_id() (GET_APIC_ID(apic_read(APIC_ID)))
  24. #define send_IPI_self (apic->send_IPI_self)
  25. #define wakeup_secondary_cpu (apic->wakeup_cpu)
  26. extern void setup_apic_routing(void);
  27. #else
  28. #define wakeup_secondary_cpu wakeup_secondary_cpu_via_init
  29. /*
  30. * Set up the logical destination ID.
  31. *
  32. * Intel recommends to set DFR, LDR and TPR before enabling
  33. * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
  34. * document number 292116). So here it goes...
  35. */
  36. static inline void init_apic_ldr(void)
  37. {
  38. unsigned long val;
  39. apic_write(APIC_DFR, APIC_DFR_VALUE);
  40. val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
  41. val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id());
  42. apic_write(APIC_LDR, val);
  43. }
  44. static inline int default_apic_id_registered(void)
  45. {
  46. return physid_isset(read_apic_id(), phys_cpu_present_map);
  47. }
  48. static inline unsigned int cpu_mask_to_apicid(const struct cpumask *cpumask)
  49. {
  50. return cpumask_bits(cpumask)[0];
  51. }
  52. static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *cpumask,
  53. const struct cpumask *andmask)
  54. {
  55. unsigned long mask1 = cpumask_bits(cpumask)[0];
  56. unsigned long mask2 = cpumask_bits(andmask)[0];
  57. unsigned long mask3 = cpumask_bits(cpu_online_mask)[0];
  58. return (unsigned int)(mask1 & mask2 & mask3);
  59. }
  60. static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
  61. {
  62. return cpuid_apic >> index_msb;
  63. }
  64. static inline void setup_apic_routing(void)
  65. {
  66. #ifdef CONFIG_X86_IO_APIC
  67. printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
  68. "Flat", nr_ioapics);
  69. #endif
  70. }
  71. static inline int apicid_to_node(int logical_apicid)
  72. {
  73. #ifdef CONFIG_SMP
  74. return apicid_2_node[hard_smp_processor_id()];
  75. #else
  76. return 0;
  77. #endif
  78. }
  79. static inline void vector_allocation_domain(int cpu, struct cpumask *retmask)
  80. {
  81. /* Careful. Some cpus do not strictly honor the set of cpus
  82. * specified in the interrupt destination when using lowest
  83. * priority interrupt delivery mode.
  84. *
  85. * In particular there was a hyperthreading cpu observed to
  86. * deliver interrupts to the wrong hyperthread when only one
  87. * hyperthread was specified in the interrupt desitination.
  88. */
  89. *retmask = (cpumask_t) { { [0] = APIC_ALL_CPUS } };
  90. }
  91. #endif
  92. static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
  93. {
  94. return physid_isset(apicid, bitmap);
  95. }
  96. static inline unsigned long check_apicid_present(int bit)
  97. {
  98. return physid_isset(bit, phys_cpu_present_map);
  99. }
  100. static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
  101. {
  102. return phys_map;
  103. }
  104. static inline int multi_timer_check(int apic, int irq)
  105. {
  106. return 0;
  107. }
  108. /* Mapping from cpu number to logical apicid */
  109. static inline int cpu_to_logical_apicid(int cpu)
  110. {
  111. return 1 << cpu;
  112. }
  113. static inline int cpu_present_to_apicid(int mps_cpu)
  114. {
  115. if (mps_cpu < nr_cpu_ids && cpu_present(mps_cpu))
  116. return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
  117. else
  118. return BAD_APICID;
  119. }
  120. static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
  121. {
  122. return physid_mask_of_physid(phys_apicid);
  123. }
  124. static inline void setup_portio_remap(void)
  125. {
  126. }
  127. static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
  128. {
  129. return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map);
  130. }
  131. static inline void enable_apic_mode(void)
  132. {
  133. }
  134. #endif /* CONFIG_X86_LOCAL_APIC */
  135. #endif /* _ASM_X86_MACH_DEFAULT_MACH_APIC_H */