kexec.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* kexec: hot-reload the kernel over serial without a reboot (C-light variant). */
  2. #ifndef KEXEC_H
  3. #define KEXEC_H
  4. void program_kexec_main(void);
  5. /* Kernel load address (the boot sector's) and a sanity cap for an incoming
  6. * image. The staging buffer itself is allocated on demand: it used to be a
  7. * fixed region below the VGA window, which forced the low-memory map to move
  8. * whenever the kernel grew. */
  9. #define KEXEC_LOAD 0x7E00
  10. #define KEXEC_MAX 0x400000
  11. /* Allocate the staging buffer for an image of `size` bytes (contiguous,
  12. * page-aligned, identity-mapped). Sets kexec_stage; returns 1 on success. */
  13. int kexec_stage_alloc(unsigned int size);
  14. /* Free a staging buffer allocated by kexec_stage_alloc(). */
  15. void kexec_stage_free(void);
  16. /* Physical base of the staging buffer holding the received image. */
  17. extern unsigned int kexec_stage;
  18. /* Copy the staged image (kexec_stage, `size` bytes) over the kernel region,
  19. * relocate the trampoline and jump to `entry`. Never returns. */
  20. void kexec_jump(unsigned int entry, unsigned int size);
  21. /* Non-zero while a kexec receive is in progress (prevents double-trigger). */
  22. extern volatile int kexec_busy;
  23. /* Receive progress, in bytes. kexec_total is 0 until the header is parsed. */
  24. extern volatile unsigned int kexec_progress;
  25. extern volatile unsigned int kexec_total;
  26. /* Returns 1 if the serial ring buffer starts with the "KXEC" magic, i.e. the
  27. * host has begun sending a new kernel image. */
  28. int kexec_pending(void);
  29. #endif