mach_apic.h 3.4 KB

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