mach_apic.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #ifndef __ASM_MACH_APIC_H
  2. #define __ASM_MACH_APIC_H
  3. #include <mach_apicdef.h>
  4. #include <asm/smp.h>
  5. #define APIC_DFR_VALUE (APIC_DFR_FLAT)
  6. static inline cpumask_t target_cpus(void)
  7. {
  8. #ifdef CONFIG_SMP
  9. return cpu_online_map;
  10. #else
  11. return cpumask_of_cpu(0);
  12. #endif
  13. }
  14. #define TARGET_CPUS (target_cpus())
  15. #define NO_BALANCE_IRQ (0)
  16. #define esr_disable (0)
  17. #define INT_DELIVERY_MODE dest_LowestPrio
  18. #define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */
  19. static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
  20. {
  21. return physid_isset(apicid, bitmap);
  22. }
  23. static inline unsigned long check_apicid_present(int bit)
  24. {
  25. return physid_isset(bit, phys_cpu_present_map);
  26. }
  27. /*
  28. * Set up the logical destination ID.
  29. *
  30. * Intel recommends to set DFR, LDR and TPR before enabling
  31. * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
  32. * document number 292116). So here it goes...
  33. */
  34. static inline void init_apic_ldr(void)
  35. {
  36. unsigned long val;
  37. apic_write_around(APIC_DFR, APIC_DFR_VALUE);
  38. val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
  39. val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id());
  40. apic_write_around(APIC_LDR, val);
  41. }
  42. static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
  43. {
  44. return phys_map;
  45. }
  46. static inline void setup_apic_routing(void)
  47. {
  48. printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
  49. "Flat", nr_ioapics);
  50. }
  51. static inline int multi_timer_check(int apic, int irq)
  52. {
  53. return 0;
  54. }
  55. static inline int apicid_to_node(int logical_apicid)
  56. {
  57. return 0;
  58. }
  59. /* Mapping from cpu number to logical apicid */
  60. static inline int cpu_to_logical_apicid(int cpu)
  61. {
  62. return 1 << cpu;
  63. }
  64. static inline int cpu_present_to_apicid(int mps_cpu)
  65. {
  66. if (mps_cpu < get_physical_broadcast())
  67. return mps_cpu;
  68. else
  69. return BAD_APICID;
  70. }
  71. static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
  72. {
  73. return physid_mask_of_physid(phys_apicid);
  74. }
  75. static inline int mpc_apic_id(struct mpc_config_processor *m,
  76. struct mpc_config_translation *translation_record)
  77. {
  78. printk("Processor #%d %ld:%ld APIC version %d\n",
  79. m->mpc_apicid,
  80. (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
  81. (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
  82. m->mpc_apicver);
  83. return (m->mpc_apicid);
  84. }
  85. static inline void setup_portio_remap(void)
  86. {
  87. }
  88. static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
  89. {
  90. return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map);
  91. }
  92. static inline int apic_id_registered(void)
  93. {
  94. return physid_isset(GET_APIC_ID(apic_read(APIC_ID)), phys_cpu_present_map);
  95. }
  96. static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
  97. {
  98. return cpus_addr(cpumask)[0];
  99. }
  100. static inline void enable_apic_mode(void)
  101. {
  102. }
  103. static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
  104. {
  105. return cpuid_apic >> index_msb;
  106. }
  107. #endif /* __ASM_MACH_APIC_H */