kexec.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 kernel (`kernel_size` bytes) over the kernel region,
  19. * relocate the trampoline and jump to `entry`. `pack_addr`/`pack_size`
  20. * describe the boot-time rootfs source; a zero pack_size means "keep the
  21. * running ramfs". Never returns. */
  22. void kexec_jump(unsigned int entry, unsigned int kernel_size,
  23. unsigned int pack_addr, unsigned int pack_size);
  24. /* Non-zero while a kexec receive is in progress (prevents double-trigger). */
  25. extern volatile int kexec_busy;
  26. /* Receive progress, in bytes. kexec_total is 0 until the header is parsed. */
  27. extern volatile unsigned int kexec_progress;
  28. extern volatile unsigned int kexec_total;
  29. /* Returns 1 if the serial ring buffer starts with the "KXE2" magic, i.e. the
  30. * host has begun sending a new kernel/rootfs image. */
  31. int kexec_pending(void);
  32. #endif