smp.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General
  3. * Public License. See the file "COPYING" in the main directory of this
  4. * archive for more details.
  5. *
  6. * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com)
  7. * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
  8. * Copyright (C) 2000, 2001, 2002 Ralf Baechle
  9. * Copyright (C) 2000, 2001 Broadcom Corporation
  10. */
  11. #ifndef __ASM_SMP_H
  12. #define __ASM_SMP_H
  13. #ifdef CONFIG_SMP
  14. #include <linux/bitops.h>
  15. #include <linux/linkage.h>
  16. #include <linux/threads.h>
  17. #include <linux/cpumask.h>
  18. #include <asm/atomic.h>
  19. extern int smp_num_siblings;
  20. extern cpumask_t cpu_sibling_map[];
  21. #define raw_smp_processor_id() (current_thread_info()->cpu)
  22. /* Map from cpu id to sequential logical cpu number. This will only
  23. not be idempotent when cpus failed to come on-line. */
  24. extern int __cpu_number_map[NR_CPUS];
  25. #define cpu_number_map(cpu) __cpu_number_map[cpu]
  26. /* The reverse map from sequential logical cpu number to cpu id. */
  27. extern int __cpu_logical_map[NR_CPUS];
  28. #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
  29. #define NO_PROC_ID (-1)
  30. struct call_data_struct {
  31. void (*func)(void *);
  32. void *info;
  33. atomic_t started;
  34. atomic_t finished;
  35. int wait;
  36. };
  37. extern struct call_data_struct *call_data;
  38. #define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */
  39. #define SMP_CALL_FUNCTION 0x2
  40. extern cpumask_t phys_cpu_present_map;
  41. #define cpu_possible_map phys_cpu_present_map
  42. /*
  43. * These are defined by the board-specific code.
  44. */
  45. /*
  46. * Cause the function described by call_data to be executed on the passed
  47. * cpu. When the function has finished, increment the finished field of
  48. * call_data.
  49. */
  50. extern void core_send_ipi(int cpu, unsigned int action);
  51. static inline void core_send_ipi_mask(cpumask_t mask, unsigned int action)
  52. {
  53. unsigned int i;
  54. for_each_cpu_mask(i, mask)
  55. core_send_ipi(i, action);
  56. }
  57. /*
  58. * Firmware CPU startup hook
  59. */
  60. extern void prom_boot_secondary(int cpu, struct task_struct *idle);
  61. /*
  62. * After we've done initial boot, this function is called to allow the
  63. * board code to clean up state, if needed
  64. */
  65. extern void prom_init_secondary(void);
  66. /*
  67. * Populate cpu_possible_map before smp_init, called from setup_arch.
  68. */
  69. extern void plat_smp_setup(void);
  70. /*
  71. * Called in smp_prepare_cpus.
  72. */
  73. extern void plat_prepare_cpus(unsigned int max_cpus);
  74. /*
  75. * Last chance for the board code to finish SMP initialization before
  76. * the CPU is "online".
  77. */
  78. extern void prom_smp_finish(void);
  79. /* Hook for after all CPUs are online */
  80. extern void prom_cpus_done(void);
  81. extern void asmlinkage smp_bootstrap(void);
  82. /*
  83. * this function sends a 'reschedule' IPI to another CPU.
  84. * it goes straight through and wastes no time serializing
  85. * anything. Worst case is that we lose a reschedule ...
  86. */
  87. static inline void smp_send_reschedule(int cpu)
  88. {
  89. core_send_ipi(cpu, SMP_RESCHEDULE_YOURSELF);
  90. }
  91. extern asmlinkage void smp_call_function_interrupt(void);
  92. #endif /* CONFIG_SMP */
  93. #endif /* __ASM_SMP_H */