Merge branch 'fix/hda' into for-linus
[sfrench/cifs-2.6.git] / arch / x86 / kernel / trampoline.c
1 #include <linux/io.h>
2
3 #include <asm/trampoline.h>
4 #include <asm/e820.h>
5
6 #if defined(CONFIG_X86_64) && defined(CONFIG_ACPI_SLEEP)
7 #define __trampinit
8 #define __trampinitdata
9 #else
10 #define __trampinit __cpuinit
11 #define __trampinitdata __cpuinitdata
12 #endif
13
14 /* ready for x86_64 and x86 */
15 unsigned char *__trampinitdata trampoline_base;
16
17 void __init reserve_trampoline_memory(void)
18 {
19         unsigned long mem;
20
21         /* Has to be in very low memory so we can execute real-mode AP code. */
22         mem = find_e820_area(0, 1<<20, TRAMPOLINE_SIZE, PAGE_SIZE);
23         if (mem == -1L)
24                 panic("Cannot allocate trampoline\n");
25
26         trampoline_base = __va(mem);
27         reserve_early(mem, mem + TRAMPOLINE_SIZE, "TRAMPOLINE");
28 }
29
30 /*
31  * Currently trivial. Write the real->protected mode
32  * bootstrap into the page concerned. The caller
33  * has made sure it's suitably aligned.
34  */
35 unsigned long __trampinit setup_trampoline(void)
36 {
37         memcpy(trampoline_base, trampoline_data, TRAMPOLINE_SIZE);
38         return virt_to_phys(trampoline_base);
39 }