mach_apic.h 3.7 KB

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