kexec.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. /* Kernel + gzip rootfs (PACK_MAX is 4 MB) or a raw runtime pack, which
  11. * ramfs caps at RAMFS_MAX_DECOMPRESSED (8 MB). */
  12. #define KEXEC_MAX 0x800000
  13. /* Allocate the staging buffer for an image of `size` bytes (contiguous,
  14. * page-aligned, identity-mapped). Sets kexec_stage; returns 1 on success. */
  15. int kexec_stage_alloc(unsigned int size);
  16. /* Free a staging buffer allocated by kexec_stage_alloc(). */
  17. void kexec_stage_free(void);
  18. /* Physical base of the staging buffer holding the received image. */
  19. extern unsigned int kexec_stage;
  20. /* Copy the staged kernel (`kernel_size` bytes) over the kernel region,
  21. * relocate the trampoline and jump to `entry`. `pack_addr`/`pack_size`
  22. * describe the boot-time rootfs source; a zero pack_size means "keep the
  23. * running ramfs". Never returns. */
  24. void kexec_jump(unsigned int entry, unsigned int kernel_size,
  25. unsigned int pack_addr, unsigned int pack_size);
  26. /* Non-zero while a kexec receive is in progress (prevents double-trigger). */
  27. extern volatile int kexec_busy;
  28. /* Receive progress, in bytes. kexec_total is 0 until the header is parsed. */
  29. extern volatile unsigned int kexec_progress;
  30. extern volatile unsigned int kexec_total;
  31. /* Returns 1 if the serial ring buffer starts with the "KXE2" magic, i.e. the
  32. * host has begun sending a new kernel/rootfs image. */
  33. int kexec_pending(void);
  34. #endif