Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
| 15 | #ifdef CONFIG_SMP |
| 16 | |
| 17 | #include <linux/bitops.h> |
| 18 | #include <linux/linkage.h> |
| 19 | #include <linux/threads.h> |
| 20 | #include <linux/cpumask.h> |
| 21 | #include <asm/atomic.h> |
| 22 | |
Ralf Baechle | 0ab7aef | 2007-03-02 20:42:04 +0000 | [diff] [blame^] | 23 | extern int smp_num_siblings; |
| 24 | extern cpumask_t cpu_sibling_map[]; |
| 25 | |
Ingo Molnar | 39c715b | 2005-06-21 17:14:34 -0700 | [diff] [blame] | 26 | #define raw_smp_processor_id() (current_thread_info()->cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
| 28 | /* Map from cpu id to sequential logical cpu number. This will only |
| 29 | not be idempotent when cpus failed to come on-line. */ |
| 30 | extern int __cpu_number_map[NR_CPUS]; |
| 31 | #define cpu_number_map(cpu) __cpu_number_map[cpu] |
| 32 | |
| 33 | /* The reverse map from sequential logical cpu number to cpu id. */ |
| 34 | extern int __cpu_logical_map[NR_CPUS]; |
| 35 | #define cpu_logical_map(cpu) __cpu_logical_map[cpu] |
| 36 | |
| 37 | #define NO_PROC_ID (-1) |
| 38 | |
| 39 | struct call_data_struct { |
| 40 | void (*func)(void *); |
| 41 | void *info; |
| 42 | atomic_t started; |
| 43 | atomic_t finished; |
| 44 | int wait; |
| 45 | }; |
| 46 | |
| 47 | extern struct call_data_struct *call_data; |
| 48 | |
| 49 | #define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */ |
| 50 | #define SMP_CALL_FUNCTION 0x2 |
| 51 | |
| 52 | extern cpumask_t phys_cpu_present_map; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | #define cpu_possible_map phys_cpu_present_map |
| 54 | |
Ralf Baechle | 9b6695a | 2006-02-23 12:23:27 +0000 | [diff] [blame] | 55 | /* |
| 56 | * These are defined by the board-specific code. |
| 57 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | /* |
| 60 | * Cause the function described by call_data to be executed on the passed |
| 61 | * cpu. When the function has finished, increment the finished field of |
| 62 | * call_data. |
| 63 | */ |
| 64 | extern void core_send_ipi(int cpu, unsigned int action); |
| 65 | |
Ralf Baechle | bd6aeef | 2007-10-03 01:24:16 +0100 | [diff] [blame] | 66 | static inline void core_send_ipi_mask(cpumask_t mask, unsigned int action) |
| 67 | { |
| 68 | unsigned int i; |
| 69 | |
| 70 | for_each_cpu_mask(i, mask) |
| 71 | core_send_ipi(i, action); |
| 72 | } |
| 73 | |
| 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | /* |
| 76 | * Firmware CPU startup hook |
| 77 | */ |
| 78 | extern void prom_boot_secondary(int cpu, struct task_struct *idle); |
| 79 | |
| 80 | /* |
| 81 | * After we've done initial boot, this function is called to allow the |
| 82 | * board code to clean up state, if needed |
| 83 | */ |
| 84 | extern void prom_init_secondary(void); |
| 85 | |
| 86 | /* |
Ralf Baechle | 9b6695a | 2006-02-23 12:23:27 +0000 | [diff] [blame] | 87 | * Populate cpu_possible_map before smp_init, called from setup_arch. |
| 88 | */ |
| 89 | extern void plat_smp_setup(void); |
| 90 | |
| 91 | /* |
Ralf Baechle | 722ace9 | 2006-05-24 03:04:18 +0100 | [diff] [blame] | 92 | * Called in smp_prepare_cpus. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | */ |
Ralf Baechle | 722ace9 | 2006-05-24 03:04:18 +0100 | [diff] [blame] | 94 | extern void plat_prepare_cpus(unsigned int max_cpus); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
| 96 | /* |
| 97 | * Last chance for the board code to finish SMP initialization before |
| 98 | * the CPU is "online". |
| 99 | */ |
| 100 | extern void prom_smp_finish(void); |
| 101 | |
| 102 | /* Hook for after all CPUs are online */ |
| 103 | extern void prom_cpus_done(void); |
| 104 | |
| 105 | extern void asmlinkage smp_bootstrap(void); |
| 106 | |
| 107 | /* |
| 108 | * this function sends a 'reschedule' IPI to another CPU. |
| 109 | * it goes straight through and wastes no time serializing |
| 110 | * anything. Worst case is that we lose a reschedule ... |
| 111 | */ |
| 112 | static inline void smp_send_reschedule(int cpu) |
| 113 | { |
| 114 | core_send_ipi(cpu, SMP_RESCHEDULE_YOURSELF); |
| 115 | } |
| 116 | |
| 117 | extern asmlinkage void smp_call_function_interrupt(void); |
| 118 | |
| 119 | #endif /* CONFIG_SMP */ |
| 120 | |
| 121 | #endif /* __ASM_SMP_H */ |