kexec.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #ifndef LINUX_KEXEC_H
  2. #define LINUX_KEXEC_H
  3. #ifdef CONFIG_KEXEC
  4. #include <linux/types.h>
  5. #include <linux/list.h>
  6. #include <linux/linkage.h>
  7. #include <linux/compat.h>
  8. #include <asm/kexec.h>
  9. /* Verify architecture specific macros are defined */
  10. #ifndef KEXEC_SOURCE_MEMORY_LIMIT
  11. #error KEXEC_SOURCE_MEMORY_LIMIT not defined
  12. #endif
  13. #ifndef KEXEC_DESTINATION_MEMORY_LIMIT
  14. #error KEXEC_DESTINATION_MEMORY_LIMIT not defined
  15. #endif
  16. #ifndef KEXEC_CONTROL_MEMORY_LIMIT
  17. #error KEXEC_CONTROL_MEMORY_LIMIT not defined
  18. #endif
  19. #ifndef KEXEC_CONTROL_CODE_SIZE
  20. #error KEXEC_CONTROL_CODE_SIZE not defined
  21. #endif
  22. #ifndef KEXEC_ARCH
  23. #error KEXEC_ARCH not defined
  24. #endif
  25. /*
  26. * This structure is used to hold the arguments that are used when loading
  27. * kernel binaries.
  28. */
  29. typedef unsigned long kimage_entry_t;
  30. #define IND_DESTINATION 0x1
  31. #define IND_INDIRECTION 0x2
  32. #define IND_DONE 0x4
  33. #define IND_SOURCE 0x8
  34. #define KEXEC_SEGMENT_MAX 8
  35. struct kexec_segment {
  36. void __user *buf;
  37. size_t bufsz;
  38. unsigned long mem; /* User space sees this as a (void *) ... */
  39. size_t memsz;
  40. };
  41. #ifdef CONFIG_COMPAT
  42. struct compat_kexec_segment {
  43. compat_uptr_t buf;
  44. compat_size_t bufsz;
  45. compat_ulong_t mem; /* User space sees this as a (void *) ... */
  46. compat_size_t memsz;
  47. };
  48. #endif
  49. struct kimage {
  50. kimage_entry_t head;
  51. kimage_entry_t *entry;
  52. kimage_entry_t *last_entry;
  53. unsigned long destination;
  54. unsigned long start;
  55. struct page *control_code_page;
  56. unsigned long nr_segments;
  57. struct kexec_segment segment[KEXEC_SEGMENT_MAX];
  58. struct list_head control_pages;
  59. struct list_head dest_pages;
  60. struct list_head unuseable_pages;
  61. /* Address of next control page to allocate for crash kernels. */
  62. unsigned long control_page;
  63. /* Flags to indicate special processing */
  64. unsigned int type : 1;
  65. #define KEXEC_TYPE_DEFAULT 0
  66. #define KEXEC_TYPE_CRASH 1
  67. };
  68. /* kexec interface functions */
  69. extern NORET_TYPE void machine_kexec(struct kimage *image) ATTRIB_NORET;
  70. extern int machine_kexec_prepare(struct kimage *image);
  71. extern void machine_kexec_cleanup(struct kimage *image);
  72. extern asmlinkage long sys_kexec_load(unsigned long entry,
  73. unsigned long nr_segments,
  74. struct kexec_segment __user *segments,
  75. unsigned long flags);
  76. #ifdef CONFIG_COMPAT
  77. extern asmlinkage long compat_sys_kexec_load(unsigned long entry,
  78. unsigned long nr_segments,
  79. struct compat_kexec_segment __user *segments,
  80. unsigned long flags);
  81. #endif
  82. extern struct page *kimage_alloc_control_pages(struct kimage *image,
  83. unsigned int order);
  84. extern void crash_kexec(struct pt_regs *);
  85. int kexec_should_crash(struct task_struct *);
  86. extern struct kimage *kexec_image;
  87. #define KEXEC_ON_CRASH 0x00000001
  88. #define KEXEC_ARCH_MASK 0xffff0000
  89. /* These values match the ELF architecture values.
  90. * Unless there is a good reason that should continue to be the case.
  91. */
  92. #define KEXEC_ARCH_DEFAULT ( 0 << 16)
  93. #define KEXEC_ARCH_386 ( 3 << 16)
  94. #define KEXEC_ARCH_X86_64 (62 << 16)
  95. #define KEXEC_ARCH_PPC (20 << 16)
  96. #define KEXEC_ARCH_PPC64 (21 << 16)
  97. #define KEXEC_ARCH_IA_64 (50 << 16)
  98. #define KEXEC_ARCH_S390 (22 << 16)
  99. #define KEXEC_FLAGS (KEXEC_ON_CRASH) /* List of defined/legal kexec flags */
  100. /* Location of a reserved region to hold the crash kernel.
  101. */
  102. extern struct resource crashk_res;
  103. #else /* !CONFIG_KEXEC */
  104. struct pt_regs;
  105. struct task_struct;
  106. static inline void crash_kexec(struct pt_regs *regs) { }
  107. static inline int kexec_should_crash(struct task_struct *p) { return 0; }
  108. #endif /* CONFIG_KEXEC */
  109. #endif /* LINUX_KEXEC_H */