suspend.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef _LINUX_SWSUSP_H
  2. #define _LINUX_SWSUSP_H
  3. #if defined(CONFIG_X86) || defined(CONFIG_FRV) || defined(CONFIG_PPC32) || defined(CONFIG_PPC64)
  4. #include <asm/suspend.h>
  5. #endif
  6. #include <linux/swap.h>
  7. #include <linux/notifier.h>
  8. #include <linux/init.h>
  9. #include <linux/pm.h>
  10. #include <linux/mm.h>
  11. /* struct pbe is used for creating lists of pages that should be restored
  12. * atomically during the resume from disk, because the page frames they have
  13. * occupied before the suspend are in use.
  14. */
  15. struct pbe {
  16. void *address; /* address of the copy */
  17. void *orig_address; /* original address of a page */
  18. struct pbe *next;
  19. };
  20. /* mm/page_alloc.c */
  21. extern void drain_local_pages(void);
  22. extern void mark_free_pages(struct zone *zone);
  23. #if defined(CONFIG_PM) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
  24. extern int pm_prepare_console(void);
  25. extern void pm_restore_console(void);
  26. #else
  27. static inline int pm_prepare_console(void) { return 0; }
  28. static inline void pm_restore_console(void) {}
  29. #endif
  30. /**
  31. * struct hibernation_ops - hibernation platform support
  32. *
  33. * The methods in this structure allow a platform to override the default
  34. * mechanism of shutting down the machine during a hibernation transition.
  35. *
  36. * All three methods must be assigned.
  37. *
  38. * @prepare: prepare system for hibernation
  39. * @enter: shut down system after state has been saved to disk
  40. * @finish: finish/clean up after state has been reloaded
  41. * @pre_restore: prepare system for the restoration from a hibernation image
  42. * @restore_cleanup: clean up after a failing image restoration
  43. */
  44. struct hibernation_ops {
  45. int (*prepare)(void);
  46. int (*enter)(void);
  47. void (*finish)(void);
  48. int (*pre_restore)(void);
  49. void (*restore_cleanup)(void);
  50. };
  51. #if defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND)
  52. /* kernel/power/snapshot.c */
  53. extern void __register_nosave_region(unsigned long b, unsigned long e, int km);
  54. static inline void register_nosave_region(unsigned long b, unsigned long e)
  55. {
  56. __register_nosave_region(b, e, 0);
  57. }
  58. static inline void register_nosave_region_late(unsigned long b, unsigned long e)
  59. {
  60. __register_nosave_region(b, e, 1);
  61. }
  62. extern int swsusp_page_is_forbidden(struct page *);
  63. extern void swsusp_set_page_free(struct page *);
  64. extern void swsusp_unset_page_free(struct page *);
  65. extern unsigned long get_safe_page(gfp_t gfp_mask);
  66. extern void hibernation_set_ops(struct hibernation_ops *ops);
  67. extern int hibernate(void);
  68. #else
  69. static inline void register_nosave_region(unsigned long b, unsigned long e) {}
  70. static inline void register_nosave_region_late(unsigned long b, unsigned long e) {}
  71. static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
  72. static inline void swsusp_set_page_free(struct page *p) {}
  73. static inline void swsusp_unset_page_free(struct page *p) {}
  74. static inline void hibernation_set_ops(struct hibernation_ops *ops) {}
  75. static inline int hibernate(void) { return -ENOSYS; }
  76. #endif /* defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND) */
  77. void save_processor_state(void);
  78. void restore_processor_state(void);
  79. struct saved_context;
  80. void __save_processor_state(struct saved_context *ctxt);
  81. void __restore_processor_state(struct saved_context *ctxt);
  82. #endif /* _LINUX_SWSUSP_H */