x86: move x86_cpu_to_apicid to setup.c
[deliverable/linux.git] / arch / x86 / kernel / setup.c
1 #include <linux/kernel.h>
2 #include <linux/module.h>
3 #include <linux/init.h>
4 #include <linux/bootmem.h>
5 #include <linux/percpu.h>
6 #include <asm/smp.h>
7 #include <asm/percpu.h>
8 #include <asm/sections.h>
9 #include <asm/processor.h>
10 #include <asm/setup.h>
11 #include <asm/topology.h>
12 #include <asm/apicdef.h>
13
14 DEFINE_PER_CPU(u16, x86_cpu_to_apicid) = BAD_APICID;
15 EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
16
17 #if defined(CONFIG_HAVE_SETUP_PER_CPU_AREA) && defined(CONFIG_SMP)
18 /*
19 * Copy data used in early init routines from the initial arrays to the
20 * per cpu data areas. These arrays then become expendable and the
21 * *_early_ptr's are zeroed indicating that the static arrays are gone.
22 */
23 static void __init setup_per_cpu_maps(void)
24 {
25 int cpu;
26
27 for_each_possible_cpu(cpu) {
28 per_cpu(x86_cpu_to_apicid, cpu) = x86_cpu_to_apicid_init[cpu];
29 per_cpu(x86_bios_cpu_apicid, cpu) =
30 x86_bios_cpu_apicid_init[cpu];
31 #ifdef CONFIG_NUMA
32 per_cpu(x86_cpu_to_node_map, cpu) =
33 x86_cpu_to_node_map_init[cpu];
34 #endif
35 }
36
37 /* indicate the early static arrays will soon be gone */
38 x86_cpu_to_apicid_early_ptr = NULL;
39 x86_bios_cpu_apicid_early_ptr = NULL;
40 #ifdef CONFIG_NUMA
41 x86_cpu_to_node_map_early_ptr = NULL;
42 #endif
43 }
44
45 #ifdef CONFIG_X86_32
46 /*
47 * Great future not-so-futuristic plan: make i386 and x86_64 do it
48 * the same way
49 */
50 unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
51 EXPORT_SYMBOL(__per_cpu_offset);
52 #endif
53
54 /*
55 * Great future plan:
56 * Declare PDA itself and support (irqstack,tss,pgd) as per cpu data.
57 * Always point %gs to its beginning
58 */
59 void __init setup_per_cpu_areas(void)
60 {
61 int i;
62 unsigned long size;
63
64 #ifdef CONFIG_HOTPLUG_CPU
65 prefill_possible_map();
66 #endif
67
68 /* Copy section for each CPU (we discard the original) */
69 size = PERCPU_ENOUGH_ROOM;
70 printk(KERN_INFO "PERCPU: Allocating %lu bytes of per cpu data\n",
71 size);
72
73 for_each_possible_cpu(i) {
74 char *ptr;
75 #ifndef CONFIG_NEED_MULTIPLE_NODES
76 ptr = alloc_bootmem_pages(size);
77 #else
78 int node = early_cpu_to_node(i);
79 if (!node_online(node) || !NODE_DATA(node)) {
80 ptr = alloc_bootmem_pages(size);
81 printk(KERN_INFO
82 "cpu %d has no node or node-local memory\n", i);
83 }
84 else
85 ptr = alloc_bootmem_pages_node(NODE_DATA(node), size);
86 #endif
87 if (!ptr)
88 panic("Cannot allocate cpu data for CPU %d\n", i);
89 #ifdef CONFIG_X86_64
90 cpu_pda(i)->data_offset = ptr - __per_cpu_start;
91 #else
92 __per_cpu_offset[i] = ptr - __per_cpu_start;
93 #endif
94 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
95 }
96
97 /* Setup percpu data maps */
98 setup_per_cpu_maps();
99 }
100
101 #endif
This page took 0.034939 seconds and 6 git commands to generate.