apic.h 3.1 KB

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