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.
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
14 #include <linux/config.h>
18 #include <linux/bitops.h>
19 #include <linux/threads.h>
20 #include <asm/atomic.h>
22 #define smp_processor_id() (current_thread_info()->cpu)
24 /* Map from cpu id to sequential logical cpu number. This will only
25 not be idempotent when cpus failed to come on-line. */
26 extern int __cpu_number_map[NR_CPUS];
27 #define cpu_number_map(cpu) __cpu_number_map[cpu]
29 /* The reverse map from sequential logical cpu number to cpu id. */
30 extern int __cpu_logical_map[NR_CPUS];
31 #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
33 #define NO_PROC_ID (-1)
35 struct call_data_struct {
43 extern struct call_data_struct *call_data;
45 #define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */
46 #define SMP_CALL_FUNCTION 0x2
48 #if (NR_CPUS <= _MIPS_SZLONG)
50 typedef unsigned long cpumask_t;
52 #define CPUMASK_CLRALL(p) (p) = 0
53 #define CPUMASK_SETB(p, bit) (p) |= 1UL << (bit)
54 #define CPUMASK_CLRB(p, bit) (p) &= ~(1UL << (bit))
55 #define CPUMASK_TSTB(p, bit) ((p) & (1UL << (bit)))
57 #elif (NR_CPUS <= 128)
60 * The foll should work till 128 cpus.
62 #define CPUMASK_SIZE (NR_CPUS/_MIPS_SZLONG)
63 #define CPUMASK_INDEX(bit) ((bit) >> 6)
64 #define CPUMASK_SHFT(bit) ((bit) & 0x3f)
67 unsigned long _bits[CPUMASK_SIZE];
70 #define CPUMASK_CLRALL(p) (p)._bits[0] = 0, (p)._bits[1] = 0
71 #define CPUMASK_SETB(p, bit) (p)._bits[CPUMASK_INDEX(bit)] |= \
72 (1UL << CPUMASK_SHFT(bit))
73 #define CPUMASK_CLRB(p, bit) (p)._bits[CPUMASK_INDEX(bit)] &= \
74 ~(1UL << CPUMASK_SHFT(bit))
75 #define CPUMASK_TSTB(p, bit) ((p)._bits[CPUMASK_INDEX(bit)] & \
76 (1UL << CPUMASK_SHFT(bit)))
79 #error cpumask macros only defined for 128p kernels
82 extern cpumask_t phys_cpu_present_map;
83 extern cpumask_t cpu_online_map;
85 #define cpu_possible(cpu) (phys_cpu_present_map & (1<<(cpu)))
86 #define cpu_online(cpu) (cpu_online_map & (1<<(cpu)))
88 extern inline unsigned int num_online_cpus(void)
90 return hweight32(cpu_online_map);
93 extern volatile unsigned long cpu_callout_map;
94 /* We don't mark CPUs online until __cpu_up(), so we need another measure */
95 static inline int num_booting_cpus(void)
97 return hweight32(cpu_callout_map);
100 #endif /* CONFIG_SMP */
102 #endif /* __ASM_SMP_H */