kexec.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2019 FORTH-ICS/CARV
  4. * Nick Kossifidis <[email protected]>
  5. */
  6. #ifndef _RISCV_KEXEC_H
  7. #define _RISCV_KEXEC_H
  8. #include <asm/page.h> /* For PAGE_SIZE */
  9. /* Maximum physical address we can use pages from */
  10. #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
  11. /* Maximum address we can reach in physical address mode */
  12. #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
  13. /* Maximum address we can use for the control code buffer */
  14. #define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
  15. /* Reserve a page for the control code buffer */
  16. #define KEXEC_CONTROL_PAGE_SIZE PAGE_SIZE
  17. #define KEXEC_ARCH KEXEC_ARCH_RISCV
  18. extern void riscv_crash_save_regs(struct pt_regs *newregs);
  19. static inline void
  20. crash_setup_regs(struct pt_regs *newregs,
  21. struct pt_regs *oldregs)
  22. {
  23. if (oldregs)
  24. memcpy(newregs, oldregs, sizeof(struct pt_regs));
  25. else
  26. riscv_crash_save_regs(newregs);
  27. }
  28. #define ARCH_HAS_KIMAGE_ARCH
  29. struct kimage_arch {
  30. void *fdt; /* For CONFIG_KEXEC_FILE */
  31. unsigned long fdt_addr;
  32. };
  33. extern const unsigned char riscv_kexec_relocate[];
  34. extern const unsigned int riscv_kexec_relocate_size;
  35. typedef void (*riscv_kexec_method)(unsigned long first_ind_entry,
  36. unsigned long jump_addr,
  37. unsigned long fdt_addr,
  38. unsigned long hartid,
  39. unsigned long va_pa_off);
  40. extern riscv_kexec_method riscv_kexec_norelocate;
  41. #ifdef CONFIG_KEXEC_FILE
  42. extern const struct kexec_file_ops elf_kexec_ops;
  43. struct purgatory_info;
  44. int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
  45. Elf_Shdr *section,
  46. const Elf_Shdr *relsec,
  47. const Elf_Shdr *symtab);
  48. #define arch_kexec_apply_relocations_add arch_kexec_apply_relocations_add
  49. struct kimage;
  50. int arch_kimage_file_post_load_cleanup(struct kimage *image);
  51. #define arch_kimage_file_post_load_cleanup arch_kimage_file_post_load_cleanup
  52. #endif
  53. #endif