summaryrefslogtreecommitdiff
path: root/kernel/power/tuxonice_extent.h
blob: aeccf1f5e858002597b65d928659ce5e09b7e27d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * kernel/power/tuxonice_extent.h
 *
 * Copyright (C) 2003-2015 Nigel Cunningham (nigel at nigelcunningham com au)
 *
 * This file is released under the GPLv2.
 *
 * It contains declarations related to extents. Extents are
 * TuxOnIce's method of storing some of the metadata for the image.
 * See tuxonice_extent.c for more info.
 *
 */

#include "tuxonice_modules.h"

#ifndef EXTENT_H
#define EXTENT_H

struct hibernate_extent {
        unsigned long start, end;
        struct hibernate_extent *next;
};

struct hibernate_extent_chain {
        unsigned long size; /* size of the chain ie sum (max-min+1) */
        int num_extents;
        struct hibernate_extent *first, *last_touched;
        struct hibernate_extent *current_extent;
        unsigned long current_offset;
};

/* Simplify iterating through all the values in an extent chain */
#define toi_extent_for_each(extent_chain, extentpointer, value) \
if ((extent_chain)->first) \
        for ((extentpointer) = (extent_chain)->first, (value) = \
                        (extentpointer)->start; \
             ((extentpointer) && ((extentpointer)->next || (value) <= \
                                 (extentpointer)->end)); \
             (((value) == (extentpointer)->end) ? \
                ((extentpointer) = (extentpointer)->next, (value) = \
                 ((extentpointer) ? (extentpointer)->start : 0)) : \
                        (value)++))

extern void toi_put_extent_chain_from(struct hibernate_extent_chain *chain, unsigned long from);
#endif