smp.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 <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. extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
  37. void *info, int wait);
  38. #define hard_smp_processor_id() ia64_get_lid()
  39. #ifdef CONFIG_SMP
  40. #define XTP_OFFSET 0x1e0008
  41. #define SMP_IRQ_REDIRECTION (1 << 0)
  42. #define SMP_IPI_REDIRECTION (1 << 1)
  43. #define raw_smp_processor_id() (current_thread_info()->cpu)
  44. extern struct smp_boot_data {
  45. int cpu_count;
  46. int cpu_phys_id[NR_CPUS];
  47. } smp_boot_data __initdata;
  48. extern char no_int_routing __devinitdata;
  49. extern cpumask_t cpu_online_map;
  50. extern cpumask_t cpu_core_map[NR_CPUS];
  51. DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
  52. extern int smp_num_siblings;
  53. extern void __iomem *ipi_base_addr;
  54. extern unsigned char smp_int_redirect;
  55. extern volatile int ia64_cpu_to_sapicid[];
  56. #define cpu_physical_id(i) ia64_cpu_to_sapicid[i]
  57. extern unsigned long ap_wakeup_vector;
  58. /*
  59. * Function to map hard smp processor id to logical id. Slow, so don't use this in
  60. * performance-critical code.
  61. */
  62. static inline int
  63. cpu_logical_id (int cpuid)
  64. {
  65. int i;
  66. for (i = 0; i < NR_CPUS; ++i)
  67. if (cpu_physical_id(i) == cpuid)
  68. break;
  69. return i;
  70. }
  71. /*
  72. * XTP control functions:
  73. * min_xtp : route all interrupts to this CPU
  74. * normal_xtp: nominal XTP value
  75. * max_xtp : never deliver interrupts to this CPU.
  76. */
  77. static inline void
  78. min_xtp (void)
  79. {
  80. if (smp_int_redirect & SMP_IRQ_REDIRECTION)
  81. writeb(0x00, ipi_base_addr + XTP_OFFSET); /* XTP to min */
  82. }
  83. static inline void
  84. normal_xtp (void)
  85. {
  86. if (smp_int_redirect & SMP_IRQ_REDIRECTION)
  87. writeb(0x08, ipi_base_addr + XTP_OFFSET); /* XTP normal */
  88. }
  89. static inline void
  90. max_xtp (void)
  91. {
  92. if (smp_int_redirect & SMP_IRQ_REDIRECTION)
  93. writeb(0x0f, ipi_base_addr + XTP_OFFSET); /* Set XTP to max */
  94. }
  95. /* Upping and downing of CPUs */
  96. extern int __cpu_disable (void);
  97. extern void __cpu_die (unsigned int cpu);
  98. extern void cpu_die (void) __attribute__ ((noreturn));
  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 /* CONFIG_SMP */
  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 */