blob: 27731e032ee999be767993dbdb47b8c3a7334086 [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>
Jiri Slaby1977f032007-10-18 23:40:25 -070017#include <linux/bitops.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#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
Fernando Luis Vazquez Cao818563d2007-05-09 02:33:28 -070041#define hard_smp_processor_id() ia64_get_lid()
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#ifdef CONFIG_SMP
44
45#define XTP_OFFSET 0x1e0008
46
47#define SMP_IRQ_REDIRECTION (1 << 0)
48#define SMP_IPI_REDIRECTION (1 << 1)
49
Ingo Molnar39c715b2005-06-21 17:14:34 -070050#define raw_smp_processor_id() (current_thread_info()->cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52extern struct smp_boot_data {
53 int cpu_count;
54 int cpu_phys_id[NR_CPUS];
55} smp_boot_data __initdata;
56
57extern char no_int_routing __devinitdata;
58
59extern cpumask_t cpu_online_map;
Suresh Siddhae927ecb2005-04-25 13:25:06 -070060extern cpumask_t cpu_core_map[NR_CPUS];
Mike Travisd5a74302007-10-16 01:24:05 -070061DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
Suresh Siddhae927ecb2005-04-25 13:25:06 -070062extern int smp_num_siblings;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063extern void __iomem *ipi_base_addr;
64extern unsigned char smp_int_redirect;
65
66extern volatile int ia64_cpu_to_sapicid[];
67#define cpu_physical_id(i) ia64_cpu_to_sapicid[i]
68
69extern unsigned long ap_wakeup_vector;
70
71/*
72 * Function to map hard smp processor id to logical id. Slow, so don't use this in
73 * performance-critical code.
74 */
75static inline int
76cpu_logical_id (int cpuid)
77{
78 int i;
79
80 for (i = 0; i < NR_CPUS; ++i)
81 if (cpu_physical_id(i) == cpuid)
82 break;
83 return i;
84}
85
86/*
87 * XTP control functions:
88 * min_xtp : route all interrupts to this CPU
89 * normal_xtp: nominal XTP value
90 * max_xtp : never deliver interrupts to this CPU.
91 */
92
93static inline void
94min_xtp (void)
95{
96 if (smp_int_redirect & SMP_IRQ_REDIRECTION)
97 writeb(0x00, ipi_base_addr + XTP_OFFSET); /* XTP to min */
98}
99
100static inline void
101normal_xtp (void)
102{
103 if (smp_int_redirect & SMP_IRQ_REDIRECTION)
104 writeb(0x08, ipi_base_addr + XTP_OFFSET); /* XTP normal */
105}
106
107static inline void
108max_xtp (void)
109{
110 if (smp_int_redirect & SMP_IRQ_REDIRECTION)
111 writeb(0x0f, ipi_base_addr + XTP_OFFSET); /* Set XTP to max */
112}
113
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114/* Upping and downing of CPUs */
115extern int __cpu_disable (void);
116extern void __cpu_die (unsigned int cpu);
117extern void cpu_die (void) __attribute__ ((noreturn));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118extern void __init smp_build_cpu_map(void);
119
120extern void __init init_smp_config (void);
121extern void smp_do_timer (struct pt_regs *regs);
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123extern void smp_send_reschedule (int cpu);
Suresh Siddhae927ecb2005-04-25 13:25:06 -0700124extern void identify_siblings (struct cpuinfo_ia64 *);
Stephane Eraniandd562c02006-09-21 10:35:44 -0700125extern int is_multithreading_enabled(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
Jens Axboef27b4332008-06-26 11:22:30 +0200127extern void arch_send_call_function_single_ipi(int cpu);
128extern void arch_send_call_function_ipi(cpumask_t mask);
129
Fernando Luis Vazquez Cao2f4dfe22007-05-09 02:33:25 -0700130#else /* CONFIG_SMP */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132#define cpu_logical_id(i) 0
133#define cpu_physical_id(i) ia64_get_lid()
134
135#endif /* CONFIG_SMP */
136#endif /* _ASM_IA64_SMP_H */