mach_apic.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. #ifdef CONFIG_X86_64
  16. #include <asm/genapic.h>
  17. #define cpu_mask_to_apicid (apic->cpu_mask_to_apicid)
  18. #define cpu_mask_to_apicid_and (apic->cpu_mask_to_apicid_and)
  19. #define phys_pkg_id (apic->phys_pkg_id)
  20. #define read_apic_id() (GET_APIC_ID(apic_read(APIC_ID)))
  21. #define send_IPI_self (apic->send_IPI_self)
  22. #define wakeup_secondary_cpu (apic->wakeup_cpu)
  23. extern void default_setup_apic_routing(void);
  24. #else
  25. #define wakeup_secondary_cpu wakeup_secondary_cpu_via_init
  26. /*
  27. * Set up the logical destination ID.
  28. *
  29. * Intel recommends to set DFR, LDR and TPR before enabling
  30. * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
  31. * document number 292116). So here it goes...
  32. */
  33. static inline void default_init_apic_ldr(void)
  34. {
  35. unsigned long val;
  36. apic_write(APIC_DFR, APIC_DFR_VALUE);
  37. val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
  38. val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id());
  39. apic_write(APIC_LDR, val);
  40. }
  41. static inline int default_apic_id_registered(void)
  42. {
  43. return physid_isset(read_apic_id(), phys_cpu_present_map);
  44. }
  45. static inline unsigned int cpu_mask_to_apicid(const struct cpumask *cpumask)
  46. {
  47. return cpumask_bits(cpumask)[0];
  48. }
  49. static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *cpumask,
  50. const struct cpumask *andmask)
  51. {
  52. unsigned long mask1 = cpumask_bits(cpumask)[0];
  53. unsigned long mask2 = cpumask_bits(andmask)[0];
  54. unsigned long mask3 = cpumask_bits(cpu_online_mask)[0];
  55. return (unsigned int)(mask1 & mask2 & mask3);
  56. }
  57. static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
  58. {
  59. return cpuid_apic >> index_msb;
  60. }
  61. static inline void default_setup_apic_routing(void)
  62. {
  63. #ifdef CONFIG_X86_IO_APIC
  64. printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
  65. "Flat", nr_ioapics);
  66. #endif
  67. }
  68. static inline int apicid_to_node(int logical_apicid)
  69. {
  70. #ifdef CONFIG_SMP
  71. return apicid_2_node[hard_smp_processor_id()];
  72. #else
  73. return 0;
  74. #endif
  75. }
  76. #endif
  77. static inline unsigned long default_check_apicid_used(physid_mask_t bitmap, int apicid)
  78. {
  79. return physid_isset(apicid, bitmap);
  80. }
  81. static inline unsigned long default_check_apicid_present(int bit)
  82. {
  83. return physid_isset(bit, phys_cpu_present_map);
  84. }
  85. static inline physid_mask_t default_ioapic_phys_id_map(physid_mask_t phys_map)
  86. {
  87. return phys_map;
  88. }
  89. /* Mapping from cpu number to logical apicid */
  90. static inline int cpu_to_logical_apicid(int cpu)
  91. {
  92. return 1 << cpu;
  93. }
  94. static inline int cpu_present_to_apicid(int mps_cpu)
  95. {
  96. if (mps_cpu < nr_cpu_ids && cpu_present(mps_cpu))
  97. return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
  98. else
  99. return BAD_APICID;
  100. }
  101. static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
  102. {
  103. return physid_mask_of_physid(phys_apicid);
  104. }
  105. static inline void setup_portio_remap(void)
  106. {
  107. }
  108. static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
  109. {
  110. return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map);
  111. }
  112. static inline void enable_apic_mode(void)
  113. {
  114. }
  115. #endif /* CONFIG_X86_LOCAL_APIC */
  116. #endif /* _ASM_X86_MACH_DEFAULT_MACH_APIC_H */