smp.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * SMP Support
  3. *
  4. * Copyright (C) 1999 VA Linux Systems
  5. * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
  6. * (c) Copyright 2001-2003, 2005 Hewlett-Packard Development Company, L.P.
  7. * David Mosberger-Tang <davidm@hpl.hp.com>
  8. * Bjorn Helgaas <bjorn.helgaas@hp.com>
  9. */
  10. #ifndef _ASM_IA64_SMP_H
  11. #define _ASM_IA64_SMP_H
  12. #include <linux/init.h>
  13. #include <linux/threads.h>
  14. #include <linux/kernel.h>
  15. #include <linux/cpumask.h>
  16. #include <linux/bitops.h>
  17. #include <linux/irqreturn.h>
  18. #include <asm/io.h>
  19. #include <asm/param.h>
  20. #include <asm/processor.h>
  21. #include <asm/ptrace.h>
  22. static inline unsigned int
  23. ia64_get_lid (void)
  24. {
  25. union {
  26. struct {
  27. unsigned long reserved : 16;
  28. unsigned long eid : 8;
  29. unsigned long id : 8;
  30. unsigned long ignored : 32;
  31. } f;
  32. unsigned long bits;
  33. } lid;
  34. lid.bits = ia64_getreg(_IA64_REG_CR_LID);
  35. return lid.f.id << 8 | lid.f.eid;
  36. }
  37. #define hard_smp_processor_id() ia64_get_lid()
  38. #ifdef CONFIG_SMP
  39. #define XTP_OFFSET 0x1e0008
  40. #define SMP_IRQ_REDIRECTION (1 << 0)
  41. #define SMP_IPI_REDIRECTION (1 << 1)
  42. #define raw_smp_processor_id() (current_thread_info()->cpu)
  43. extern struct smp_boot_data {
  44. int cpu_count;
  45. int cpu_phys_id[NR_CPUS];
  46. } smp_boot_data __initdata;
  47. extern char no_int_routing;
  48. extern cpumask_t cpu_core_map[NR_CPUS];
  49. DECLARE_PER_CPU_SHARED_ALIGNED(cpumask_t, cpu_sibling_map);
  50. extern int smp_num_siblings;
  51. extern void __iomem *ipi_base_addr;
  52. extern unsigned char smp_int_redirect;
  53. extern volatile int ia64_cpu_to_sapicid[];
  54. #define cpu_physical_id(i) ia64_cpu_to_sapicid[i]
  55. extern unsigned long ap_wakeup_vector;
  56. /*
  57. * Function to map hard smp processor id to logical id. Slow, so don't use this in
  58. * performance-critical code.
  59. */
  60. static inline int
  61. cpu_logical_id (int cpuid)
  62. {
  63. int i;
  64. for (i = 0; i < NR_CPUS; ++i)
  65. if (cpu_physical_id(i) == cpuid)
  66. break;
  67. return i;
  68. }
  69. /*
  70. * XTP control functions:
  71. * min_xtp : route all interrupts to this CPU
  72. * normal_xtp: nominal XTP value
  73. * max_xtp : never deliver interrupts to this CPU.
  74. */
  75. static inline void
  76. min_xtp (void)
  77. {
  78. if (smp_int_redirect & SMP_IRQ_REDIRECTION)
  79. writeb(0x00, ipi_base_addr + XTP_OFFSET); /* XTP to min */
  80. }
  81. static inline void
  82. normal_xtp (void)
  83. {
  84. if (smp_int_redirect & SMP_IRQ_REDIRECTION)
  85. writeb(0x08, ipi_base_addr + XTP_OFFSET); /* XTP normal */
  86. }
  87. static inline void
  88. max_xtp (void)
  89. {
  90. if (smp_int_redirect & SMP_IRQ_REDIRECTION)
  91. writeb(0x0f, ipi_base_addr + XTP_OFFSET); /* Set XTP to max */
  92. }
  93. /* Upping and downing of CPUs */
  94. extern int __cpu_disable (void);
  95. extern void __cpu_die (unsigned int cpu);
  96. extern void cpu_die (void) __attribute__ ((noreturn));
  97. extern void __init smp_build_cpu_map(void);
  98. extern void __init init_smp_config (void);
  99. extern void smp_do_timer (struct pt_regs *regs);
  100. extern irqreturn_t handle_IPI(int irq, void *dev_id);
  101. extern void smp_send_reschedule (int cpu);
  102. extern void identify_siblings (struct cpuinfo_ia64 *);
  103. extern int is_multithreading_enabled(void);
  104. extern void arch_send_call_function_single_ipi(int cpu);
  105. extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
  106. #else /* CONFIG_SMP */
  107. #define cpu_logical_id(i) 0
  108. #define cpu_physical_id(i) ia64_get_lid()
  109. #endif /* CONFIG_SMP */
  110. #endif /* _ASM_IA64_SMP_H */