1 |
1276 |
phoenix |
/*
|
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.
|
6 |
|
|
*
|
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.
|
11 |
|
|
*
|
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.
|
15 |
|
|
*
|
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
|
20 |
|
|
*/
|
21 |
|
|
#ifndef _ASM_SMP_H
|
22 |
|
|
#define _ASM_SMP_H
|
23 |
|
|
|
24 |
|
|
#include <linux/config.h>
|
25 |
|
|
|
26 |
|
|
#ifdef CONFIG_SMP
|
27 |
|
|
|
28 |
|
|
#include <linux/threads.h>
|
29 |
|
|
#include <asm/atomic.h>
|
30 |
|
|
#include <asm/current.h>
|
31 |
|
|
|
32 |
|
|
#define smp_processor_id() (current->processor)
|
33 |
|
|
|
34 |
|
|
#define PROC_CHANGE_PENALTY 20
|
35 |
|
|
|
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]
|
40 |
|
|
|
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]
|
44 |
|
|
|
45 |
|
|
#define NO_PROC_ID (-1)
|
46 |
|
|
|
47 |
|
|
#define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */
|
48 |
|
|
#define SMP_CALL_FUNCTION 0x2
|
49 |
|
|
|
50 |
|
|
#if (NR_CPUS <= _MIPS_SZLONG)
|
51 |
|
|
|
52 |
|
|
typedef unsigned long cpumask_t;
|
53 |
|
|
|
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)))
|
58 |
|
|
|
59 |
|
|
#elif (NR_CPUS <= 128)
|
60 |
|
|
|
61 |
|
|
/*
|
62 |
|
|
* The foll should work till 128 cpus.
|
63 |
|
|
*/
|
64 |
|
|
#define CPUMASK_SIZE (NR_CPUS/_MIPS_SZLONG)
|
65 |
|
|
#define CPUMASK_INDEX(bit) ((bit) >> 6)
|
66 |
|
|
#define CPUMASK_SHFT(bit) ((bit) & 0x3f)
|
67 |
|
|
|
68 |
|
|
typedef struct {
|
69 |
|
|
unsigned long _bits[CPUMASK_SIZE];
|
70 |
|
|
} cpumask_t;
|
71 |
|
|
|
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)))
|
79 |
|
|
|
80 |
|
|
#else
|
81 |
|
|
#error cpumask macros only defined for 128p kernels
|
82 |
|
|
#endif
|
83 |
|
|
|
84 |
|
|
struct call_data_struct {
|
85 |
|
|
void (*func)(void *);
|
86 |
|
|
void *info;
|
87 |
|
|
atomic_t started;
|
88 |
|
|
atomic_t finished;
|
89 |
|
|
int wait;
|
90 |
|
|
};
|
91 |
|
|
|
92 |
|
|
extern struct call_data_struct *call_data;
|
93 |
|
|
|
94 |
|
|
extern cpumask_t cpu_online_map;
|
95 |
|
|
|
96 |
|
|
/* These are defined by the board-specific code. */
|
97 |
|
|
|
98 |
|
|
/*
|
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
|
101 |
|
|
* call_data.
|
102 |
|
|
*/
|
103 |
|
|
void core_send_ipi(int cpu, unsigned int action);
|
104 |
|
|
|
105 |
|
|
/*
|
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();
|
108 |
|
|
*/
|
109 |
|
|
void prom_boot_secondary(int cpu, unsigned long sp, unsigned long gp);
|
110 |
|
|
|
111 |
|
|
/*
|
112 |
|
|
* After we've done initial boot, this function is called to allow the
|
113 |
|
|
* board code to clean up state, if needed
|
114 |
|
|
*/
|
115 |
|
|
void prom_init_secondary(void);
|
116 |
|
|
|
117 |
|
|
/*
|
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
|
120 |
|
|
*/
|
121 |
|
|
int prom_setup_smp(void);
|
122 |
|
|
|
123 |
|
|
void prom_smp_finish(void);
|
124 |
|
|
|
125 |
|
|
extern void asmlinkage smp_bootstrap(void);
|
126 |
|
|
|
127 |
|
|
#endif /* CONFIG_SMP */
|
128 |
|
|
#endif /* _ASM_SMP_H */
|