apic.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef __ASM_MACH_APIC_H
  2. #define __ASM_MACH_APIC_H
  3. #define xapic_phys_to_log_apicid(cpu) (per_cpu(x86_bios_cpu_apicid, cpu))
  4. #define esr_disable (1)
  5. static inline int apic_id_registered(void)
  6. {
  7. return (1);
  8. }
  9. static inline cpumask_t target_cpus(void)
  10. {
  11. #ifdef CONFIG_SMP
  12. return cpu_online_map;
  13. #else
  14. return cpumask_of_cpu(0);
  15. #endif
  16. }
  17. #undef APIC_DEST_LOGICAL
  18. #define APIC_DEST_LOGICAL 0
  19. #define APIC_DFR_VALUE (APIC_DFR_FLAT)
  20. #define INT_DELIVERY_MODE (dest_Fixed)
  21. #define INT_DEST_MODE (0) /* phys delivery to target proc */
  22. #define NO_BALANCE_IRQ (0)
  23. #define WAKE_SECONDARY_VIA_INIT
  24. static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
  25. {
  26. return (0);
  27. }
  28. static inline unsigned long check_apicid_present(int bit)
  29. {
  30. return (1);
  31. }
  32. static inline unsigned long calculate_ldr(int cpu)
  33. {
  34. unsigned long val, id;
  35. val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
  36. id = xapic_phys_to_log_apicid(cpu);
  37. val |= SET_APIC_LOGICAL_ID(id);
  38. return val;
  39. }
  40. /*
  41. * Set up the logical destination ID.
  42. *
  43. * Intel recommends to set DFR, LDR and TPR before enabling
  44. * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
  45. * document number 292116). So here it goes...
  46. */
  47. static inline void init_apic_ldr(void)
  48. {
  49. unsigned long val;
  50. int cpu = smp_processor_id();
  51. apic_write(APIC_DFR, APIC_DFR_VALUE);
  52. val = calculate_ldr(cpu);
  53. apic_write(APIC_LDR, val);
  54. }
  55. static inline void setup_apic_routing(void)
  56. {
  57. printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
  58. "Physflat", nr_ioapics);
  59. }
  60. static inline int multi_timer_check(int apic, int irq)
  61. {
  62. return (0);
  63. }
  64. static inline int apicid_to_node(int logical_apicid)
  65. {
  66. return apicid_2_node[hard_smp_processor_id()];
  67. }
  68. static inline int cpu_present_to_apicid(int mps_cpu)
  69. {
  70. if (mps_cpu < NR_CPUS)
  71. return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
  72. return BAD_APICID;
  73. }
  74. static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
  75. {
  76. return physid_mask_of_physid(phys_apicid);
  77. }
  78. extern u8 cpu_2_logical_apicid[];
  79. /* Mapping from cpu number to logical apicid */
  80. static inline int cpu_to_logical_apicid(int cpu)
  81. {
  82. if (cpu >= NR_CPUS)
  83. return BAD_APICID;
  84. return cpu_physical_id(cpu);
  85. }
  86. static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
  87. {
  88. /* For clustered we don't have a good way to do this yet - hack */
  89. return physids_promote(0xFFL);
  90. }
  91. static inline void setup_portio_remap(void)
  92. {
  93. }
  94. static inline void enable_apic_mode(void)
  95. {
  96. }
  97. static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
  98. {
  99. return (1);
  100. }
  101. /* As we are using single CPU as destination, pick only one CPU here */
  102. static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
  103. {
  104. int cpu;
  105. int apicid;
  106. cpu = first_cpu(cpumask);
  107. apicid = cpu_to_logical_apicid(cpu);
  108. return apicid;
  109. }
  110. static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
  111. {
  112. return cpuid_apic >> index_msb;
  113. }
  114. #endif /* __ASM_MACH_APIC_H */