smp.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. #include <linux/config.h>
  14. #ifdef CONFIG_SMP
  15. #include <linux/bitops.h>
  16. #include <linux/linkage.h>
  17. #include <linux/threads.h>
  18. #include <linux/cpumask.h>
  19. #include <asm/atomic.h>
  20. #define raw_smp_processor_id() (current_thread_info()->cpu)
  21. /* Map from cpu id to sequential logical cpu number. This will only
  22. not be idempotent when cpus failed to come on-line. */
  23. extern int __cpu_number_map[NR_CPUS];
  24. #define cpu_number_map(cpu) __cpu_number_map[cpu]
  25. /* The reverse map from sequential logical cpu number to cpu id. */
  26. extern int __cpu_logical_map[NR_CPUS];
  27. #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
  28. #define NO_PROC_ID (-1)
  29. struct call_data_struct {
  30. void (*func)(void *);
  31. void *info;
  32. atomic_t started;
  33. atomic_t finished;
  34. int wait;
  35. };
  36. extern struct call_data_struct *call_data;
  37. #define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */
  38. #define SMP_CALL_FUNCTION 0x2
  39. extern cpumask_t phys_cpu_present_map;
  40. extern cpumask_t cpu_online_map;
  41. #define cpu_possible_map phys_cpu_present_map
  42. extern cpumask_t cpu_callout_map;
  43. /* We don't mark CPUs online until __cpu_up(), so we need another measure */
  44. static inline int num_booting_cpus(void)
  45. {
  46. return cpus_weight(cpu_callout_map);
  47. }
  48. /* These are defined by the board-specific code. */
  49. /*
  50. * Cause the function described by call_data to be executed on the passed
  51. * cpu. When the function has finished, increment the finished field of
  52. * call_data.
  53. */
  54. extern void core_send_ipi(int cpu, unsigned int action);
  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. * Detect available CPUs, populate phys_cpu_present_map before smp_init
  66. */
  67. extern void prom_prepare_cpus(unsigned int max_cpus);
  68. /*
  69. * Last chance for the board code to finish SMP initialization before
  70. * the CPU is "online".
  71. */
  72. extern void prom_smp_finish(void);
  73. /* Hook for after all CPUs are online */
  74. extern void prom_cpus_done(void);
  75. extern void asmlinkage smp_bootstrap(void);
  76. /*
  77. * this function sends a 'reschedule' IPI to another CPU.
  78. * it goes straight through and wastes no time serializing
  79. * anything. Worst case is that we lose a reschedule ...
  80. */
  81. static inline void smp_send_reschedule(int cpu)
  82. {
  83. core_send_ipi(cpu, SMP_RESCHEDULE_YOURSELF);
  84. }
  85. extern asmlinkage void smp_call_function_interrupt(void);
  86. #endif /* CONFIG_SMP */
  87. #endif /* __ASM_SMP_H */