blob: cd022121cab611629ec9b04de51677e44bef3567 [file] [log] [blame]
Ingo Molnar77ad3862008-03-21 15:23:19 +01001#include <linux/io.h>
2
3#include <asm/trampoline.h>
Rafael J. Wysocki3e1e9002008-12-08 00:50:22 +01004#include <asm/e820.h>
Ingo Molnar77ad3862008-03-21 15:23:19 +01005
Jan Beulich7a4b7e52009-10-06 16:32:43 +01006#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
Yinghai Lua4c81cf2008-05-18 01:18:57 -070014/* ready for x86_64 and x86 */
Jan Beulich7a4b7e52009-10-06 16:32:43 +010015unsigned char *__trampinitdata trampoline_base = __va(TRAMPOLINE_BASE);
Ingo Molnar77ad3862008-03-21 15:23:19 +010016
Rafael J. Wysocki3e1e9002008-12-08 00:50:22 +010017void __init reserve_trampoline_memory(void)
18{
19#ifdef CONFIG_X86_32
20 /*
21 * But first pinch a few for the stack/trampoline stuff
22 * FIXME: Don't need the extra page at 4K, but need to fix
23 * trampoline before removing it. (see the GDT stuff)
24 */
25 reserve_early(PAGE_SIZE, PAGE_SIZE + PAGE_SIZE, "EX TRAMPOLINE");
26#endif
27 /* Has to be in very low memory so we can execute real-mode AP code. */
28 reserve_early(TRAMPOLINE_BASE, TRAMPOLINE_BASE + TRAMPOLINE_SIZE,
29 "TRAMPOLINE");
30}
31
Ingo Molnar77ad3862008-03-21 15:23:19 +010032/*
33 * Currently trivial. Write the real->protected mode
34 * bootstrap into the page concerned. The caller
35 * has made sure it's suitably aligned.
36 */
Jan Beulich7a4b7e52009-10-06 16:32:43 +010037unsigned long __trampinit setup_trampoline(void)
Ingo Molnar77ad3862008-03-21 15:23:19 +010038{
Rafael J. Wysocki3e1e9002008-12-08 00:50:22 +010039 memcpy(trampoline_base, trampoline_data, TRAMPOLINE_SIZE);
Ingo Molnar77ad3862008-03-21 15:23:19 +010040 return virt_to_phys(trampoline_base);
41}