mach_apic.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #ifndef __ASM_MACH_APIC_H
  2. #define __ASM_MACH_APIC_H
  3. #include <asm/smp.h>
  4. #define SEQUENTIAL_APICID
  5. #ifdef SEQUENTIAL_APICID
  6. #define xapic_phys_to_log_apicid(phys_apic) ( (1ul << ((phys_apic) & 0x3)) |\
  7. ((phys_apic<<2) & (~0xf)) )
  8. #elif CLUSTERED_APICID
  9. #define xapic_phys_to_log_apicid(phys_apic) ( (1ul << ((phys_apic) & 0x3)) |\
  10. ((phys_apic) & (~0xf)) )
  11. #endif
  12. #define NO_BALANCE_IRQ (1)
  13. #define esr_disable (1)
  14. #define NO_IOAPIC_CHECK (0)
  15. static inline int apic_id_registered(void)
  16. {
  17. return (1);
  18. }
  19. #define APIC_DFR_VALUE (APIC_DFR_CLUSTER)
  20. /* Round robin the irqs amoung the online cpus */
  21. static inline cpumask_t target_cpus(void)
  22. {
  23. static unsigned long cpu = NR_CPUS;
  24. do {
  25. if (cpu >= NR_CPUS)
  26. cpu = first_cpu(cpu_online_map);
  27. else
  28. cpu = next_cpu(cpu, cpu_online_map);
  29. } while (cpu >= NR_CPUS);
  30. return cpumask_of_cpu(cpu);
  31. }
  32. #define TARGET_CPUS (target_cpus())
  33. #define INT_DELIVERY_MODE dest_Fixed
  34. #define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */
  35. static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
  36. {
  37. return 0;
  38. }
  39. /* we don't use the phys_cpu_present_map to indicate apicid presence */
  40. static inline unsigned long check_apicid_present(int bit)
  41. {
  42. return 1;
  43. }
  44. #define apicid_cluster(apicid) (apicid & 0xF0)
  45. static inline unsigned long calculate_ldr(unsigned long old)
  46. {
  47. unsigned long id;
  48. id = xapic_phys_to_log_apicid(hard_smp_processor_id());
  49. return ((old & ~APIC_LDR_MASK) | SET_APIC_LOGICAL_ID(id));
  50. }
  51. /*
  52. * Set up the logical destination ID.
  53. *
  54. * Intel recommends to set DFR, LDR and TPR before enabling
  55. * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
  56. * document number 292116). So here it goes...
  57. */
  58. static inline void init_apic_ldr(void)
  59. {
  60. unsigned long val;
  61. apic_write_around(APIC_DFR, APIC_DFR_VALUE);
  62. val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
  63. val = calculate_ldr(val);
  64. apic_write_around(APIC_LDR, val);
  65. }
  66. static inline void clustered_apic_check(void)
  67. {
  68. printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
  69. "Cluster", nr_ioapics);
  70. }
  71. static inline int multi_timer_check(int apic, int irq)
  72. {
  73. return 0;
  74. }
  75. static inline int apicid_to_node(int logical_apicid)
  76. {
  77. return 0;
  78. }
  79. extern u8 bios_cpu_apicid[];
  80. static inline int cpu_present_to_apicid(int mps_cpu)
  81. {
  82. if (mps_cpu < NR_CPUS)
  83. return (int)bios_cpu_apicid[mps_cpu];
  84. else
  85. return BAD_APICID;
  86. }
  87. static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
  88. {
  89. return physid_mask_of_physid(phys_apicid);
  90. }
  91. extern u8 cpu_2_logical_apicid[];
  92. /* Mapping from cpu number to logical apicid */
  93. static inline int cpu_to_logical_apicid(int cpu)
  94. {
  95. if (cpu >= NR_CPUS)
  96. return BAD_APICID;
  97. return (int)cpu_2_logical_apicid[cpu];
  98. }
  99. static inline int mpc_apic_id(struct mpc_config_processor *m,
  100. struct mpc_config_translation *translation_record)
  101. {
  102. printk("Processor #%d %ld:%ld APIC version %d\n",
  103. m->mpc_apicid,
  104. (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
  105. (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
  106. m->mpc_apicver);
  107. return m->mpc_apicid;
  108. }
  109. static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
  110. {
  111. /* For clustered we don't have a good way to do this yet - hack */
  112. return physids_promote(0xFUL);
  113. }
  114. #define WAKE_SECONDARY_VIA_INIT
  115. static inline void setup_portio_remap(void)
  116. {
  117. }
  118. static inline void enable_apic_mode(void)
  119. {
  120. }
  121. static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
  122. {
  123. return (1);
  124. }
  125. /* As we are using single CPU as destination, pick only one CPU here */
  126. static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
  127. {
  128. int cpu;
  129. int apicid;
  130. cpu = first_cpu(cpumask);
  131. apicid = cpu_to_logical_apicid(cpu);
  132. return apicid;
  133. }
  134. static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
  135. {
  136. return cpuid_apic >> index_msb;
  137. }
  138. #endif /* __ASM_MACH_APIC_H */