diff options
Diffstat (limited to 'kernel/power/power.h')
-rw-r--r-- | kernel/power/power.h | 75 |
1 files changed, 67 insertions, 8 deletions
diff --git a/kernel/power/power.h b/kernel/power/power.h index 388dba680841..f06f12f21767 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h | |||
@@ -8,6 +8,7 @@ struct swsusp_info { | |||
8 | int cpus; | 8 | int cpus; |
9 | unsigned long image_pages; | 9 | unsigned long image_pages; |
10 | unsigned long pages; | 10 | unsigned long pages; |
11 | unsigned long size; | ||
11 | } __attribute__((aligned(PAGE_SIZE))); | 12 | } __attribute__((aligned(PAGE_SIZE))); |
12 | 13 | ||
13 | 14 | ||
@@ -37,21 +38,79 @@ extern struct subsystem power_subsys; | |||
37 | /* References to section boundaries */ | 38 | /* References to section boundaries */ |
38 | extern const void __nosave_begin, __nosave_end; | 39 | extern const void __nosave_begin, __nosave_end; |
39 | 40 | ||
40 | extern unsigned int nr_copy_pages; | ||
41 | extern struct pbe *pagedir_nosave; | 41 | extern struct pbe *pagedir_nosave; |
42 | 42 | ||
43 | /* Preferred image size in bytes (default 500 MB) */ | 43 | /* Preferred image size in bytes (default 500 MB) */ |
44 | extern unsigned long image_size; | 44 | extern unsigned long image_size; |
45 | extern int in_suspend; | ||
46 | extern dev_t swsusp_resume_device; | ||
45 | 47 | ||
46 | extern asmlinkage int swsusp_arch_suspend(void); | 48 | extern asmlinkage int swsusp_arch_suspend(void); |
47 | extern asmlinkage int swsusp_arch_resume(void); | 49 | extern asmlinkage int swsusp_arch_resume(void); |
48 | 50 | ||
49 | extern unsigned int count_data_pages(void); | 51 | extern unsigned int count_data_pages(void); |
50 | extern void free_pagedir(struct pbe *pblist); | 52 | |
51 | extern void release_eaten_pages(void); | 53 | struct snapshot_handle { |
52 | extern struct pbe *alloc_pagedir(unsigned nr_pages, gfp_t gfp_mask, int safe_needed); | 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 | |||
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); | ||
68 | |||
69 | #define SNAPSHOT_IOC_MAGIC '3' | ||
70 | #define SNAPSHOT_FREEZE _IO(SNAPSHOT_IOC_MAGIC, 1) | ||
71 | #define SNAPSHOT_UNFREEZE _IO(SNAPSHOT_IOC_MAGIC, 2) | ||
72 | #define SNAPSHOT_ATOMIC_SNAPSHOT _IOW(SNAPSHOT_IOC_MAGIC, 3, void *) | ||
73 | #define SNAPSHOT_ATOMIC_RESTORE _IO(SNAPSHOT_IOC_MAGIC, 4) | ||
74 | #define SNAPSHOT_FREE _IO(SNAPSHOT_IOC_MAGIC, 5) | ||
75 | #define SNAPSHOT_SET_IMAGE_SIZE _IOW(SNAPSHOT_IOC_MAGIC, 6, unsigned long) | ||
76 | #define SNAPSHOT_AVAIL_SWAP _IOR(SNAPSHOT_IOC_MAGIC, 7, void *) | ||
77 | #define SNAPSHOT_GET_SWAP_PAGE _IOR(SNAPSHOT_IOC_MAGIC, 8, void *) | ||
78 | #define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9) | ||
79 | #define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int) | ||
80 | #define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11) | ||
81 | #define SNAPSHOT_IOC_MAXNR 11 | ||
82 | |||
83 | /** | ||
84 | * The bitmap is used for tracing allocated swap pages | ||
85 | * | ||
86 | * The entire bitmap consists of a number of bitmap_page | ||
87 | * structures linked with the help of the .next member. | ||
88 | * Thus each page can be allocated individually, so we only | ||
89 | * need to make 0-order memory allocations to create | ||
90 | * the bitmap. | ||
91 | */ | ||
92 | |||
93 | #define BITMAP_PAGE_SIZE (PAGE_SIZE - sizeof(void *)) | ||
94 | #define BITMAP_PAGE_CHUNKS (BITMAP_PAGE_SIZE / sizeof(long)) | ||
95 | #define BITS_PER_CHUNK (sizeof(long) * 8) | ||
96 | #define BITMAP_PAGE_BITS (BITMAP_PAGE_CHUNKS * BITS_PER_CHUNK) | ||
97 | |||
98 | struct bitmap_page { | ||
99 | unsigned long chunks[BITMAP_PAGE_CHUNKS]; | ||
100 | struct bitmap_page *next; | ||
101 | }; | ||
102 | |||
103 | extern void free_bitmap(struct bitmap_page *bitmap); | ||
104 | extern struct bitmap_page *alloc_bitmap(unsigned int nr_bits); | ||
105 | extern unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap); | ||
106 | extern void free_all_swap_pages(int swap, struct bitmap_page *bitmap); | ||
107 | |||
108 | extern int swsusp_check(void); | ||
109 | extern int swsusp_shrink_memory(void); | ||
53 | extern void swsusp_free(void); | 110 | extern void swsusp_free(void); |
54 | extern int alloc_data_pages(struct pbe *pblist, gfp_t gfp_mask, int safe_needed); | 111 | extern int swsusp_suspend(void); |
55 | extern unsigned int snapshot_nr_pages(void); | 112 | extern int swsusp_resume(void); |
56 | extern struct pbe *snapshot_pblist(void); | 113 | extern int swsusp_read(void); |
57 | extern void snapshot_pblist_set(struct pbe *pblist); | 114 | extern int swsusp_write(void); |
115 | extern void swsusp_close(void); | ||
116 | extern int suspend_enter(suspend_state_t state); | ||