summaryrefslogtreecommitdiff
path: root/kernel/power/tuxonice_pageflags.h
blob: 30ee577c3038dec31fc667e0d2bbfeb7ca6db2aa (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 * kernel/power/tuxonice_pageflags.h
 *
 * Copyright (C) 2004-2015 Nigel Cunningham (nigel at nigelcunningham com au)
 *
 * This file is released under the GPLv2.
 */

#ifndef KERNEL_POWER_TUXONICE_PAGEFLAGS_H
#define KERNEL_POWER_TUXONICE_PAGEFLAGS_H

struct  memory_bitmap;
void memory_bm_free(struct memory_bitmap *bm, int clear_nosave_free);
void memory_bm_clear(struct memory_bitmap *bm);

int mem_bm_set_bit_check(struct memory_bitmap *bm, int index, unsigned long pfn);
void memory_bm_set_bit(struct memory_bitmap *bm, int index, unsigned long pfn);
unsigned long memory_bm_next_pfn(struct memory_bitmap *bm, int index);
unsigned long memory_bm_next_pfn_index(struct memory_bitmap *bm, int index);
void memory_bm_position_reset(struct memory_bitmap *bm);
void memory_bm_free(struct memory_bitmap *bm, int clear_nosave_free);
int toi_alloc_bitmap(struct memory_bitmap **bm);
void toi_free_bitmap(struct memory_bitmap **bm);
void memory_bm_clear(struct memory_bitmap *bm);
void memory_bm_clear_bit(struct memory_bitmap *bm, int index, unsigned long pfn);
void memory_bm_set_bit(struct memory_bitmap *bm, int index, unsigned long pfn);
int memory_bm_test_bit(struct memory_bitmap *bm, int index, unsigned long pfn);
int memory_bm_test_bit_index(struct memory_bitmap *bm, int index, unsigned long pfn);
void memory_bm_clear_bit_index(struct memory_bitmap *bm, int index, unsigned long pfn);

struct toi_module_ops;
int memory_bm_write(struct memory_bitmap *bm, int (*rw_chunk)
	(int rw, struct toi_module_ops *owner, char *buffer, int buffer_size));
int memory_bm_read(struct memory_bitmap *bm, int (*rw_chunk)
	(int rw, struct toi_module_ops *owner, char *buffer, int buffer_size));
int memory_bm_space_needed(struct memory_bitmap *bm);

extern struct memory_bitmap *pageset1_map;
extern struct memory_bitmap *pageset1_copy_map;
extern struct memory_bitmap *pageset2_map;
extern struct memory_bitmap *page_resave_map;
extern struct memory_bitmap *io_map;
extern struct memory_bitmap *nosave_map;
extern struct memory_bitmap *free_map;
extern struct memory_bitmap *compare_map;

#define PagePageset1(page) \
	(pageset1_map && memory_bm_test_bit(pageset1_map, smp_processor_id(), page_to_pfn(page)))
#define SetPagePageset1(page) \
	(memory_bm_set_bit(pageset1_map, smp_processor_id(), page_to_pfn(page)))
#define ClearPagePageset1(page) \
	(memory_bm_clear_bit(pageset1_map, smp_processor_id(), page_to_pfn(page)))

#define PagePageset1Copy(page) \
	(memory_bm_test_bit(pageset1_copy_map, smp_processor_id(), page_to_pfn(page)))
#define SetPagePageset1Copy(page) \
	(memory_bm_set_bit(pageset1_copy_map, smp_processor_id(), page_to_pfn(page)))
#define ClearPagePageset1Copy(page) \
	(memory_bm_clear_bit(pageset1_copy_map, smp_processor_id(), page_to_pfn(page)))

#define PagePageset2(page) \
	(memory_bm_test_bit(pageset2_map, smp_processor_id(), page_to_pfn(page)))
#define SetPagePageset2(page) \
	(memory_bm_set_bit(pageset2_map, smp_processor_id(), page_to_pfn(page)))
#define ClearPagePageset2(page) \
	(memory_bm_clear_bit(pageset2_map, smp_processor_id(), page_to_pfn(page)))

#define PageWasRW(page) \
	(memory_bm_test_bit(pageset2_map, smp_processor_id(), page_to_pfn(page)))
#define SetPageWasRW(page) \
	(memory_bm_set_bit(pageset2_map, smp_processor_id(), page_to_pfn(page)))
#define ClearPageWasRW(page) \
	(memory_bm_clear_bit(pageset2_map, smp_processor_id(), page_to_pfn(page)))

#define PageResave(page) (page_resave_map ? \
	memory_bm_test_bit(page_resave_map, smp_processor_id(), page_to_pfn(page)) : 0)
#define SetPageResave(page) \
	(memory_bm_set_bit(page_resave_map, smp_processor_id(), page_to_pfn(page)))
#define ClearPageResave(page) \
	(memory_bm_clear_bit(page_resave_map, smp_processor_id(), page_to_pfn(page)))

#define PageNosave(page) (nosave_map ? \
	memory_bm_test_bit(nosave_map, smp_processor_id(), page_to_pfn(page)) : 0)
#define SetPageNosave(page) \
	(mem_bm_set_bit_check(nosave_map, smp_processor_id(), page_to_pfn(page)))
#define ClearPageNosave(page) \
	(memory_bm_clear_bit(nosave_map, smp_processor_id(), page_to_pfn(page)))

#define PageNosaveFree(page) (free_map ? \
		memory_bm_test_bit(free_map, smp_processor_id(), page_to_pfn(page)) : 0)
#define SetPageNosaveFree(page) \
	(memory_bm_set_bit(free_map, smp_processor_id(), page_to_pfn(page)))
#define ClearPageNosaveFree(page) \
	(memory_bm_clear_bit(free_map, smp_processor_id(), page_to_pfn(page)))

#define PageCompareChanged(page) (compare_map ? \
		memory_bm_test_bit(compare_map, smp_processor_id(), page_to_pfn(page)) : 0)
#define SetPageCompareChanged(page) \
	(memory_bm_set_bit(compare_map, smp_processor_id(), page_to_pfn(page)))
#define ClearPageCompareChanged(page) \
	(memory_bm_clear_bit(compare_map, smp_processor_id(), page_to_pfn(page)))

extern void save_pageflags(struct memory_bitmap *pagemap);
extern int load_pageflags(struct memory_bitmap *pagemap);
extern int toi_pageflags_space_needed(void);
#endif