Routines for serialising pageflags in an image header.
Signed-off-by: Nigel Cunningham <[email protected]>
kernel/power/pageflags.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 74 insertions(+), 0 deletions(-)
diff --git a/kernel/power/pageflags.c b/kernel/power/pageflags.c
index 7c00257..0b019de 100644
--- a/kernel/power/pageflags.c
+++ b/kernel/power/pageflags.c
@@ -56,3 +56,77 @@ int suspend_pageflags_space_needed(void)
return total;
}
+/* save_dyn_pageflags
+ *
+ * Description: Save a set of pageflags.
+ * Arguments: dyn_pageflags_t *: Pointer to the bitmap being saved.
+ */
+
+void save_dyn_pageflags(dyn_pageflags_t pagemap)
+{
+ int i, zone_num = 0;
+ struct zone *zone;
+
+ if (!*pagemap)
+ return;
+
+ for_each_zone(zone) {
+ int size = pages_for_zone(zone);
+
+ suspend_active_writer->rw_header_chunk(WRITE, NULL,
+ (char *) &zone_num, sizeof(int));
+ suspend_active_writer->rw_header_chunk(WRITE, NULL,
+ (char *) &size, sizeof(int));
+
+ for (i = 0; i < size; i++)
+ suspend_active_writer->rw_header_chunk(WRITE, NULL,
+ (char *) pagemap[zone_num][i], PAGE_SIZE);
+ zone_num++;
+ }
+ zone_num = -1;
+ suspend_active_writer->rw_header_chunk(WRITE, NULL,
+ (char *) &zone_num, sizeof(int));
+}
+
+/* load_dyn_pageflags
+ *
+ * Description: Load a set of pageflags.
+ * Arguments: dyn_pageflags_t *: Pointer to the bitmap being loaded.
+ * (It must be allocated before calling this routine).
+ */
+
+void load_dyn_pageflags(dyn_pageflags_t pagemap)
+{
+ int i, zone_num = 0, zone_check = 0;
+ struct zone *zone;
+
+ if (!pagemap)
+ return;
+
+ for_each_zone(zone) {
+ int size = 0;
+ suspend_active_writer->rw_header_chunk(READ, NULL,
+ (char *) &zone_check, sizeof(int));
+ if (zone_check != zone_num) {
+ printk("Zone check (%d) != zone_num (%d).\n",
+ zone_check, zone_num);
+ BUG();
+ }
+ suspend_active_writer->rw_header_chunk(READ, NULL,
+ (char *) &size, sizeof(int));
+
+ for (i = 0; i < size; i++)
+ suspend_active_writer->rw_header_chunk(READ, NULL,
+ (char *) pagemap[zone_num][i],
+ PAGE_SIZE);
+ zone_num++;
+ }
+ suspend_active_writer->rw_header_chunk(READ, NULL, (char *) &zone_check,
+ sizeof(int));
+ if (zone_check != -1) {
+ printk("Didn't read end of dyn pageflag data marker.(%x)\n",
+ zone_check);
+ BUG();
+ }
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]