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 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 20#include <asm/io.h> 21#include <asm/param.h> 22#include <asm/processor.h> 23#include <asm/ptrace.h> 24 25#define XTP_OFFSET 0x1e0008 26 27#define SMP_IRQ_REDIRECTION (1 << 0) 28#define SMP_IPI_REDIRECTION (1 << 1) 29 30#define smp_processor_id() (current->processor) 31 32extern struct smp_boot_data { 33 int cpu_count; 34 int cpu_phys_id[NR_CPUS]; 35} smp_boot_data __initdata; 36 37extern char no_int_routing __initdata; 38 39extern volatile unsigned long cpu_online_map; 40extern unsigned long ipi_base_addr; 41extern unsigned char smp_int_redirect; 42extern int smp_num_cpus; 43 44extern volatile int ia64_cpu_to_sapicid[]; 45#define cpu_physical_id(i) ia64_cpu_to_sapicid[i] 46#define cpu_number_map(i) (i) 47#define cpu_logical_map(i) (i) 48 49extern unsigned long ap_wakeup_vector; 50 51/* 52 * Function to map hard smp processor id to logical id. Slow, so 53 * don't use this in performance-critical code. 54 */ 55static inline int 56cpu_logical_id (int cpuid) 57{ 58 int i; 59 60 for (i = 0; i < smp_num_cpus; ++i) 61 if (cpu_physical_id(i) == (__u32) cpuid) 62 break; 63 return i; 64} 65 66/* 67 * XTP control functions: 68 * min_xtp : route all interrupts to this CPU 69 * normal_xtp: nominal XTP value 70 * max_xtp : never deliver interrupts to this CPU. 71 */ 72 73static inline void 74min_xtp (void) 75{ 76 if (smp_int_redirect & SMP_IRQ_REDIRECTION) 77 writeb(0x00, ipi_base_addr | XTP_OFFSET); /* XTP to min */ 78} 79 80static inline void 81normal_xtp (void) 82{ 83 if (smp_int_redirect & SMP_IRQ_REDIRECTION) 84 writeb(0x08, ipi_base_addr | XTP_OFFSET); /* XTP normal */ 85} 86 87static inline void 88max_xtp (void) 89{ 90 if (smp_int_redirect & SMP_IRQ_REDIRECTION) 91 writeb(0x0f, ipi_base_addr | XTP_OFFSET); /* Set XTP to max */ 92} 93 94static inline unsigned int 95hard_smp_processor_id (void) 96{ 97 union { 98 struct { 99 unsigned long reserved : 16; 100 unsigned long eid : 8; 101 unsigned long id : 8; 102 unsigned long ignored : 32; 103 } f; 104 unsigned long bits; 105 } lid; 106 107 lid.bits = ia64_get_lid(); 108 return lid.f.id << 8 | lid.f.eid; 109} 110 111#define NO_PROC_ID 0xffffffff /* no processor magic marker */ 112 113/* 114 * Extra overhead to move a task from one cpu to another (due to TLB and cache misses). 115 * Expressed in "negative nice value" units (larger number means higher priority/penalty). 116 */ 117#define PROC_CHANGE_PENALTY 20 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); 124 125 126#endif /* CONFIG_SMP */ 127#endif /* _ASM_IA64_SMP_H */ 128