1 #ifndef __ASM_SMP_H
2 #define __ASM_SMP_H
3 
4 /*
5  * We need the APIC definitions automatically as part of 'smp.h'
6  */
7 #ifndef __ASSEMBLY__
8 #include <xen/bitops.h>
9 #include <xen/kernel.h>
10 #include <xen/cpumask.h>
11 #include <asm/current.h>
12 #include <asm/mpspec.h>
13 #endif
14 
15 #define BAD_APICID   (-1U)
16 #define INVALID_CUID (~0U)   /* AMD Compute Unit ID */
17 #ifndef __ASSEMBLY__
18 
19 /*
20  * Private routines/data
21  */
22 DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_mask);
23 DECLARE_PER_CPU(cpumask_var_t, cpu_core_mask);
24 DECLARE_PER_CPU(cpumask_var_t, scratch_cpumask);
25 DECLARE_PER_CPU(cpumask_var_t, send_ipi_cpumask);
26 
27 /*
28  * Do we, for platform reasons, need to actually keep CPUs online when we
29  * would otherwise prefer them to be off?
30  */
31 extern bool park_offline_cpus;
32 
33 void smp_send_nmi_allbutself(void);
34 
35 void send_IPI_mask(const cpumask_t *, int vector);
36 void send_IPI_self(int vector);
37 
38 extern void (*mtrr_hook) (void);
39 
40 extern void zap_low_mappings(void);
41 
42 extern u32 x86_cpu_to_apicid[];
43 
44 #define cpu_physical_id(cpu)	x86_cpu_to_apicid[cpu]
45 
46 #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
47 extern void cpu_exit_clear(unsigned int cpu);
48 extern void cpu_uninit(unsigned int cpu);
49 int cpu_add(uint32_t apic_id, uint32_t acpi_id, uint32_t pxm);
50 
51 /*
52  * This function is needed by all SMP systems. It must _always_ be valid
53  * from the initial startup. We map APIC_BASE very early in page_setup(),
54  * so this is correct in the x86 case.
55  */
56 #define smp_processor_id() get_processor_id()
57 
58 void __stop_this_cpu(void);
59 
60 long cpu_up_helper(void *data);
61 long cpu_down_helper(void *data);
62 
63 long core_parking_helper(void *data);
64 bool core_parking_remove(unsigned int cpu);
65 uint32_t get_cur_idle_nums(void);
66 
67 /*
68  * The value may be greater than the actual socket number in the system and
69  * is required not to change from the initial startup.
70  */
71 extern unsigned int nr_sockets;
72 
73 void set_nr_sockets(void);
74 
75 /* Representing HT and core siblings in each socket. */
76 extern cpumask_t **socket_cpumask;
77 
78 /*
79  * To be used only while no context switch can occur on the cpu, i.e.
80  * by certain scheduling code only.
81  */
82 #define get_cpu_current(cpu) \
83     (get_cpu_info_from_stack((unsigned long)stack_base[cpu])->current_vcpu)
84 
85 extern unsigned int disabled_cpus;
86 extern bool unaccounted_cpus;
87 
88 #endif /* !__ASSEMBLY__ */
89 
90 #endif
91