trampoline.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <linux/io.h>
  2. #include <asm/trampoline.h>
  3. #include <asm/e820.h>
  4. #if defined(CONFIG_X86_64) && defined(CONFIG_ACPI_SLEEP)
  5. #define __trampinit
  6. #define __trampinitdata
  7. #else
  8. #define __trampinit __cpuinit
  9. #define __trampinitdata __cpuinitdata
  10. #endif
  11. /* ready for x86_64 and x86 */
  12. unsigned char *__trampinitdata trampoline_base = __va(TRAMPOLINE_BASE);
  13. void __init reserve_trampoline_memory(void)
  14. {
  15. #ifdef CONFIG_X86_32
  16. /*
  17. * But first pinch a few for the stack/trampoline stuff
  18. * FIXME: Don't need the extra page at 4K, but need to fix
  19. * trampoline before removing it. (see the GDT stuff)
  20. */
  21. reserve_early(PAGE_SIZE, PAGE_SIZE + PAGE_SIZE, "EX TRAMPOLINE");
  22. #endif
  23. /* Has to be in very low memory so we can execute real-mode AP code. */
  24. reserve_early(TRAMPOLINE_BASE, TRAMPOLINE_BASE + TRAMPOLINE_SIZE,
  25. "TRAMPOLINE");
  26. }
  27. /*
  28. * Currently trivial. Write the real->protected mode
  29. * bootstrap into the page concerned. The caller
  30. * has made sure it's suitably aligned.
  31. */
  32. unsigned long __trampinit setup_trampoline(void)
  33. {
  34. memcpy(trampoline_base, trampoline_data, TRAMPOLINE_SIZE);
  35. return virt_to_phys(trampoline_base);
  36. }