ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-mips / smp.h
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
14 #include <linux/config.h>
15
16 #ifdef CONFIG_SMP
17
18 #include <linux/bitops.h>
19 #include <linux/linkage.h>
20 #include <linux/threads.h>
21 #include <linux/cpumask.h>
22 #include <asm/atomic.h>
23
24 #define smp_processor_id()      (current_thread_info()->cpu)
25
26 /* Map from cpu id to sequential logical cpu number.  This will only
27    not be idempotent when cpus failed to come on-line.  */
28 extern int __cpu_number_map[NR_CPUS];
29 #define cpu_number_map(cpu)  __cpu_number_map[cpu]
30
31 /* The reverse map from sequential logical cpu number to cpu id.  */
32 extern int __cpu_logical_map[NR_CPUS];
33 #define cpu_logical_map(cpu)  __cpu_logical_map[cpu]
34
35 #define NO_PROC_ID      (-1)
36
37 struct call_data_struct {
38         void            (*func)(void *);
39         void            *info;
40         atomic_t        started;
41         atomic_t        finished;
42         int             wait;
43 };
44
45 extern struct call_data_struct *call_data;
46
47 #define SMP_RESCHEDULE_YOURSELF 0x1     /* XXX braindead */
48 #define SMP_CALL_FUNCTION       0x2
49
50 extern cpumask_t phys_cpu_present_map;
51 extern cpumask_t cpu_online_map;
52 #define cpu_possible_map        phys_cpu_present_map
53
54 #define cpu_online(cpu)         cpu_isset(cpu, cpu_online_map)
55
56 extern cpumask_t cpu_callout_map;
57 /* We don't mark CPUs online until __cpu_up(), so we need another measure */
58 static inline int num_booting_cpus(void)
59 {
60         return cpus_weight(cpu_callout_map);
61 }
62
63 /* These are defined by the board-specific code. */
64
65 /*
66  * Cause the function described by call_data to be executed on the passed
67  * cpu.  When the function has finished, increment the finished field of
68  * call_data.
69  */
70 extern void core_send_ipi(int cpu, unsigned int action);
71
72 /*
73  * Detect available CPUs, populate phys_cpu_present_map
74  */
75 extern void prom_build_cpu_map(void);
76
77 /*
78  * Firmware CPU startup hook
79  */
80 extern void prom_boot_secondary(int cpu, struct task_struct *idle);
81
82 /*
83  *  After we've done initial boot, this function is called to allow the
84  *  board code to clean up state, if needed
85  */
86 extern void prom_init_secondary(void);
87
88 /*
89  * Callout to firmware before smp_init
90  */
91 extern void prom_prepare_cpus(unsigned int max_cpus);
92
93 /*
94  * Do whatever setup needs to be done for SMP at the board level.  Return
95  * the number of cpus in the system, including this one
96  */
97 extern int prom_setup_smp(void);
98
99 /*
100  * Last chance for the board code to finish SMP initialization before
101  * the CPU is "online".
102  */
103 extern void prom_smp_finish(void);
104
105 /* Hook for after all CPUs are online */
106 extern void prom_cpus_done(void);
107
108 extern void asmlinkage smp_bootstrap(void);
109
110 /*
111  * this function sends a 'reschedule' IPI to another CPU.
112  * it goes straight through and wastes no time serializing
113  * anything. Worst case is that we lose a reschedule ...
114  */
115 static inline void smp_send_reschedule(int cpu)
116 {
117         core_send_ipi(cpu, SMP_RESCHEDULE_YOURSELF);
118 }
119
120 extern asmlinkage void smp_call_function_interrupt(void);
121
122 #endif /* CONFIG_SMP */
123
124 #endif /* __ASM_SMP_H */