mach_apic.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 cpumask_t target_cpus(void)
  8. {
  9. #ifdef CONFIG_SMP
  10. return cpu_online_map;
  11. #else
  12. return cpumask_of_cpu(0);
  13. #endif
  14. }
  15. #define NO_BALANCE_IRQ (0)
  16. #define esr_disable (0)
  17. #ifdef CONFIG_X86_64
  18. #include <asm/genapic.h>
  19. #define INT_DELIVERY_MODE (genapic->int_delivery_mode)
  20. #define INT_DEST_MODE (genapic->int_dest_mode)
  21. #define TARGET_CPUS (genapic->target_cpus())
  22. #define apic_id_registered (genapic->apic_id_registered)
  23. #define init_apic_ldr (genapic->init_apic_ldr)
  24. #define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
  25. #define phys_pkg_id (genapic->phys_pkg_id)
  26. #define vector_allocation_domain (genapic->vector_allocation_domain)
  27. extern void setup_apic_routing(void);
  28. #else
  29. #define INT_DELIVERY_MODE dest_LowestPrio
  30. #define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */
  31. #define TARGET_CPUS (target_cpus())
  32. /*
  33. * Set up the logical destination ID.
  34. *
  35. * Intel recommends to set DFR, LDR and TPR before enabling
  36. * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
  37. * document number 292116). So here it goes...
  38. */
  39. static inline void init_apic_ldr(void)
  40. {
  41. unsigned long val;
  42. apic_write(APIC_DFR, APIC_DFR_VALUE);
  43. val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
  44. val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id());
  45. apic_write(APIC_LDR, val);
  46. }
  47. static inline int apic_id_registered(void)
  48. {
  49. return physid_isset(GET_APIC_ID(read_apic_id()), phys_cpu_present_map);
  50. }
  51. static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
  52. {
  53. return cpus_addr(cpumask)[0];
  54. }
  55. static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
  56. {
  57. return cpuid_apic >> index_msb;
  58. }
  59. static inline void setup_apic_routing(void)
  60. {
  61. #ifdef CONFIG_X86_IO_APIC
  62. printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
  63. "Flat", nr_ioapics);
  64. #endif
  65. }
  66. static inline int apicid_to_node(int logical_apicid)
  67. {
  68. #ifdef CONFIG_SMP
  69. return apicid_2_node[hard_smp_processor_id()];
  70. #else
  71. return 0;
  72. #endif
  73. }
  74. #endif
  75. static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
  76. {
  77. return physid_isset(apicid, bitmap);
  78. }
  79. static inline unsigned long check_apicid_present(int bit)
  80. {
  81. return physid_isset(bit, phys_cpu_present_map);
  82. }
  83. static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
  84. {
  85. return phys_map;
  86. }
  87. static inline int multi_timer_check(int apic, int irq)
  88. {
  89. return 0;
  90. }
  91. /* Mapping from cpu number to logical apicid */
  92. static inline int cpu_to_logical_apicid(int cpu)
  93. {
  94. return 1 << cpu;
  95. }
  96. static inline int cpu_present_to_apicid(int mps_cpu)
  97. {
  98. if (mps_cpu < NR_CPUS && cpu_present(mps_cpu))
  99. return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
  100. else
  101. return BAD_APICID;
  102. }
  103. static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
  104. {
  105. return physid_mask_of_physid(phys_apicid);
  106. }
  107. static inline void setup_portio_remap(void)
  108. {
  109. }
  110. static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
  111. {
  112. return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map);
  113. }
  114. static inline void enable_apic_mode(void)
  115. {
  116. }
  117. #endif /* CONFIG_X86_LOCAL_APIC */
  118. #endif /* ASM_X86__MACH_DEFAULT__MACH_APIC_H */