mach_apic.h 3.1 KB

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