blob: 089c84bed89577699447aa60b90ff2ea90b1d71b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/suspend.h>
2#include <linux/utsname.h>
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004struct swsusp_info {
5 struct new_utsname uts;
6 u32 version_code;
7 unsigned long num_physpages;
8 int cpus;
9 unsigned long image_pages;
Rafael J. Wysocki7088a5c2006-01-06 00:13:05 -080010 unsigned long pages;
Linus Torvalds1da177e2005-04-16 15:20:36 -070011} __attribute__((aligned(PAGE_SIZE)));
12
13
14
15#ifdef CONFIG_SOFTWARE_SUSPEND
16extern int pm_suspend_disk(void);
17
18#else
19static inline int pm_suspend_disk(void)
20{
21 return -EPERM;
22}
23#endif
24extern struct semaphore pm_sem;
25#define power_attr(_name) \
26static struct subsys_attribute _name##_attr = { \
27 .attr = { \
28 .name = __stringify(_name), \
29 .mode = 0644, \
30 }, \
31 .show = _name##_show, \
32 .store = _name##_store, \
33}
34
35extern struct subsystem power_subsys;
36
Rafael J. Wysocki25761b62005-10-30 14:59:56 -080037/* References to section boundaries */
38extern const void __nosave_begin, __nosave_end;
39
Rafael J. Wysocki72a97e02006-01-06 00:13:46 -080040extern struct pbe *pagedir_nosave;
41
Rafael J. Wysocki853609b2006-02-01 03:05:07 -080042/* Preferred image size in bytes (default 500 MB) */
43extern unsigned long image_size;
Rafael J. Wysockif577eb32006-03-23 02:59:59 -080044extern int in_suspend;
Rafael J. Wysocki61159a32006-03-23 03:00:00 -080045extern dev_t swsusp_resume_device;
Rafael J. Wysockif577eb32006-03-23 02:59:59 -080046
Rafael J. Wysocki25761b62005-10-30 14:59:56 -080047extern asmlinkage int swsusp_arch_suspend(void);
48extern asmlinkage int swsusp_arch_resume(void);
49
Rafael J. Wysocki72a97e02006-01-06 00:13:46 -080050extern unsigned int count_data_pages(void);
Rafael J. Wysocki2c1b4a52005-10-30 14:59:58 -080051extern void swsusp_free(void);
Rafael J. Wysockif577eb32006-03-23 02:59:59 -080052
53struct snapshot_handle {
54 loff_t offset;
55 unsigned int page;
56 unsigned int page_offset;
57 unsigned int prev;
58 struct pbe *pbe;
59 void *buffer;
60 unsigned int buf_offset;
61};
62
63#define data_of(handle) ((handle).buffer + (handle).buf_offset)
64
65extern int snapshot_read_next(struct snapshot_handle *handle, size_t count);
66extern int snapshot_write_next(struct snapshot_handle *handle, size_t count);
67int snapshot_image_loaded(struct snapshot_handle *handle);
Rafael J. Wysocki61159a32006-03-23 03:00:00 -080068
69/**
70 * The bitmap is used for tracing allocated swap pages
71 *
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
76 * the bitmap.
77 */
78
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)
83
84struct bitmap_page {
85 unsigned long chunks[BITMAP_PAGE_CHUNKS];
86 struct bitmap_page *next;
87};
88
89extern void free_bitmap(struct bitmap_page *bitmap);
90extern struct bitmap_page *alloc_bitmap(unsigned int nr_bits);
91extern unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap);
92extern void free_all_swap_pages(int swap, struct bitmap_page *bitmap);
93
94extern int swsusp_shrink_memory(void);
95extern int swsusp_suspend(void);
96extern int swsusp_resume(void);