2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com)
17 * Copyright (C) 2000, 2001, 2002 by Ralf Baechle
18 * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
19 * Copyright (C) 2000, 2001 Broadcom Corporation
24 #include <linux/config.h>
28 #include <linux/threads.h>
29 #include <asm/atomic.h>
30 #include <asm/current.h>
32 #define smp_processor_id() (current->processor)
34 #define PROC_CHANGE_PENALTY 20
36 /* Map from cpu id to sequential logical cpu number. This will only
37 not be idempotent when cpus failed to come on-line. */
38 extern int __cpu_number_map[NR_CPUS];
39 #define cpu_number_map(cpu) __cpu_number_map[cpu]
41 /* The reverse map from sequential logical cpu number to cpu id. */
42 extern int __cpu_logical_map[NR_CPUS];
43 #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
45 #define NO_PROC_ID (-1)
47 #define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */
48 #define SMP_CALL_FUNCTION 0x2
50 #if (NR_CPUS <= _MIPS_SZLONG)
52 typedef unsigned long cpumask_t;
54 #define CPUMASK_CLRALL(p) do { (p) = 0; } while(0)
55 #define CPUMASK_SETB(p, bit) (p) |= 1UL << (bit)
56 #define CPUMASK_CLRB(p, bit) (p) &= ~(1UL << (bit))
57 #define CPUMASK_TSTB(p, bit) ((p) & (1UL << (bit)))
59 #elif (NR_CPUS <= 128)
62 * The foll should work till 128 cpus.
64 #define CPUMASK_SIZE (NR_CPUS/_MIPS_SZLONG)
65 #define CPUMASK_INDEX(bit) ((bit) >> 6)
66 #define CPUMASK_SHFT(bit) ((bit) & 0x3f)
69 unsigned long _bits[CPUMASK_SIZE];
72 #define CPUMASK_CLRALL(p) (p)._bits[0] = 0, (p)._bits[1] = 0
73 #define CPUMASK_SETB(p, bit) (p)._bits[CPUMASK_INDEX(bit)] |= \
74 (1UL << CPUMASK_SHFT(bit))
75 #define CPUMASK_CLRB(p, bit) (p)._bits[CPUMASK_INDEX(bit)] &= \
76 ~(1UL << CPUMASK_SHFT(bit))
77 #define CPUMASK_TSTB(p, bit) ((p)._bits[CPUMASK_INDEX(bit)] & \
78 (1UL << CPUMASK_SHFT(bit)))
81 #error cpumask macros only defined for 128p kernels
84 struct call_data_struct {
92 extern struct call_data_struct *call_data;
94 extern cpumask_t cpu_online_map;
96 /* These are defined by the board-specific code. */
99 * Cause the function described by call_data to be executed on the passed
100 * cpu. When the function has finished, increment the finished field of
103 void core_send_ipi(int cpu, unsigned int action);
106 * Clear all undefined state in the cpu, set up sp and gp to the passed
107 * values, and kick the cpu into smp_bootstrap();
109 int prom_boot_secondary(int cpu, unsigned long sp, unsigned long gp);
112 * After we've done initial boot, this function is called to allow the
113 * board code to clean up state, if needed
115 void prom_init_secondary(void);
118 * Do whatever setup needs to be done for SMP at the board level. Return
119 * the number of cpus in the system, including this one
121 int prom_setup_smp(void);
123 void prom_smp_finish(void);
125 extern void asmlinkage smp_bootstrap(void);
127 #endif /* CONFIG_SMP */
128 #endif /* _ASM_SMP_H */