]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #include <linux/suspend.h> |
2 | #include <linux/utsname.h> | |
3 | ||
1da177e4 LT |
4 | struct swsusp_info { |
5 | struct new_utsname uts; | |
6 | u32 version_code; | |
7 | unsigned long num_physpages; | |
8 | int cpus; | |
9 | unsigned long image_pages; | |
7088a5c0 | 10 | unsigned long pages; |
1da177e4 LT |
11 | } __attribute__((aligned(PAGE_SIZE))); |
12 | ||
13 | ||
14 | ||
15 | #ifdef CONFIG_SOFTWARE_SUSPEND | |
16 | extern int pm_suspend_disk(void); | |
17 | ||
18 | #else | |
19 | static inline int pm_suspend_disk(void) | |
20 | { | |
21 | return -EPERM; | |
22 | } | |
23 | #endif | |
24 | extern struct semaphore pm_sem; | |
25 | #define power_attr(_name) \ | |
26 | static 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 | ||
35 | extern struct subsystem power_subsys; | |
36 | ||
25761b6e RW |
37 | /* References to section boundaries */ |
38 | extern const void __nosave_begin, __nosave_end; | |
39 | ||
72a97e08 RW |
40 | extern struct pbe *pagedir_nosave; |
41 | ||
853609b6 RW |
42 | /* Preferred image size in bytes (default 500 MB) */ |
43 | extern unsigned long image_size; | |
f577eb30 | 44 | extern int in_suspend; |
61159a31 | 45 | extern dev_t swsusp_resume_device; |
f577eb30 | 46 | |
25761b6e RW |
47 | extern asmlinkage int swsusp_arch_suspend(void); |
48 | extern asmlinkage int swsusp_arch_resume(void); | |
49 | ||
72a97e08 | 50 | extern unsigned int count_data_pages(void); |
f577eb30 RW |
51 | |
52 | struct snapshot_handle { | |
53 | loff_t offset; | |
54 | unsigned int page; | |
55 | unsigned int page_offset; | |
56 | unsigned int prev; | |
57 | struct pbe *pbe; | |
58 | void *buffer; | |
59 | unsigned int buf_offset; | |
60 | }; | |
61 | ||
62 | #define data_of(handle) ((handle).buffer + (handle).buf_offset) | |
63 | ||
64 | extern int snapshot_read_next(struct snapshot_handle *handle, size_t count); | |
65 | extern int snapshot_write_next(struct snapshot_handle *handle, size_t count); | |
66 | int snapshot_image_loaded(struct snapshot_handle *handle); | |
61159a31 RW |
67 | |
68 | /** | |
69 | * The bitmap is used for tracing allocated swap pages | |
70 | * | |
71 | * The entire bitmap consists of a number of bitmap_page | |
72 | * structures linked with the help of the .next member. | |
73 | * Thus each page can be allocated individually, so we only | |
74 | * need to make 0-order memory allocations to create | |
75 | * the bitmap. | |
76 | */ | |
77 | ||
78 | #define BITMAP_PAGE_SIZE (PAGE_SIZE - sizeof(void *)) | |
79 | #define BITMAP_PAGE_CHUNKS (BITMAP_PAGE_SIZE / sizeof(long)) | |
80 | #define BITS_PER_CHUNK (sizeof(long) * 8) | |
81 | #define BITMAP_PAGE_BITS (BITMAP_PAGE_CHUNKS * BITS_PER_CHUNK) | |
82 | ||
83 | struct bitmap_page { | |
84 | unsigned long chunks[BITMAP_PAGE_CHUNKS]; | |
85 | struct bitmap_page *next; | |
86 | }; | |
87 | ||
88 | extern void free_bitmap(struct bitmap_page *bitmap); | |
89 | extern struct bitmap_page *alloc_bitmap(unsigned int nr_bits); | |
90 | extern unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap); | |
91 | extern void free_all_swap_pages(int swap, struct bitmap_page *bitmap); | |
92 | ||
74c7e2ef | 93 | extern int swsusp_check(void); |
61159a31 | 94 | extern int swsusp_shrink_memory(void); |
74c7e2ef | 95 | extern void swsusp_free(void); |
61159a31 RW |
96 | extern int swsusp_suspend(void); |
97 | extern int swsusp_resume(void); | |
74c7e2ef RD |
98 | extern int swsusp_read(void); |
99 | extern int swsusp_write(void); | |
100 | extern void swsusp_close(void); |