blob: 719ff309ce090276b0678b0ebccfeccf4a43b4ea [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/init.h>
14#include <linux/threads.h>
15#include <linux/kernel.h>
16#include <linux/cpumask.h>
17
18#include <asm/bitops.h>
19#include <asm/io.h>
20#include <asm/param.h>
21#include <asm/processor.h>
22#include <asm/ptrace.h>
23
24static inline unsigned int
25ia64_get_lid (void)
26{
27 union {
28 struct {
29 unsigned long reserved : 16;
30 unsigned long eid : 8;
31 unsigned long id : 8;
32 unsigned long ignored : 32;
33 } f;
34 unsigned long bits;
35 } lid;
36
37 lid.bits = ia64_getreg(_IA64_REG_CR_LID);
38 return lid.f.id << 8 | lid.f.eid;
39}
40
41#ifdef CONFIG_SMP
42
43#define XTP_OFFSET 0x1e0008
44
45#define SMP_IRQ_REDIRECTION (1 << 0)
46#define SMP_IPI_REDIRECTION (1 << 1)
47
Ingo Molnar39c715b2005-06-21 17:14:34 -070048#define raw_smp_processor_id() (current_thread_info()->cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50extern struct smp_boot_data {
51 int cpu_count;
52 int cpu_phys_id[NR_CPUS];
53} smp_boot_data __initdata;
54
55extern char no_int_routing __devinitdata;
56
57extern cpumask_t cpu_online_map;
Suresh Siddhae927ecb2005-04-25 13:25:06 -070058extern cpumask_t cpu_core_map[NR_CPUS];
59extern cpumask_t cpu_sibling_map[NR_CPUS];
60extern int smp_num_siblings;
61extern int smp_num_cpucores;
Linus Torvalds1da177e2005-04-16 15:20:36 -070062extern void __iomem *ipi_base_addr;
63extern unsigned char smp_int_redirect;
64
65extern volatile int ia64_cpu_to_sapicid[];
66#define cpu_physical_id(i) ia64_cpu_to_sapicid[i]
67
68extern unsigned long ap_wakeup_vector;
69
70/*
71 * Function to map hard smp processor id to logical id. Slow, so don't use this in
72 * performance-critical code.
73 */
74static inline int
75cpu_logical_id (int cpuid)
76{
77 int i;
78
79 for (i = 0; i < NR_CPUS; ++i)
80 if (cpu_physical_id(i) == cpuid)
81 break;
82 return i;
83}
84
85/*
86 * XTP control functions:
87 * min_xtp : route all interrupts to this CPU
88 * normal_xtp: nominal XTP value
89 * max_xtp : never deliver interrupts to this CPU.
90 */
91
92static inline void
93min_xtp (void)
94{
95 if (smp_int_redirect & SMP_IRQ_REDIRECTION)
96 writeb(0x00, ipi_base_addr + XTP_OFFSET); /* XTP to min */
97}
98
99static inline void
100normal_xtp (void)
101{
102 if (smp_int_redirect & SMP_IRQ_REDIRECTION)
103 writeb(0x08, ipi_base_addr + XTP_OFFSET); /* XTP normal */
104}
105
106static inline void
107max_xtp (void)
108{
109 if (smp_int_redirect & SMP_IRQ_REDIRECTION)
110 writeb(0x0f, ipi_base_addr + XTP_OFFSET); /* Set XTP to max */
111}
112
113#define hard_smp_processor_id() ia64_get_lid()
114
115/* Upping and downing of CPUs */
116extern int __cpu_disable (void);
117extern void __cpu_die (unsigned int cpu);
118extern void cpu_die (void) __attribute__ ((noreturn));
119extern int __cpu_up (unsigned int cpu);
120extern void __init smp_build_cpu_map(void);
121
122extern void __init init_smp_config (void);
123extern void smp_do_timer (struct pt_regs *regs);
124
125extern int smp_call_function_single (int cpuid, void (*func) (void *info), void *info,
126 int retry, int wait);
127extern void smp_send_reschedule (int cpu);
128extern void lock_ipi_calllock(void);
129extern void unlock_ipi_calllock(void);
Suresh Siddhae927ecb2005-04-25 13:25:06 -0700130extern void identify_siblings (struct cpuinfo_ia64 *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
132#else
133
134#define cpu_logical_id(i) 0
135#define cpu_physical_id(i) ia64_get_lid()
136
137#endif /* CONFIG_SMP */
138#endif /* _ASM_IA64_SMP_H */