diff options
Diffstat (limited to 'kernel/power/power.h')
-rw-r--r-- | kernel/power/power.h | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/kernel/power/power.h b/kernel/power/power.h index 59ce712f082d..1cefcf87a694 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h | |||
@@ -50,17 +50,65 @@ extern asmlinkage int swsusp_arch_resume(void); | |||
50 | 50 | ||
51 | extern unsigned int count_data_pages(void); | 51 | extern unsigned int count_data_pages(void); |
52 | 52 | ||
53 | /** | ||
54 | * Auxiliary structure used for reading the snapshot image data and | ||
55 | * metadata from and writing them to the list of page backup entries | ||
56 | * (PBEs) which is the main data structure of swsusp. | ||
57 | * | ||
58 | * Using struct snapshot_handle we can transfer the image, including its | ||
59 | * metadata, as a continuous sequence of bytes with the help of | ||
60 | * snapshot_read_next() and snapshot_write_next(). | ||
61 | * | ||
62 | * The code that writes the image to a storage or transfers it to | ||
63 | * the user land is required to use snapshot_read_next() for this | ||
64 | * purpose and it should not make any assumptions regarding the internal | ||
65 | * structure of the image. Similarly, the code that reads the image from | ||
66 | * a storage or transfers it from the user land is required to use | ||
67 | * snapshot_write_next(). | ||
68 | * | ||
69 | * This may allow us to change the internal structure of the image | ||
70 | * in the future with considerably less effort. | ||
71 | */ | ||
72 | |||
53 | struct snapshot_handle { | 73 | struct snapshot_handle { |
54 | loff_t offset; | 74 | loff_t offset; /* number of the last byte ready for reading |
55 | unsigned int page; | 75 | * or writing in the sequence |
56 | unsigned int page_offset; | 76 | */ |
57 | unsigned int prev; | 77 | unsigned int cur; /* number of the block of PAGE_SIZE bytes the |
58 | struct pbe *pbe, *last_pbe; | 78 | * next operation will refer to (ie. current) |
59 | void *buffer; | 79 | */ |
60 | unsigned int buf_offset; | 80 | unsigned int cur_offset; /* offset with respect to the current |
61 | int sync_read; | 81 | * block (for the next operation) |
82 | */ | ||
83 | unsigned int prev; /* number of the block of PAGE_SIZE bytes that | ||
84 | * was the current one previously | ||
85 | */ | ||
86 | struct pbe *pbe; /* PBE that corresponds to 'buffer' */ | ||
87 | struct pbe *last_pbe; /* When the image is restored (eg. read | ||
88 | * from disk) we can store some image | ||
89 | * data directly in the page frames | ||
90 | * in which they were before suspend. | ||
91 | * In such a case the PBEs that | ||
92 | * correspond to them will be unused. | ||
93 | * This is the last PBE, so far, that | ||
94 | * does not correspond to such data. | ||
95 | */ | ||
96 | void *buffer; /* address of the block to read from | ||
97 | * or write to | ||
98 | */ | ||
99 | unsigned int buf_offset; /* location to read from or write to, | ||
100 | * given as a displacement from 'buffer' | ||
101 | */ | ||
102 | int sync_read; /* Set to one to notify the caller of | ||
103 | * snapshot_write_next() that it may | ||
104 | * need to call wait_on_bio_chain() | ||
105 | */ | ||
62 | }; | 106 | }; |
63 | 107 | ||
108 | /* This macro returns the address from/to which the caller of | ||
109 | * snapshot_read_next()/snapshot_write_next() is allowed to | ||
110 | * read/write data after the function returns | ||
111 | */ | ||
64 | #define data_of(handle) ((handle).buffer + (handle).buf_offset) | 112 | #define data_of(handle) ((handle).buffer + (handle).buf_offset) |
65 | 113 | ||
66 | extern int snapshot_read_next(struct snapshot_handle *handle, size_t count); | 114 | extern int snapshot_read_next(struct snapshot_handle *handle, size_t count); |