mach_apic.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #ifndef __ASM_MACH_APIC_H
  2. #define __ASM_MACH_APIC_H
  3. #include <asm/io.h>
  4. #include <linux/mmzone.h>
  5. #include <linux/nodemask.h>
  6. #define APIC_DFR_VALUE (APIC_DFR_CLUSTER)
  7. static inline cpumask_t target_cpus(void)
  8. {
  9. return CPU_MASK_ALL;
  10. }
  11. #define TARGET_CPUS (target_cpus())
  12. #define NO_BALANCE_IRQ (1)
  13. #define esr_disable (1)
  14. #define INT_DELIVERY_MODE dest_LowestPrio
  15. #define INT_DEST_MODE 0 /* physical delivery on LOCAL quad */
  16. #define check_apicid_used(bitmap, apicid) physid_isset(apicid, bitmap)
  17. #define check_apicid_present(bit) physid_isset(bit, phys_cpu_present_map)
  18. #define apicid_cluster(apicid) (apicid & 0xF0)
  19. static inline int apic_id_registered(void)
  20. {
  21. return 1;
  22. }
  23. static inline void init_apic_ldr(void)
  24. {
  25. /* Already done in NUMA-Q firmware */
  26. }
  27. static inline void setup_apic_routing(void)
  28. {
  29. printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
  30. "NUMA-Q", nr_ioapics);
  31. }
  32. /*
  33. * Skip adding the timer int on secondary nodes, which causes
  34. * a small but painful rift in the time-space continuum.
  35. */
  36. static inline int multi_timer_check(int apic, int irq)
  37. {
  38. return apic != 0 && irq == 0;
  39. }
  40. static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
  41. {
  42. /* We don't have a good way to do this yet - hack */
  43. return physids_promote(0xFUL);
  44. }
  45. /* Mapping from cpu number to logical apicid */
  46. extern u8 cpu_2_logical_apicid[];
  47. static inline int cpu_to_logical_apicid(int cpu)
  48. {
  49. if (cpu >= NR_CPUS)
  50. return BAD_APICID;
  51. return (int)cpu_2_logical_apicid[cpu];
  52. }
  53. /*
  54. * Supporting over 60 cpus on NUMA-Q requires a locality-dependent
  55. * cpu to APIC ID relation to properly interact with the intelligent
  56. * mode of the cluster controller.
  57. */
  58. static inline int cpu_present_to_apicid(int mps_cpu)
  59. {
  60. if (mps_cpu < 60)
  61. return ((mps_cpu >> 2) << 4) | (1 << (mps_cpu & 0x3));
  62. else
  63. return BAD_APICID;
  64. }
  65. static inline int generate_logical_apicid(int quad, int phys_apicid)
  66. {
  67. return (quad << 4) + (phys_apicid ? phys_apicid << 1 : 1);
  68. }
  69. static inline int apicid_to_node(int logical_apicid)
  70. {
  71. return logical_apicid >> 4;
  72. }
  73. static inline physid_mask_t apicid_to_cpu_present(int logical_apicid)
  74. {
  75. int node = apicid_to_node(logical_apicid);
  76. int cpu = __ffs(logical_apicid & 0xf);
  77. return physid_mask_of_physid(cpu + 4*node);
  78. }
  79. static inline int mpc_apic_id(struct mpc_config_processor *m,
  80. struct mpc_config_translation *translation_record)
  81. {
  82. int quad = translation_record->trans_quad;
  83. int logical_apicid = generate_logical_apicid(quad, m->mpc_apicid);
  84. printk("Processor #%d %ld:%ld APIC version %d (quad %d, apic %d)\n",
  85. m->mpc_apicid,
  86. (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
  87. (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
  88. m->mpc_apicver, quad, logical_apicid);
  89. return logical_apicid;
  90. }
  91. static inline void setup_portio_remap(void)
  92. {
  93. int num_quads = num_online_nodes();
  94. if (num_quads <= 1)
  95. return;
  96. printk("Remapping cross-quad port I/O for %d quads\n", num_quads);
  97. xquad_portio = ioremap(XQUAD_PORTIO_BASE, num_quads*XQUAD_PORTIO_QUAD);
  98. printk("xquad_portio vaddr 0x%08lx, len %08lx\n",
  99. (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
  100. }
  101. static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
  102. {
  103. return (1);
  104. }
  105. static inline void enable_apic_mode(void)
  106. {
  107. }
  108. /*
  109. * We use physical apicids here, not logical, so just return the default
  110. * physical broadcast to stop people from breaking us
  111. */
  112. static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
  113. {
  114. return (int) 0xF;
  115. }
  116. /* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */
  117. static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
  118. {
  119. return cpuid_apic >> index_msb;
  120. }
  121. #endif /* __ASM_MACH_APIC_H */