ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-ia64 / smp.h
1 /*
2  * SMP Support
3  *
4  * Copyright (C) 1999 VA Linux Systems
5  * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
6  * Copyright (C) 2001-2003 Hewlett-Packard Co
7  *      David Mosberger-Tang <davidm@hpl.hp.com>
8  */
9 #ifndef _ASM_IA64_SMP_H
10 #define _ASM_IA64_SMP_H
11
12 #include <linux/config.h>
13
14 #ifdef CONFIG_SMP
15
16 #include <linux/init.h>
17 #include <linux/threads.h>
18 #include <linux/kernel.h>
19 #include <linux/cpumask.h>
20
21 #include <asm/bitops.h>
22 #include <asm/io.h>
23 #include <asm/param.h>
24 #include <asm/processor.h>
25 #include <asm/ptrace.h>
26
27 #define XTP_OFFSET              0x1e0008
28
29 #define SMP_IRQ_REDIRECTION     (1 << 0)
30 #define SMP_IPI_REDIRECTION     (1 << 1)
31
32 #define smp_processor_id()      (current_thread_info()->cpu)
33
34 extern struct smp_boot_data {
35         int cpu_count;
36         int cpu_phys_id[NR_CPUS];
37 } smp_boot_data __initdata;
38
39 extern char no_int_routing __initdata;
40
41 extern cpumask_t phys_cpu_present_map;
42 extern cpumask_t cpu_online_map;
43 extern unsigned long ipi_base_addr;
44 extern unsigned char smp_int_redirect;
45
46 extern volatile int ia64_cpu_to_sapicid[];
47 #define cpu_physical_id(i)      ia64_cpu_to_sapicid[i]
48
49 extern unsigned long ap_wakeup_vector;
50
51 #define cpu_possible_map phys_cpu_present_map
52
53 /*
54  * Function to map hard smp processor id to logical id.  Slow, so don't use this in
55  * performance-critical code.
56  */
57 static inline int
58 cpu_logical_id (int cpuid)
59 {
60         int i;
61
62         for (i = 0; i < NR_CPUS; ++i)
63                 if (cpu_physical_id(i) == cpuid)
64                         break;
65         return i;
66 }
67
68 /*
69  * XTP control functions:
70  *      min_xtp   : route all interrupts to this CPU
71  *      normal_xtp: nominal XTP value
72  *      max_xtp   : never deliver interrupts to this CPU.
73  */
74
75 static inline void
76 min_xtp (void)
77 {
78         if (smp_int_redirect & SMP_IRQ_REDIRECTION)
79                 writeb(0x00, ipi_base_addr | XTP_OFFSET); /* XTP to min */
80 }
81
82 static inline void
83 normal_xtp (void)
84 {
85         if (smp_int_redirect & SMP_IRQ_REDIRECTION)
86                 writeb(0x08, ipi_base_addr | XTP_OFFSET); /* XTP normal */
87 }
88
89 static inline void
90 max_xtp (void)
91 {
92         if (smp_int_redirect & SMP_IRQ_REDIRECTION)
93                 writeb(0x0f, ipi_base_addr | XTP_OFFSET); /* Set XTP to max */
94 }
95
96 static inline unsigned int
97 hard_smp_processor_id (void)
98 {
99         union {
100                 struct {
101                         unsigned long reserved : 16;
102                         unsigned long eid : 8;
103                         unsigned long id : 8;
104                         unsigned long ignored : 32;
105                 } f;
106                 unsigned long bits;
107         } lid;
108
109         lid.bits = ia64_getreg(_IA64_REG_CR_LID);
110         return lid.f.id << 8 | lid.f.eid;
111 }
112
113 /* Upping and downing of CPUs */
114 extern int __cpu_disable (void);
115 extern void __cpu_die (unsigned int cpu);
116 extern int __cpu_up (unsigned int cpu);
117 extern void __init smp_build_cpu_map(void);
118
119 extern void __init init_smp_config (void);
120 extern void smp_do_timer (struct pt_regs *regs);
121
122 extern int smp_call_function_single (int cpuid, void (*func) (void *info), void *info,
123                                      int retry, int wait);
124 extern void smp_send_reschedule (int cpu);
125
126 #endif /* CONFIG_SMP */
127 #endif /* _ASM_IA64_SMP_H */