blob: 808031a5ba19a62bee01b404a812d57409b60b7d [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
Yinghai Lua4c81cf2008-05-18 01:18:57 -07006/* ready for x86_64 and x86 */
Ingo Molnar77ad3862008-03-21 15:23:19 +01007unsigned char *trampoline_base = __va(TRAMPOLINE_BASE);
8
Rafael J. Wysocki3e1e9002008-12-08 00:50:22 +01009void __init reserve_trampoline_memory(void)
10{
11#ifdef CONFIG_X86_32
12 /*
13 * But first pinch a few for the stack/trampoline stuff
14 * FIXME: Don't need the extra page at 4K, but need to fix
15 * trampoline before removing it. (see the GDT stuff)
16 */
17 reserve_early(PAGE_SIZE, PAGE_SIZE + PAGE_SIZE, "EX TRAMPOLINE");
18#endif
19 /* Has to be in very low memory so we can execute real-mode AP code. */
20 reserve_early(TRAMPOLINE_BASE, TRAMPOLINE_BASE + TRAMPOLINE_SIZE,
21 "TRAMPOLINE");
22}
23
Ingo Molnar77ad3862008-03-21 15:23:19 +010024/*
25 * Currently trivial. Write the real->protected mode
26 * bootstrap into the page concerned. The caller
27 * has made sure it's suitably aligned.
28 */
29unsigned long setup_trampoline(void)
30{
Rafael J. Wysocki3e1e9002008-12-08 00:50:22 +010031 memcpy(trampoline_base, trampoline_data, TRAMPOLINE_SIZE);
Ingo Molnar77ad3862008-03-21 15:23:19 +010032 return virt_to_phys(trampoline_base);
33}