[PATCH] swsusp: reduce code duplication
[linux-2.6.git] / kernel / power / power.h
1 #include <linux/suspend.h>
2 #include <linux/utsname.h>
3
4 /* With SUSPEND_CONSOLE defined suspend looks *really* cool, but
5    we probably do not take enough locks for switching consoles, etc,
6    so bad things might happen.
7 */
8 #if defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
9 #define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
10 #endif
11
12 #define MAX_PBES        ((PAGE_SIZE - sizeof(struct new_utsname) \
13                         - 4 - 3*sizeof(unsigned long) - sizeof(int) \
14                         - sizeof(void *)) / sizeof(swp_entry_t))
15
16 struct swsusp_info {
17         struct new_utsname      uts;
18         u32                     version_code;
19         unsigned long           num_physpages;
20         int                     cpus;
21         unsigned long           image_pages;
22         unsigned long           pagedir_pages;
23         suspend_pagedir_t       * suspend_pagedir;
24         swp_entry_t             pagedir[MAX_PBES];
25 } __attribute__((aligned(PAGE_SIZE)));
26
27
28
29 #ifdef CONFIG_SOFTWARE_SUSPEND
30 extern int pm_suspend_disk(void);
31
32 #else
33 static inline int pm_suspend_disk(void)
34 {
35         return -EPERM;
36 }
37 #endif
38 extern struct semaphore pm_sem;
39 #define power_attr(_name) \
40 static struct subsys_attribute _name##_attr = { \
41         .attr   = {                             \
42                 .name = __stringify(_name),     \
43                 .mode = 0644,                   \
44         },                                      \
45         .show   = _name##_show,                 \
46         .store  = _name##_store,                \
47 }
48
49 extern struct subsystem power_subsys;
50
51 extern int freeze_processes(void);
52 extern void thaw_processes(void);
53
54 extern int pm_prepare_console(void);
55 extern void pm_restore_console(void);
56
57
58 /* References to section boundaries */
59 extern const void __nosave_begin, __nosave_end;
60
61 extern unsigned int nr_copy_pages;
62 extern suspend_pagedir_t *pagedir_nosave;
63 extern suspend_pagedir_t *pagedir_save;
64
65 extern asmlinkage int swsusp_arch_suspend(void);
66 extern asmlinkage int swsusp_arch_resume(void);
67
68 extern int restore_highmem(void);
69 extern struct pbe *alloc_pagedir(unsigned nr_pages, gfp_t gfp_mask, int safe_needed);
70 extern void create_pbe_list(struct pbe *pblist, unsigned nr_pages);
71 extern void swsusp_free(void);
72 extern int alloc_data_pages(struct pbe *pblist, gfp_t gfp_mask, int safe_needed);
73 extern int enough_swap(unsigned nr_pages);