smp.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. #define raw_smp_processor_id() (current_thread_info()->cpu)
  20. /* Map from cpu id to sequential logical cpu number. This will only
  21. not be idempotent when cpus failed to come on-line. */
  22. extern int __cpu_number_map[NR_CPUS];
  23. #define cpu_number_map(cpu) __cpu_number_map[cpu]
  24. /* The reverse map from sequential logical cpu number to cpu id. */
  25. extern int __cpu_logical_map[NR_CPUS];
  26. #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
  27. #define NO_PROC_ID (-1)
  28. struct call_data_struct {
  29. void (*func)(void *);
  30. void *info;
  31. atomic_t started;
  32. atomic_t finished;
  33. int wait;
  34. };
  35. extern struct call_data_struct *call_data;
  36. #define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */
  37. #define SMP_CALL_FUNCTION 0x2
  38. extern cpumask_t phys_cpu_present_map;
  39. #define cpu_possible_map phys_cpu_present_map
  40. /*
  41. * These are defined by the board-specific code.
  42. */
  43. /*
  44. * Cause the function described by call_data to be executed on the passed
  45. * cpu. When the function has finished, increment the finished field of
  46. * call_data.
  47. */
  48. extern void core_send_ipi(int cpu, unsigned int action);
  49. static inline void core_send_ipi_mask(cpumask_t mask, unsigned int action)
  50. {
  51. unsigned int i;
  52. for_each_cpu_mask(i, mask)
  53. core_send_ipi(i, action);
  54. }
  55. /*
  56. * Firmware CPU startup hook
  57. */
  58. extern void prom_boot_secondary(int cpu, struct task_struct *idle);
  59. /*
  60. * After we've done initial boot, this function is called to allow the
  61. * board code to clean up state, if needed
  62. */
  63. extern void prom_init_secondary(void);
  64. /*
  65. * Populate cpu_possible_map before smp_init, called from setup_arch.
  66. */
  67. extern void plat_smp_setup(void);
  68. /*
  69. * Called in smp_prepare_cpus.
  70. */
  71. extern void plat_prepare_cpus(unsigned int max_cpus);
  72. /*
  73. * Last chance for the board code to finish SMP initialization before
  74. * the CPU is "online".
  75. */
  76. extern void prom_smp_finish(void);
  77. /* Hook for after all CPUs are online */
  78. extern void prom_cpus_done(void);
  79. extern void asmlinkage smp_bootstrap(void);
  80. /*
  81. * this function sends a 'reschedule' IPI to another CPU.
  82. * it goes straight through and wastes no time serializing
  83. * anything. Worst case is that we lose a reschedule ...
  84. */
  85. static inline void smp_send_reschedule(int cpu)
  86. {
  87. core_send_ipi(cpu, SMP_RESCHEDULE_YOURSELF);
  88. }
  89. extern asmlinkage void smp_call_function_interrupt(void);
  90. #endif /* CONFIG_SMP */
  91. #endif /* __ASM_SMP_H */