trampoline.c 1014 Bytes
Newer Older
Ingo Molnar's avatar
Ingo Molnar committed
1
2
3
#include <linux/io.h>

#include <asm/trampoline.h>
4
#include <asm/pgtable.h>
5
#include <asm/e820.h>
Ingo Molnar's avatar
Ingo Molnar committed
6

7
8
9
10
11
12
13
14
#if defined(CONFIG_X86_64) && defined(CONFIG_ACPI_SLEEP)
#define __trampinit
#define __trampinitdata
#else
#define __trampinit __cpuinit
#define __trampinitdata __cpuinitdata
#endif

15
/* ready for x86_64 and x86 */
16
unsigned char *__trampinitdata trampoline_base;
Ingo Molnar's avatar
Ingo Molnar committed
17

18
19
void __init reserve_trampoline_memory(void)
{
20
21
	unsigned long mem;

22
	/* Has to be in very low memory so we can execute real-mode AP code. */
23
24
25
26
27
28
	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");
29
30
}

Ingo Molnar's avatar
Ingo Molnar committed
31
32
33
34
35
/*
 * Currently trivial. Write the real->protected mode
 * bootstrap into the page concerned. The caller
 * has made sure it's suitably aligned.
 */
36
unsigned long __trampinit setup_trampoline(void)
Ingo Molnar's avatar
Ingo Molnar committed
37
{
38
	memcpy(trampoline_base, trampoline_data, TRAMPOLINE_SIZE);
Ingo Molnar's avatar
Ingo Molnar committed
39
40
	return virt_to_phys(trampoline_base);
}