2008-03-21 22:23:19 +08:00
|
|
|
#include <linux/io.h>
|
|
|
|
|
|
|
|
#include <asm/trampoline.h>
|
2008-12-08 07:50:22 +08:00
|
|
|
#include <asm/e820.h>
|
2008-03-21 22:23:19 +08:00
|
|
|
|
2009-10-06 23:32:43 +08:00
|
|
|
#if defined(CONFIG_X86_64) && defined(CONFIG_ACPI_SLEEP)
|
|
|
|
#define __trampinit
|
|
|
|
#define __trampinitdata
|
|
|
|
#else
|
|
|
|
#define __trampinit __cpuinit
|
|
|
|
#define __trampinitdata __cpuinitdata
|
|
|
|
#endif
|
|
|
|
|
2008-05-18 16:18:57 +08:00
|
|
|
/* ready for x86_64 and x86 */
|
2009-12-11 05:07:22 +08:00
|
|
|
unsigned char *__trampinitdata trampoline_base;
|
2008-03-21 22:23:19 +08:00
|
|
|
|
2008-12-08 07:50:22 +08:00
|
|
|
void __init reserve_trampoline_memory(void)
|
|
|
|
{
|
2009-12-11 05:07:22 +08:00
|
|
|
unsigned long mem;
|
|
|
|
|
2008-12-08 07:50:22 +08:00
|
|
|
/* Has to be in very low memory so we can execute real-mode AP code. */
|
2009-12-11 05:07:22 +08:00
|
|
|
mem = find_e820_area(0, 1<<20, TRAMPOLINE_SIZE, PAGE_SIZE);
|
|
|
|
if (mem == -1L)
|
|
|
|
panic("Cannot allocate trampoline\n");
|
|
|
|
|
|
|
|
trampoline_base = __va(mem);
|
|
|
|
reserve_early(mem, mem + TRAMPOLINE_SIZE, "TRAMPOLINE");
|
2008-12-08 07:50:22 +08:00
|
|
|
}
|
|
|
|
|
2008-03-21 22:23:19 +08:00
|
|
|
/*
|
|
|
|
* Currently trivial. Write the real->protected mode
|
|
|
|
* bootstrap into the page concerned. The caller
|
|
|
|
* has made sure it's suitably aligned.
|
|
|
|
*/
|
2009-10-06 23:32:43 +08:00
|
|
|
unsigned long __trampinit setup_trampoline(void)
|
2008-03-21 22:23:19 +08:00
|
|
|
{
|
2008-12-08 07:50:22 +08:00
|
|
|
memcpy(trampoline_base, trampoline_data, TRAMPOLINE_SIZE);
|
2008-03-21 22:23:19 +08:00
|
|
|
return virt_to_phys(trampoline_base);
|
|
|
|
}
|