blob: 2984e262fc6c2e3b1e18d201d8cd296ce2b5c918 [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>
Isaku Yamahata444933c2008-05-19 22:13:28 +090018#include <linux/irqreturn.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#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
Xiantao Zhang31a6b112008-04-03 11:39:43 -070042extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
43 void *info, int wait);
44
Fernando Luis Vazquez Cao818563d2007-05-09 02:33:28 -070045#define hard_smp_processor_id() ia64_get_lid()
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#ifdef CONFIG_SMP
48
49#define XTP_OFFSET 0x1e0008
50
51#define SMP_IRQ_REDIRECTION (1 << 0)
52#define SMP_IPI_REDIRECTION (1 << 1)
53
Ingo Molnar39c715b2005-06-21 17:14:34 -070054#define raw_smp_processor_id() (current_thread_info()->cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56extern struct smp_boot_data {
57 int cpu_count;
58 int cpu_phys_id[NR_CPUS];
59} smp_boot_data __initdata;
60
61extern char no_int_routing __devinitdata;
62
63extern cpumask_t cpu_online_map;
Suresh Siddhae927ecb2005-04-25 13:25:06 -070064extern cpumask_t cpu_core_map[NR_CPUS];
Mike Travisd5a74302007-10-16 01:24:05 -070065DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
Suresh Siddhae927ecb2005-04-25 13:25:06 -070066extern int smp_num_siblings;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067extern void __iomem *ipi_base_addr;
68extern unsigned char smp_int_redirect;
69
70extern volatile int ia64_cpu_to_sapicid[];
71#define cpu_physical_id(i) ia64_cpu_to_sapicid[i]
72
73extern unsigned long ap_wakeup_vector;
74
75/*
76 * Function to map hard smp processor id to logical id. Slow, so don't use this in
77 * performance-critical code.
78 */
79static inline int
80cpu_logical_id (int cpuid)
81{
82 int i;
83
84 for (i = 0; i < NR_CPUS; ++i)
85 if (cpu_physical_id(i) == cpuid)
86 break;
87 return i;
88}
89
90/*
91 * XTP control functions:
92 * min_xtp : route all interrupts to this CPU
93 * normal_xtp: nominal XTP value
94 * max_xtp : never deliver interrupts to this CPU.
95 */
96
97static inline void
98min_xtp (void)
99{
100 if (smp_int_redirect & SMP_IRQ_REDIRECTION)
101 writeb(0x00, ipi_base_addr + XTP_OFFSET); /* XTP to min */
102}
103
104static inline void
105normal_xtp (void)
106{
107 if (smp_int_redirect & SMP_IRQ_REDIRECTION)
108 writeb(0x08, ipi_base_addr + XTP_OFFSET); /* XTP normal */
109}
110
111static inline void
112max_xtp (void)
113{
114 if (smp_int_redirect & SMP_IRQ_REDIRECTION)
115 writeb(0x0f, ipi_base_addr + XTP_OFFSET); /* Set XTP to max */
116}
117
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118/* Upping and downing of CPUs */
119extern int __cpu_disable (void);
120extern void __cpu_die (unsigned int cpu);
121extern void cpu_die (void) __attribute__ ((noreturn));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122extern void __init smp_build_cpu_map(void);
123
124extern void __init init_smp_config (void);
125extern void smp_do_timer (struct pt_regs *regs);
126
Isaku Yamahata444933c2008-05-19 22:13:28 +0900127extern irqreturn_t handle_IPI(int irq, void *dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128extern void smp_send_reschedule (int cpu);
129extern void lock_ipi_calllock(void);
130extern void unlock_ipi_calllock(void);
Suresh Siddhae927ecb2005-04-25 13:25:06 -0700131extern void identify_siblings (struct cpuinfo_ia64 *);
Stephane Eraniandd562c02006-09-21 10:35:44 -0700132extern int is_multithreading_enabled(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
Fernando Luis Vazquez Cao2f4dfe22007-05-09 02:33:25 -0700134#else /* CONFIG_SMP */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136#define cpu_logical_id(i) 0
137#define cpu_physical_id(i) ia64_get_lid()
138
139#endif /* CONFIG_SMP */
140#endif /* _ASM_IA64_SMP_H */