blob: e14e4b69de21d1a3a21838cfa79ed2e7696ecf2e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Ingo Molnar39c715b2005-06-21 17:14:34 -070024#define raw_smp_processor_id() (current_thread_info()->cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26/* Map from cpu id to sequential logical cpu number. This will only
27 not be idempotent when cpus failed to come on-line. */
28extern 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. */
32extern int __cpu_logical_map[NR_CPUS];
33#define cpu_logical_map(cpu) __cpu_logical_map[cpu]
34
35#define NO_PROC_ID (-1)
36
37struct call_data_struct {
38 void (*func)(void *);
39 void *info;
40 atomic_t started;
41 atomic_t finished;
42 int wait;
43};
44
45extern struct call_data_struct *call_data;
46
47#define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */
48#define SMP_CALL_FUNCTION 0x2
49
50extern cpumask_t phys_cpu_present_map;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#define cpu_possible_map phys_cpu_present_map
52
53extern cpumask_t cpu_callout_map;
54/* We don't mark CPUs online until __cpu_up(), so we need another measure */
55static inline int num_booting_cpus(void)
56{
57 return cpus_weight(cpu_callout_map);
58}
59
Ralf Baechle9b6695a2006-02-23 12:23:27 +000060/*
61 * These are defined by the board-specific code.
62 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64/*
65 * Cause the function described by call_data to be executed on the passed
66 * cpu. When the function has finished, increment the finished field of
67 * call_data.
68 */
69extern void core_send_ipi(int cpu, unsigned int action);
70
71/*
72 * Firmware CPU startup hook
73 */
74extern void prom_boot_secondary(int cpu, struct task_struct *idle);
75
76/*
77 * After we've done initial boot, this function is called to allow the
78 * board code to clean up state, if needed
79 */
80extern void prom_init_secondary(void);
81
82/*
Ralf Baechle9b6695a2006-02-23 12:23:27 +000083 * Populate cpu_possible_map before smp_init, called from setup_arch.
84 */
85extern void plat_smp_setup(void);
86
87/*
Ralf Baechle722ace92006-05-24 03:04:18 +010088 * Called in smp_prepare_cpus.
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 */
Ralf Baechle722ace92006-05-24 03:04:18 +010090extern void plat_prepare_cpus(unsigned int max_cpus);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
92/*
93 * Last chance for the board code to finish SMP initialization before
94 * the CPU is "online".
95 */
96extern void prom_smp_finish(void);
97
98/* Hook for after all CPUs are online */
99extern void prom_cpus_done(void);
100
101extern void asmlinkage smp_bootstrap(void);
102
103/*
104 * this function sends a 'reschedule' IPI to another CPU.
105 * it goes straight through and wastes no time serializing
106 * anything. Worst case is that we lose a reschedule ...
107 */
108static inline void smp_send_reschedule(int cpu)
109{
110 core_send_ipi(cpu, SMP_RESCHEDULE_YOURSELF);
111}
112
113extern asmlinkage void smp_call_function_interrupt(void);
114
115#endif /* CONFIG_SMP */
116
117#endif /* __ASM_SMP_H */