1 #include <linux/suspend.h>
2 #include <linux/utsname.h>
5 struct new_utsname uts
;
7 unsigned long num_physpages
;
9 unsigned long image_pages
;
11 } __attribute__((aligned(PAGE_SIZE
)));
15 #ifdef CONFIG_SOFTWARE_SUSPEND
16 extern int pm_suspend_disk(void);
19 static inline int pm_suspend_disk(void)
24 extern struct semaphore pm_sem
;
25 #define power_attr(_name) \
26 static struct subsys_attribute _name##_attr = { \
28 .name = __stringify(_name), \
31 .show = _name##_show, \
32 .store = _name##_store, \
35 extern struct subsystem power_subsys
;
37 /* References to section boundaries */
38 extern const void __nosave_begin
, __nosave_end
;
40 extern struct pbe
*pagedir_nosave
;
42 /* Preferred image size in bytes (default 500 MB) */
43 extern unsigned long image_size
;
44 extern int in_suspend
;
45 extern dev_t swsusp_resume_device
;
47 extern asmlinkage
int swsusp_arch_suspend(void);
48 extern asmlinkage
int swsusp_arch_resume(void);
50 extern unsigned int count_data_pages(void);
51 extern void swsusp_free(void);
53 struct snapshot_handle
{
56 unsigned int page_offset
;
60 unsigned int buf_offset
;
63 #define data_of(handle) ((handle).buffer + (handle).buf_offset)
65 extern int snapshot_read_next(struct snapshot_handle
*handle
, size_t count
);
66 extern int snapshot_write_next(struct snapshot_handle
*handle
, size_t count
);
67 int snapshot_image_loaded(struct snapshot_handle
*handle
);
70 * The bitmap is used for tracing allocated swap pages
72 * The entire bitmap consists of a number of bitmap_page
73 * structures linked with the help of the .next member.
74 * Thus each page can be allocated individually, so we only
75 * need to make 0-order memory allocations to create
79 #define BITMAP_PAGE_SIZE (PAGE_SIZE - sizeof(void *))
80 #define BITMAP_PAGE_CHUNKS (BITMAP_PAGE_SIZE / sizeof(long))
81 #define BITS_PER_CHUNK (sizeof(long) * 8)
82 #define BITMAP_PAGE_BITS (BITMAP_PAGE_CHUNKS * BITS_PER_CHUNK)
85 unsigned long chunks
[BITMAP_PAGE_CHUNKS
];
86 struct bitmap_page
*next
;
89 extern void free_bitmap(struct bitmap_page
*bitmap
);
90 extern struct bitmap_page
*alloc_bitmap(unsigned int nr_bits
);
91 extern unsigned long alloc_swap_page(int swap
, struct bitmap_page
*bitmap
);
92 extern void free_all_swap_pages(int swap
, struct bitmap_page
*bitmap
);
94 extern int swsusp_shrink_memory(void);
95 extern int swsusp_suspend(void);
96 extern int swsusp_resume(void);