2 * kernel/power/tuxonice_extent.h
4 * Copyright (C) 2003-2007 Nigel Cunningham (nigel at suspend2 net)
6 * This file is released under the GPLv2.
8 * It contains declarations related to extents. Extents are
9 * TuxOnIce's method of storing some of the metadata for the image.
10 * See tuxonice_extent.c for more info.
14 #include "tuxonice_modules.h"
20 unsigned long minimum
, maximum
;
25 int size
; /* size of the chain ie sum (max-min+1) */
27 struct extent
*first
, *last_touched
;
30 struct extent_iterate_state
{
31 struct extent_chain
*chains
;
34 struct extent
*current_extent
;
35 unsigned long current_offset
;
38 struct extent_iterate_saved_state
{
44 #define toi_extent_state_eof(state) ((state)->num_chains == (state)->current_chain)
46 /* Simplify iterating through all the values in an extent chain */
47 #define toi_extent_for_each(extent_chain, extentpointer, value) \
48 if ((extent_chain)->first) \
49 for ((extentpointer) = (extent_chain)->first, (value) = \
50 (extentpointer)->minimum; \
51 ((extentpointer) && ((extentpointer)->next || (value) <= \
52 (extentpointer)->maximum)); \
53 (((value) == (extentpointer)->maximum) ? \
54 ((extentpointer) = (extentpointer)->next, (value) = \
55 ((extentpointer) ? (extentpointer)->minimum : 0)) : \
58 void toi_put_extent_chain(struct extent_chain
*chain
);
59 int toi_add_to_extent_chain(struct extent_chain
*chain
,
60 unsigned long minimum
, unsigned long maximum
);
61 int toi_serialise_extent_chain(struct toi_module_ops
*owner
,
62 struct extent_chain
*chain
);
63 int toi_load_extent_chain(struct extent_chain
*chain
);
65 /* swap_entry_to_extent_val & extent_val_to_swap_entry:
66 * We are putting offset in the low bits so consecutive swap entries
67 * make consecutive extent values */
68 #define swap_entry_to_extent_val(swp_entry) (swp_entry.val)
69 #define extent_val_to_swap_entry(val) (swp_entry_t) { (val) }
71 void toi_extent_state_save(struct extent_iterate_state
*state
,
72 struct extent_iterate_saved_state
*saved_state
);
73 void toi_extent_state_restore(struct extent_iterate_state
*state
,
74 struct extent_iterate_saved_state
*saved_state
);
75 void toi_extent_state_goto_start(struct extent_iterate_state
*state
);
76 unsigned long toi_extent_state_next(struct extent_iterate_state
*state
);