Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel'
[palacios.git] / kitten / include / arch-x86_64 / smp.h
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 <linux/threads.h>s */
9 #include <lwk/cpumask.h>
10 #include <lwk/bitops.h>
11 extern int disable_apic;
12 #endif
13
14 #ifndef __ASSEMBLY__
15 #include <arch/fixmap.h>
16 //#include <asm/mpspec.h>
17 //#include <asm/io_apic.h>
18 #include <arch/apic.h>
19 //#include <asm/thread_info.h>
20 #include <arch/pda.h>
21
22 struct pt_regs;
23
24 extern cpumask_t cpu_present_mask;
25 extern cpumask_t cpu_possible_map;
26 extern cpumask_t cpu_online_map;
27 extern cpumask_t cpu_callout_map;
28 extern cpumask_t cpu_initialized;
29
30 /*
31  * Private routines/data
32  */
33  
34 extern void smp_alloc_memory(void);
35 extern volatile unsigned long smp_invalidate_needed;
36 extern int pic_mode;
37 extern void lock_ipi_call_lock(void);
38 extern void unlock_ipi_call_lock(void);
39 extern int smp_num_siblings;
40 extern void smp_send_reschedule(int cpu);
41 void smp_stop_cpu(void);
42 extern int smp_call_function_single(int cpuid, void (*func) (void *info),
43                                 void *info, int retry, int wait);
44
45 extern cpumask_t cpu_sibling_map[NR_CPUS];
46 extern cpumask_t cpu_core_map[NR_CPUS];
47 extern uint16_t phys_proc_id[NR_CPUS];
48 extern uint16_t cpu_core_id[NR_CPUS];
49 extern uint16_t cpu_llc_id[NR_CPUS];
50
51 #define SMP_TRAMPOLINE_BASE 0x6000
52
53 /*
54  * On x86 all CPUs are mapped 1:1 to the APIC space.
55  * This simplifies scheduling and IPI sending and
56  * compresses data structures.
57  */
58
59 static inline int num_booting_cpus(void)
60 {
61         return cpus_weight(cpu_callout_map);
62 }
63
64 #define raw_smp_processor_id() read_pda(cpunumber)
65
66 static inline int hard_smp_processor_id(void)
67 {
68         /* we don't want to mark this access volatile - bad code generation */
69         return GET_APIC_ID(*(unsigned int *)(APIC_BASE+APIC_ID));
70 }
71
72 extern int safe_smp_processor_id(void);
73 extern int __cpu_disable(void);
74 extern void __cpu_die(unsigned int cpu);
75 extern void prefill_possible_map(void);
76 extern unsigned num_processors;
77 extern unsigned disabled_cpus;
78
79 #endif /* !ASSEMBLY */
80
81 #define NO_PROC_ID              0xFF            /* No processor magic marker */
82
83
84 #ifndef ASSEMBLY
85 /*
86  * Some lowlevel functions might want to know about
87  * the real APIC ID <-> CPU # mapping.
88  */
89 extern u8 x86_cpu_to_apicid[NR_CPUS];   /* physical ID */
90 extern u8 x86_cpu_to_log_apicid[NR_CPUS];
91 extern u8 bios_cpu_apicid[];
92
93 static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
94 {
95         return cpus_addr(cpumask)[0];
96 }
97
98 static inline int cpu_present_to_apicid(int mps_cpu)
99 {
100         if (mps_cpu < NR_CPUS)
101                 return (int)bios_cpu_apicid[mps_cpu];
102         else
103                 return BAD_APICID;
104 }
105
106 #endif /* !ASSEMBLY */
107
108 #include <lwk/task.h>
109 #define stack_smp_processor_id() \
110 ({                                                                      \
111         struct task_struct *task;                                               \
112         __asm__("andq %%rsp,%0; ":"=r" (task) : "0" (CURRENT_MASK));    \
113         task->arch.cpu;                                                 \
114 })
115
116 #ifndef __ASSEMBLY__
117 static __inline int logical_smp_processor_id(void)
118 {
119         /* we don't want to mark this access volatile - bad code generation */
120         return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR));
121 }
122 #endif
123
124 #define cpu_physical_id(cpu)            x86_cpu_to_apicid[cpu]
125
126 #endif
127