trampoline.c 934 B

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