Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General
0003  * Public License.  See the file "COPYING" in the main directory of this
0004  * archive for more details.
0005  *
0006  * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com)
0007  * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
0008  * Copyright (C) 2000, 2001, 2002 Ralf Baechle
0009  * Copyright (C) 2000, 2001 Broadcom Corporation
0010  */
0011 #ifndef __ASM_SMP_H
0012 #define __ASM_SMP_H
0013 
0014 #include <linux/bitops.h>
0015 #include <linux/linkage.h>
0016 #include <linux/smp.h>
0017 #include <linux/threads.h>
0018 #include <linux/cpumask.h>
0019 
0020 #include <linux/atomic.h>
0021 #include <asm/smp-ops.h>
0022 
0023 extern int smp_num_siblings;
0024 extern cpumask_t cpu_sibling_map[];
0025 extern cpumask_t cpu_core_map[];
0026 extern cpumask_t cpu_foreign_map[];
0027 
0028 static inline int raw_smp_processor_id(void)
0029 {
0030 #if defined(__VDSO__)
0031     extern int vdso_smp_processor_id(void)
0032         __compiletime_error("VDSO should not call smp_processor_id()");
0033     return vdso_smp_processor_id();
0034 #else
0035     return current_thread_info()->cpu;
0036 #endif
0037 }
0038 #define raw_smp_processor_id raw_smp_processor_id
0039 
0040 /* Map from cpu id to sequential logical cpu number.  This will only
0041    not be idempotent when cpus failed to come on-line.  */
0042 extern int __cpu_number_map[CONFIG_MIPS_NR_CPU_NR_MAP];
0043 #define cpu_number_map(cpu)  __cpu_number_map[cpu]
0044 
0045 /* The reverse map from sequential logical cpu number to cpu id.  */
0046 extern int __cpu_logical_map[NR_CPUS];
0047 #define cpu_logical_map(cpu)  __cpu_logical_map[cpu]
0048 
0049 #define NO_PROC_ID  (-1)
0050 
0051 #define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */
0052 #define SMP_CALL_FUNCTION   0x2
0053 /* Octeon - Tell another core to flush its icache */
0054 #define SMP_ICACHE_FLUSH    0x4
0055 #define SMP_ASK_C0COUNT     0x8
0056 
0057 /* Mask of CPUs which are currently definitely operating coherently */
0058 extern cpumask_t cpu_coherent_mask;
0059 
0060 extern asmlinkage void smp_bootstrap(void);
0061 
0062 extern void calculate_cpu_foreign_map(void);
0063 
0064 /*
0065  * this function sends a 'reschedule' IPI to another CPU.
0066  * it goes straight through and wastes no time serializing
0067  * anything. Worst case is that we lose a reschedule ...
0068  */
0069 static inline void smp_send_reschedule(int cpu)
0070 {
0071     extern const struct plat_smp_ops *mp_ops;   /* private */
0072 
0073     mp_ops->send_ipi_single(cpu, SMP_RESCHEDULE_YOURSELF);
0074 }
0075 
0076 #ifdef CONFIG_HOTPLUG_CPU
0077 static inline int __cpu_disable(void)
0078 {
0079     extern const struct plat_smp_ops *mp_ops;   /* private */
0080 
0081     return mp_ops->cpu_disable();
0082 }
0083 
0084 static inline void __cpu_die(unsigned int cpu)
0085 {
0086     extern const struct plat_smp_ops *mp_ops;   /* private */
0087 
0088     mp_ops->cpu_die(cpu);
0089 }
0090 
0091 extern void play_dead(void);
0092 #endif
0093 
0094 #ifdef CONFIG_KEXEC
0095 static inline void kexec_nonboot_cpu(void)
0096 {
0097     extern const struct plat_smp_ops *mp_ops;   /* private */
0098 
0099     return mp_ops->kexec_nonboot_cpu();
0100 }
0101 
0102 static inline void *kexec_nonboot_cpu_func(void)
0103 {
0104     extern const struct plat_smp_ops *mp_ops;   /* private */
0105 
0106     return mp_ops->kexec_nonboot_cpu;
0107 }
0108 #endif
0109 
0110 /*
0111  * This function will set up the necessary IPIs for Linux to communicate
0112  * with the CPUs in mask.
0113  * Return 0 on success.
0114  */
0115 int mips_smp_ipi_allocate(const struct cpumask *mask);
0116 
0117 /*
0118  * This function will free up IPIs allocated with mips_smp_ipi_allocate to the
0119  * CPUs in mask, which must be a subset of the IPIs that have been configured.
0120  * Return 0 on success.
0121  */
0122 int mips_smp_ipi_free(const struct cpumask *mask);
0123 
0124 static inline void arch_send_call_function_single_ipi(int cpu)
0125 {
0126     extern const struct plat_smp_ops *mp_ops;   /* private */
0127 
0128     mp_ops->send_ipi_single(cpu, SMP_CALL_FUNCTION);
0129 }
0130 
0131 static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask)
0132 {
0133     extern const struct plat_smp_ops *mp_ops;   /* private */
0134 
0135     mp_ops->send_ipi_mask(mask, SMP_CALL_FUNCTION);
0136 }
0137 
0138 #endif /* __ASM_SMP_H */