This source file includes following definitions.
- get_free_page
- in_swap_cache
- swap_cache_invalidate
1 #ifndef _LINUX_MM_H
2 #define _LINUX_MM_H
3
4 #include <linux/page.h>
5 #include <linux/sched.h>
6 #include <linux/errno.h>
7 #include <linux/kernel.h>
8
9 #define VERIFY_READ 0
10 #define VERIFY_WRITE 1
11
12 extern int verify_area(int, const void *, unsigned long);
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 struct vm_area_struct {
30 struct task_struct * vm_task;
31 unsigned long vm_start;
32 unsigned long vm_end;
33 unsigned short vm_page_prot;
34 unsigned short vm_flags;
35 struct vm_area_struct * vm_next;
36 struct vm_area_struct * vm_share;
37 struct inode * vm_inode;
38 unsigned long vm_offset;
39 struct vm_operations_struct * vm_ops;
40 };
41
42
43
44
45 #define VM_GROWSDOWN 0x01
46 #define VM_GROWSUP 0x02
47 #define VM_SHM 0x04
48
49
50
51
52
53
54
55 struct vm_operations_struct {
56 void (*open)(struct vm_area_struct * area);
57 void (*close)(struct vm_area_struct * area);
58 unsigned long (*nopage)(struct vm_area_struct * area, unsigned long address,
59 unsigned long page, int error_code);
60 unsigned long (*wppage)(struct vm_area_struct * area, unsigned long address,
61 unsigned long page);
62 int (*share)(struct vm_area_struct * from, struct vm_area_struct * to, unsigned long address);
63 int (*unmap)(struct vm_area_struct *area, unsigned long, size_t);
64 void (*swapout)(struct vm_area_struct *, unsigned long *);
65 unsigned long (*swapin)(struct vm_area_struct *, unsigned long);
66 };
67
68 extern unsigned long __bad_page(void);
69 extern unsigned long __bad_pagetable(void);
70 extern unsigned long __zero_page(void);
71
72 #define BAD_PAGETABLE __bad_pagetable()
73 #define BAD_PAGE __bad_page()
74 #define ZERO_PAGE __zero_page()
75
76
77 #define P_DIRTY 0x0001
78 #define P_LOCKED 0x0002
79 #define P_UPTODATE 0x0004
80 #define P_RESERVED 0x8000
81
82 struct page_info {
83 unsigned short flags;
84 unsigned short count;
85 struct inode * inode;
86 unsigned long offset;
87 struct page_info * next_same_inode;
88 struct page_info * prev_same_inode;
89 struct page_info * next_hash;
90 struct page_info * prev_hash;
91 struct wait_queue *wait;
92 };
93
94
95
96
97
98
99 extern int nr_swap_pages;
100 extern int nr_free_pages;
101
102 #define MAX_SECONDARY_PAGES 20
103 #define NR_MEM_LISTS 6
104
105 struct mem_list {
106 struct mem_list * next;
107 struct mem_list * prev;
108 };
109
110 extern struct mem_list free_area_list[NR_MEM_LISTS];
111 extern unsigned char * free_area_map[NR_MEM_LISTS];
112
113
114
115
116
117
118 #define __get_free_page(priority) __get_free_pages((priority),0)
119 extern unsigned long __get_free_pages(int priority, unsigned long gfporder);
120 extern inline unsigned long get_free_page(int priority)
121 {
122 unsigned long page;
123
124 page = __get_free_page(priority);
125 if (page)
126 __asm__ __volatile__("rep ; stosl"
127 : \
128 :"a" (0),"c" (1024),"D" (page)
129 :"di","cx");
130 return page;
131 }
132
133
134
135 #define free_page(addr) free_pages((addr),0)
136 extern void free_pages(unsigned long addr, unsigned long order);
137
138 extern void show_free_areas(void);
139 extern unsigned long put_dirty_page(struct task_struct * tsk,unsigned long page,
140 unsigned long address);
141
142 extern void free_page_tables(struct task_struct * tsk);
143 extern void clear_page_tables(struct task_struct * tsk);
144 extern int copy_page_tables(struct task_struct * to);
145 extern int clone_page_tables(struct task_struct * to);
146 extern int unmap_page_range(unsigned long from, unsigned long size);
147 extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size, int mask);
148 extern int zeromap_page_range(unsigned long from, unsigned long size, int mask);
149
150 extern void do_wp_page(struct vm_area_struct * vma, unsigned long address,
151 unsigned long error_code);
152 extern void do_no_page(struct vm_area_struct * vma, unsigned long address,
153 unsigned long error_code);
154
155 extern unsigned long paging_init(unsigned long start_mem, unsigned long end_mem);
156 extern void mem_init(unsigned long low_start_mem,
157 unsigned long start_mem, unsigned long end_mem);
158 extern void show_mem(void);
159 extern void oom(struct task_struct * task);
160 extern void si_meminfo(struct sysinfo * val);
161
162
163
164 extern void * vmalloc(unsigned long size);
165 extern void vfree(void * addr);
166 extern int vread(char *buf, char *addr, int count);
167
168
169
170 extern void swap_free(unsigned long page_nr);
171 extern unsigned long swap_duplicate(unsigned long page_nr);
172 extern unsigned long swap_in(unsigned long entry);
173 extern void si_swapinfo(struct sysinfo * val);
174 extern void rw_swap_page(int rw, unsigned long nr, char * buf);
175
176
177 extern int do_mmap(struct file * file, unsigned long addr, unsigned long len,
178 unsigned long prot, unsigned long flags, unsigned long off);
179 typedef int (*map_mergep_fnp)(const struct vm_area_struct *,
180 const struct vm_area_struct *, void *);
181 extern void merge_segments(struct vm_area_struct *, map_mergep_fnp, void *);
182 extern void insert_vm_struct(struct task_struct *, struct vm_area_struct *);
183 extern int ignoff_mergep(const struct vm_area_struct *,
184 const struct vm_area_struct *, void *);
185 extern int do_munmap(unsigned long, size_t);
186
187 #define read_swap_page(nr,buf) \
188 rw_swap_page(READ,(nr),(buf))
189 #define write_swap_page(nr,buf) \
190 rw_swap_page(WRITE,(nr),(buf))
191
192 #define invalidate() \
193 __asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3": : :"ax")
194
195 extern unsigned long high_memory;
196
197 #define MAP_NR(addr) ((addr) >> PAGE_SHIFT)
198 #define MAP_PAGE_RESERVED (1<<15)
199
200 extern unsigned short * mem_map;
201
202 #define PAGE_PRESENT 0x001
203 #define PAGE_RW 0x002
204 #define PAGE_USER 0x004
205 #define PAGE_PWT 0x008
206 #define PAGE_PCD 0x010
207 #define PAGE_ACCESSED 0x020
208 #define PAGE_DIRTY 0x040
209 #define PAGE_COW 0x200
210
211 #define PAGE_PRIVATE (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
212 #define PAGE_SHARED (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
213 #define PAGE_COPY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
214 #define PAGE_READONLY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED)
215 #define PAGE_TABLE (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
216
217 #define GFP_BUFFER 0x00
218 #define GFP_ATOMIC 0x01
219 #define GFP_USER 0x02
220 #define GFP_KERNEL 0x03
221 #define GFP_NOBUFFER 0x04
222
223
224
225 #define SHM_SWP_TYPE 0x41
226 extern void shm_no_page (ulong *);
227
228
229 extern unsigned long * swap_cache;
230
231 extern inline unsigned long in_swap_cache(unsigned long addr)
232 {
233 return swap_cache[addr >> PAGE_SHIFT];
234 }
235
236 extern inline void swap_cache_invalidate(unsigned long addr)
237 {
238 swap_cache[addr >> PAGE_SHIFT] = 0;
239 }
240
241 #endif