suspend.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef _LINUX_SWSUSP_H
  2. #define _LINUX_SWSUSP_H
  3. #if defined(CONFIG_X86) || defined(CONFIG_FRV) || defined(CONFIG_PPC32)
  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. #ifdef CONFIG_PM
  24. /* kernel/power/swsusp.c */
  25. extern int software_suspend(void);
  26. #if defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
  27. extern int pm_prepare_console(void);
  28. extern void pm_restore_console(void);
  29. #else
  30. static inline int pm_prepare_console(void) { return 0; }
  31. static inline void pm_restore_console(void) {}
  32. #endif /* defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE) */
  33. #else
  34. static inline int software_suspend(void)
  35. {
  36. printk("Warning: fake suspend called\n");
  37. return -ENOSYS;
  38. }
  39. #endif /* CONFIG_PM */
  40. void save_processor_state(void);
  41. void restore_processor_state(void);
  42. struct saved_context;
  43. void __save_processor_state(struct saved_context *ctxt);
  44. void __restore_processor_state(struct saved_context *ctxt);
  45. unsigned long get_safe_page(gfp_t gfp_mask);
  46. /* Page management functions for the software suspend (swsusp) */
  47. static inline void swsusp_set_page_forbidden(struct page *page)
  48. {
  49. SetPageNosave(page);
  50. }
  51. static inline int swsusp_page_is_forbidden(struct page *page)
  52. {
  53. return PageNosave(page);
  54. }
  55. static inline void swsusp_unset_page_forbidden(struct page *page)
  56. {
  57. ClearPageNosave(page);
  58. }
  59. static inline void swsusp_set_page_free(struct page *page)
  60. {
  61. SetPageNosaveFree(page);
  62. }
  63. static inline int swsusp_page_is_free(struct page *page)
  64. {
  65. return PageNosaveFree(page);
  66. }
  67. static inline void swsusp_unset_page_free(struct page *page)
  68. {
  69. ClearPageNosaveFree(page);
  70. }
  71. /*
  72. * XXX: We try to keep some more pages free so that I/O operations succeed
  73. * without paging. Might this be more?
  74. */
  75. #define PAGES_FOR_IO 1024
  76. #endif /* _LINUX_SWSUSP_H */