kexec.h 3.9 KB

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