]> err.no Git - linux-2.6/blobdiff - kernel/power/power.h
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux...
[linux-2.6] / kernel / power / power.h
index 6e9e2acc34f89fcec598908109818ccab9d9111a..195dc4611764b08a65780976a6231aaf004889fe 100644 (file)
@@ -11,18 +11,48 @@ struct swsusp_info {
        unsigned long           size;
 } __attribute__((aligned(PAGE_SIZE)));
 
+#ifdef CONFIG_HIBERNATION
+#ifdef CONFIG_ARCH_HIBERNATION_HEADER
+/* Maximum size of architecture specific data in a hibernation header */
+#define MAX_ARCH_HEADER_SIZE   (sizeof(struct new_utsname) + 4)
 
+extern int arch_hibernation_header_save(void *addr, unsigned int max_size);
+extern int arch_hibernation_header_restore(void *addr);
 
-#ifdef CONFIG_SOFTWARE_SUSPEND
-extern int pm_suspend_disk(void);
+static inline int init_header_complete(struct swsusp_info *info)
+{
+       return arch_hibernation_header_save(info, MAX_ARCH_HEADER_SIZE);
+}
 
-#else
-static inline int pm_suspend_disk(void)
+static inline char *check_image_kernel(struct swsusp_info *info)
 {
-       return -EPERM;
+       return arch_hibernation_header_restore(info) ?
+                       "architecture specific data" : NULL;
 }
+#endif /* CONFIG_ARCH_HIBERNATION_HEADER */
+
+/*
+ * Keep some memory free so that I/O operations can succeed without paging
+ * [Might this be more than 4 MB?]
+ */
+#define PAGES_FOR_IO   ((4096 * 1024) >> PAGE_SHIFT)
+
+/*
+ * Keep 1 MB of memory free so that device drivers can allocate some pages in
+ * their .suspend() routines without breaking the suspend to disk.
+ */
+#define SPARE_PAGES    ((1024 * 1024) >> PAGE_SHIFT)
+
+/* kernel/power/disk.c */
+extern int hibernation_snapshot(int platform_mode);
+extern int hibernation_restore(int platform_mode);
+extern int hibernation_platform_enter(void);
 #endif
-extern struct semaphore pm_sem;
+
+extern int pfn_is_nosave(unsigned long);
+
+extern struct mutex pm_mutex;
+
 #define power_attr(_name) \
 static struct subsys_attribute _name##_attr = {        \
        .attr   = {                             \
@@ -33,19 +63,19 @@ static struct subsys_attribute _name##_attr = {     \
        .store  = _name##_store,                \
 }
 
-extern struct subsystem power_subsys;
-
-/* References to section boundaries */
-extern const void __nosave_begin, __nosave_end;
+extern struct kset power_subsys;
 
 /* Preferred image size in bytes (default 500 MB) */
 extern unsigned long image_size;
 extern int in_suspend;
 extern dev_t swsusp_resume_device;
+extern sector_t swsusp_resume_block;
 
 extern asmlinkage int swsusp_arch_suspend(void);
 extern asmlinkage int swsusp_arch_resume(void);
 
+extern int create_basic_memory_bitmaps(void);
+extern void free_basic_memory_bitmaps(void);
 extern unsigned int count_data_pages(void);
 
 /**
@@ -81,16 +111,6 @@ struct snapshot_handle {
        unsigned int    prev;   /* number of the block of PAGE_SIZE bytes that
                                 * was the current one previously
                                 */
-       struct pbe      *pbe;   /* PBE that corresponds to 'buffer' */
-       struct pbe      *last_pbe;      /* When the image is restored (eg. read
-                                        * from disk) we can store some image
-                                        * data directly in the page frames
-                                        * in which they were before suspend.
-                                        * In such a case the PBEs that
-                                        * correspond to them will be unused.
-                                        * This is the last PBE, so far, that
-                                        * does not correspond to such data.
-                                        */
        void            *buffer;        /* address of the block to read from
                                         * or write to
                                         */
@@ -112,8 +132,19 @@ struct snapshot_handle {
 extern unsigned int snapshot_additional_pages(struct zone *zone);
 extern int snapshot_read_next(struct snapshot_handle *handle, size_t count);
 extern int snapshot_write_next(struct snapshot_handle *handle, size_t count);
+extern void snapshot_write_finalize(struct snapshot_handle *handle);
 extern int snapshot_image_loaded(struct snapshot_handle *handle);
 
+/*
+ * This structure is used to pass the values needed for the identification
+ * of the resume swap area from a user space to the kernel via the
+ * SNAPSHOT_SET_SWAP_AREA ioctl
+ */
+struct resume_swap_area {
+       loff_t offset;
+       u_int32_t dev;
+} __attribute__((packed));
+
 #define SNAPSHOT_IOC_MAGIC     '3'
 #define SNAPSHOT_FREEZE                        _IO(SNAPSHOT_IOC_MAGIC, 1)
 #define SNAPSHOT_UNFREEZE              _IO(SNAPSHOT_IOC_MAGIC, 2)
@@ -126,39 +157,57 @@ extern int snapshot_image_loaded(struct snapshot_handle *handle);
 #define SNAPSHOT_FREE_SWAP_PAGES       _IO(SNAPSHOT_IOC_MAGIC, 9)
 #define SNAPSHOT_SET_SWAP_FILE         _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int)
 #define SNAPSHOT_S2RAM                 _IO(SNAPSHOT_IOC_MAGIC, 11)
-#define SNAPSHOT_IOC_MAXNR     11
+#define SNAPSHOT_PMOPS                 _IOW(SNAPSHOT_IOC_MAGIC, 12, unsigned int)
+#define SNAPSHOT_SET_SWAP_AREA         _IOW(SNAPSHOT_IOC_MAGIC, 13, \
+                                                       struct resume_swap_area)
+#define SNAPSHOT_IOC_MAXNR     13
 
-/**
- *     The bitmap is used for tracing allocated swap pages
- *
- *     The entire bitmap consists of a number of bitmap_page
- *     structures linked with the help of the .next member.
- *     Thus each page can be allocated individually, so we only
- *     need to make 0-order memory allocations to create
- *     the bitmap.
- */
+#define PMOPS_PREPARE  1
+#define PMOPS_ENTER    2
+#define PMOPS_FINISH   3
 
-#define BITMAP_PAGE_SIZE       (PAGE_SIZE - sizeof(void *))
-#define BITMAP_PAGE_CHUNKS     (BITMAP_PAGE_SIZE / sizeof(long))
-#define BITS_PER_CHUNK         (sizeof(long) * 8)
-#define BITMAP_PAGE_BITS       (BITMAP_PAGE_CHUNKS * BITS_PER_CHUNK)
+/* If unset, the snapshot device cannot be open. */
+extern atomic_t snapshot_device_available;
 
-struct bitmap_page {
-       unsigned long           chunks[BITMAP_PAGE_CHUNKS];
-       struct bitmap_page      *next;
-};
+extern sector_t alloc_swapdev_block(int swap);
+extern void free_all_swap_pages(int swap);
+extern int swsusp_swap_in_use(void);
 
-extern void free_bitmap(struct bitmap_page *bitmap);
-extern struct bitmap_page *alloc_bitmap(unsigned int nr_bits);
-extern unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap);
-extern void free_all_swap_pages(int swap, struct bitmap_page *bitmap);
+/*
+ * Flags that can be passed from the hibernatig hernel to the "boot" kernel in
+ * the image header.
+ */
+#define SF_PLATFORM_MODE       1
 
+/* kernel/power/disk.c */
 extern int swsusp_check(void);
 extern int swsusp_shrink_memory(void);
 extern void swsusp_free(void);
-extern int swsusp_suspend(void);
 extern int swsusp_resume(void);
-extern int swsusp_read(void);
-extern int swsusp_write(void);
+extern int swsusp_read(unsigned int *flags_p);
+extern int swsusp_write(unsigned int flags);
 extern void swsusp_close(void);
-extern int suspend_enter(suspend_state_t state);
+
+struct timeval;
+/* kernel/power/swsusp.c */
+extern void swsusp_show_speed(struct timeval *, struct timeval *,
+                               unsigned int, char *);
+
+#ifdef CONFIG_SUSPEND
+/* kernel/power/main.c */
+extern int suspend_devices_and_enter(suspend_state_t state);
+#else /* !CONFIG_SUSPEND */
+static inline int suspend_devices_and_enter(suspend_state_t state)
+{
+       return -ENOSYS;
+}
+#endif /* !CONFIG_SUSPEND */
+
+/* kernel/power/common.c */
+extern struct blocking_notifier_head pm_chain_head;
+
+static inline int pm_notifier_call_chain(unsigned long val)
+{
+       return (blocking_notifier_call_chain(&pm_chain_head, val, NULL)
+                       == NOTIFY_BAD) ? -EINVAL : 0;
+}