Glauber Costa | e32640a | 2008-03-03 14:12:45 -0300 | [diff] [blame] | 1 | /* |
| 2 | * SMP stuff which is common to all sub-architectures. |
| 3 | */ |
| 4 | #include <linux/module.h> |
| 5 | #include <asm/smp.h> |
| 6 | |
| 7 | #ifdef CONFIG_X86_32 |
| 8 | DEFINE_PER_CPU(unsigned long, this_cpu_off); |
| 9 | EXPORT_PER_CPU_SYMBOL(this_cpu_off); |
| 10 | |
Alex Nixon | fc0091b | 2008-08-15 17:21:14 +0100 | [diff] [blame] | 11 | /* |
| 12 | * Initialize the CPU's GDT. This is either the boot CPU doing itself |
| 13 | * (still using the master per-cpu area), or a CPU doing it for a |
| 14 | * secondary which will soon come up. |
| 15 | */ |
Glauber Costa | e32640a | 2008-03-03 14:12:45 -0300 | [diff] [blame] | 16 | __cpuinit void init_gdt(int cpu) |
| 17 | { |
Alex Nixon | fc0091b | 2008-08-15 17:21:14 +0100 | [diff] [blame] | 18 | struct desc_struct gdt; |
Glauber Costa | e32640a | 2008-03-03 14:12:45 -0300 | [diff] [blame] | 19 | |
Alex Nixon | fc0091b | 2008-08-15 17:21:14 +0100 | [diff] [blame] | 20 | pack_descriptor(&gdt, __per_cpu_offset[cpu], 0xFFFFF, |
Glauber Costa | e32640a | 2008-03-03 14:12:45 -0300 | [diff] [blame] | 21 | 0x2 | DESCTYPE_S, 0x8); |
Alex Nixon | fc0091b | 2008-08-15 17:21:14 +0100 | [diff] [blame] | 22 | gdt.s = 1; |
Glauber Costa | e32640a | 2008-03-03 14:12:45 -0300 | [diff] [blame] | 23 | |
Alex Nixon | fc0091b | 2008-08-15 17:21:14 +0100 | [diff] [blame] | 24 | write_gdt_entry(get_cpu_gdt_table(cpu), |
| 25 | GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S); |
Glauber Costa | e32640a | 2008-03-03 14:12:45 -0300 | [diff] [blame] | 26 | |
| 27 | per_cpu(this_cpu_off, cpu) = __per_cpu_offset[cpu]; |
| 28 | per_cpu(cpu_number, cpu) = cpu; |
| 29 | } |
| 30 | #endif |