Complete the renaming to TuxOnIce with function names, vars etc.
[linux-2.6/suspend2-head.git] / kernel / power / tuxonice_extent.h
blob64da98c0f5c393d33e903c2dab327340fcf39c26
1 /*
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"
16 #ifndef EXTENT_H
17 #define EXTENT_H
19 struct extent {
20 unsigned long minimum, maximum;
21 struct extent *next;
24 struct extent_chain {
25 int size; /* size of the chain ie sum (max-min+1) */
26 int num_extents;
27 struct extent *first, *last_touched;
30 struct extent_iterate_state {
31 struct extent_chain *chains;
32 int num_chains;
33 int current_chain;
34 struct extent *current_extent;
35 unsigned long current_offset;
38 struct extent_iterate_saved_state {
39 int chain_num;
40 int extent_num;
41 unsigned long offset;
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)) : \
56 (value)++))
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);
77 #endif