patch-2_6_7-vs1_9_1_12
[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 __devinitdata;
40
41 extern cpumask_t cpu_online_map;
42 extern unsigned long ipi_base_addr;
43 extern unsigned char smp_int_redirect;
44
45 extern volatile int ia64_cpu_to_sapicid[];
46 #define cpu_physical_id(i)      ia64_cpu_to_sapicid[i]
47
48 extern unsigned long ap_wakeup_vector;
49
50 /*
51  * Function to map hard smp processor id to logical id.  Slow, so don't use this in
52  * performance-critical code.
53  */
54 static inline int
55 cpu_logical_id (int cpuid)
56 {
57         int i;
58
59         for (i = 0; i < NR_CPUS; ++i)
60                 if (cpu_physical_id(i) == cpuid)
61                         break;
62         return i;
63 }
64
65 /*
66  * XTP control functions:
67  *      min_xtp   : route all interrupts to this CPU
68  *      normal_xtp: nominal XTP value
69  *      max_xtp   : never deliver interrupts to this CPU.
70  */
71
72 static inline void
73 min_xtp (void)
74 {
75         if (smp_int_redirect & SMP_IRQ_REDIRECTION)
76                 writeb(0x00, ipi_base_addr | XTP_OFFSET); /* XTP to min */
77 }
78
79 static inline void
80 normal_xtp (void)
81 {
82         if (smp_int_redirect & SMP_IRQ_REDIRECTION)
83                 writeb(0x08, ipi_base_addr | XTP_OFFSET); /* XTP normal */
84 }
85
86 static inline void
87 max_xtp (void)
88 {
89         if (smp_int_redirect & SMP_IRQ_REDIRECTION)
90                 writeb(0x0f, ipi_base_addr | XTP_OFFSET); /* Set XTP to max */
91 }
92
93 static inline unsigned int
94 hard_smp_processor_id (void)
95 {
96         union {
97                 struct {
98                         unsigned long reserved : 16;
99                         unsigned long eid : 8;
100                         unsigned long id : 8;
101                         unsigned long ignored : 32;
102                 } f;
103                 unsigned long bits;
104         } lid;
105
106         lid.bits = ia64_getreg(_IA64_REG_CR_LID);
107         return lid.f.id << 8 | lid.f.eid;
108 }
109
110 /* Upping and downing of CPUs */
111 extern int __cpu_disable (void);
112 extern void __cpu_die (unsigned int cpu);
113 extern void cpu_die (void) __attribute__ ((noreturn));
114 extern int __cpu_up (unsigned int cpu);
115 extern void __init smp_build_cpu_map(void);
116
117 extern void __init init_smp_config (void);
118 extern void smp_do_timer (struct pt_regs *regs);
119
120 extern int smp_call_function_single (int cpuid, void (*func) (void *info), void *info,
121                                      int retry, int wait);
122 extern void smp_send_reschedule (int cpu);
123 extern void lock_ipi_calllock(void);
124 extern void unlock_ipi_calllock(void);
125
126 #endif /* CONFIG_SMP */
127 #endif /* _ASM_IA64_SMP_H */