suspend.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_SUSPEND_H
  3. #define __ASM_SUSPEND_H
  4. #define NR_CTX_REGS 13
  5. #define NR_CALLEE_SAVED_REGS 12
  6. /*
  7. * struct cpu_suspend_ctx must be 16-byte aligned since it is allocated on
  8. * the stack, which must be 16-byte aligned on v8
  9. */
  10. struct cpu_suspend_ctx {
  11. /*
  12. * This struct must be kept in sync with
  13. * cpu_do_{suspend/resume} in mm/proc.S
  14. */
  15. u64 ctx_regs[NR_CTX_REGS];
  16. u64 sp;
  17. } __aligned(16);
  18. /*
  19. * Memory to save the cpu state is allocated on the stack by
  20. * __cpu_suspend_enter()'s caller, and populated by __cpu_suspend_enter().
  21. * This data must survive until cpu_resume() is called.
  22. *
  23. * This struct desribes the size and the layout of the saved cpu state.
  24. * The layout of the callee_saved_regs is defined by the implementation
  25. * of __cpu_suspend_enter(), and cpu_resume(). This struct must be passed
  26. * in by the caller as __cpu_suspend_enter()'s stack-frame is gone once it
  27. * returns, and the data would be subsequently corrupted by the call to the
  28. * finisher.
  29. */
  30. struct sleep_stack_data {
  31. struct cpu_suspend_ctx system_regs;
  32. unsigned long callee_saved_regs[NR_CALLEE_SAVED_REGS];
  33. };
  34. extern unsigned long *sleep_save_stash;
  35. extern int cpu_suspend(unsigned long arg, int (*fn)(unsigned long));
  36. extern void cpu_resume(void);
  37. int __cpu_suspend_enter(struct sleep_stack_data *state);
  38. void __cpu_suspend_exit(void);
  39. void _cpu_resume(void);
  40. int swsusp_arch_suspend(void);
  41. int swsusp_arch_resume(void);
  42. int arch_hibernation_header_save(void *addr, unsigned int max_size);
  43. int arch_hibernation_header_restore(void *addr);
  44. /* Used to resume on the CPU we hibernated on */
  45. int hibernate_resume_nonboot_cpu_disable(void);
  46. #endif