1/* 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. */ 38extern 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. */ 42extern 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 48#define SMP_CALL_FUNCTION 0x2 49 50#if (NR_CPUS <= _MIPS_SZLONG) 51 52typedef 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 68typedef 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 84struct call_data_struct { 85 void (*func)(void *); 86 void *info; 87 atomic_t started; 88 atomic_t finished; 89 int wait; 90}; 91 92extern struct call_data_struct *call_data; 93 94extern cpumask_t cpu_online_map; 95 96#endif /* CONFIG_SMP */ 97#endif /* _ASM_SMP_H */ 98