smp.h 3.1 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 <asm/bitops.h>
  17. #include <asm/io.h>
  18. #include <asm/param.h>
  19. #include <asm/processor.h>
  20. #include <asm/ptrace.h>
  21. static inline unsigned int
  22. ia64_get_lid (void)
  23. {
  24. union {
  25. struct {
  26. unsigned long reserved : 16;
  27. unsigned long eid : 8;
  28. unsigned long id : 8;
  29. unsigned long ignored : 32;
  30. } f;
  31. unsigned long bits;
  32. } lid;
  33. lid.bits = ia64_getreg(_IA64_REG_CR_LID);
  34. return lid.f.id << 8 | lid.f.eid;
  35. }
  36. #ifdef CONFIG_SMP
  37. #define XTP_OFFSET 0x1e0008
  38. #define SMP_IRQ_REDIRECTION (1 << 0)
  39. #define SMP_IPI_REDIRECTION (1 << 1)
  40. #define raw_smp_processor_id() (current_thread_info()->cpu)
  41. extern struct smp_boot_data {
  42. int cpu_count;
  43. int cpu_phys_id[NR_CPUS];
  44. } smp_boot_data __initdata;
  45. extern char no_int_routing __devinitdata;
  46. extern cpumask_t cpu_online_map;
  47. extern cpumask_t cpu_core_map[NR_CPUS];
  48. extern cpumask_t cpu_sibling_map[NR_CPUS];
  49. extern int smp_num_siblings;
  50. extern int smp_num_cpucores;
  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. #define hard_smp_processor_id() ia64_get_lid()
  94. /* Upping and downing of CPUs */
  95. extern int __cpu_disable (void);
  96. extern void __cpu_die (unsigned int cpu);
  97. extern void cpu_die (void) __attribute__ ((noreturn));
  98. extern int __cpu_up (unsigned int cpu);
  99. extern void __init smp_build_cpu_map(void);
  100. extern void __init init_smp_config (void);
  101. extern void smp_do_timer (struct pt_regs *regs);
  102. extern void smp_send_reschedule (int cpu);
  103. extern void lock_ipi_calllock(void);
  104. extern void unlock_ipi_calllock(void);
  105. extern void identify_siblings (struct cpuinfo_ia64 *);
  106. extern int is_multithreading_enabled(void);
  107. #else
  108. #define cpu_logical_id(i) 0
  109. #define cpu_physical_id(i) ia64_get_lid()
  110. #endif /* CONFIG_SMP */
  111. #endif /* _ASM_IA64_SMP_H */