smp.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. /*
  50. * Firmware CPU startup hook
  51. */
  52. extern void prom_boot_secondary(int cpu, struct task_struct *idle);
  53. /*
  54. * After we've done initial boot, this function is called to allow the
  55. * board code to clean up state, if needed
  56. */
  57. extern void prom_init_secondary(void);
  58. /*
  59. * Populate cpu_possible_map before smp_init, called from setup_arch.
  60. */
  61. extern void plat_smp_setup(void);
  62. /*
  63. * Called in smp_prepare_cpus.
  64. */
  65. extern void plat_prepare_cpus(unsigned int max_cpus);
  66. /*
  67. * Last chance for the board code to finish SMP initialization before
  68. * the CPU is "online".
  69. */
  70. extern void prom_smp_finish(void);
  71. /* Hook for after all CPUs are online */
  72. extern void prom_cpus_done(void);
  73. extern void asmlinkage smp_bootstrap(void);
  74. /*
  75. * this function sends a 'reschedule' IPI to another CPU.
  76. * it goes straight through and wastes no time serializing
  77. * anything. Worst case is that we lose a reschedule ...
  78. */
  79. static inline void smp_send_reschedule(int cpu)
  80. {
  81. core_send_ipi(cpu, SMP_RESCHEDULE_YOURSELF);
  82. }
  83. extern asmlinkage void smp_call_function_interrupt(void);
  84. #endif /* CONFIG_SMP */
  85. #endif /* __ASM_SMP_H */