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