This source file includes following definitions.
- verify_area
- get_free_page
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 int __verify_write(unsigned long addr, unsigned long count);
13
14 extern inline int verify_area(int type, const void * addr, unsigned long size)
15 {
16 if (TASK_SIZE <= (unsigned long) addr)
17 return -EFAULT;
18 if (size > TASK_SIZE - (unsigned long) addr)
19 return -EFAULT;
20 if (wp_works_ok || type == VERIFY_READ || !size)
21 return 0;
22 return __verify_write((unsigned long) addr,size);
23 }
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 struct vm_area_struct {
41 struct task_struct * vm_task;
42 unsigned long vm_start;
43 unsigned long vm_end;
44 unsigned short vm_page_prot;
45 struct vm_area_struct * vm_next;
46 struct vm_area_struct * vm_share;
47 struct inode * vm_inode;
48 unsigned long vm_offset;
49 struct vm_operations_struct * vm_ops;
50 };
51
52
53
54
55
56
57
58 struct vm_operations_struct {
59 void (*open)(struct vm_area_struct * area);
60 void (*close)(struct vm_area_struct * area);
61 void (*nopage)(int error_code,
62 struct vm_area_struct * area, unsigned long address);
63 void (*wppage)(struct vm_area_struct * area, unsigned long address);
64 int (*share)(struct vm_area_struct * from, struct vm_area_struct * to, unsigned long address);
65 int (*unmap)(struct vm_area_struct *area, unsigned long, size_t);
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 extern void free_page_tables(struct task_struct * tsk);
142 extern void clear_page_tables(struct task_struct * tsk);
143 extern int copy_page_tables(struct task_struct * to);
144 extern int clone_page_tables(struct task_struct * to);
145 extern int unmap_page_range(unsigned long from, unsigned long size);
146 extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size, int mask);
147 extern int zeromap_page_range(unsigned long from, unsigned long size, int mask);
148
149 extern void do_wp_page(unsigned long error_code, unsigned long address,
150 struct task_struct *tsk, unsigned long user_esp);
151 extern void do_no_page(unsigned long error_code, unsigned long address,
152 struct task_struct *tsk, unsigned long user_esp);
153
154 extern unsigned long paging_init(unsigned long start_mem, unsigned long end_mem);
155 extern void mem_init(unsigned long low_start_mem,
156 unsigned long start_mem, unsigned long end_mem);
157 extern void show_mem(void);
158 extern void oom(struct task_struct * task);
159 extern void si_meminfo(struct sysinfo * val);
160
161
162
163 extern void * vmalloc(unsigned long size);
164 extern void vfree(void * addr);
165 extern int vread(char *buf, char *addr, int count);
166
167
168
169 extern void swap_free(unsigned long page_nr);
170 extern unsigned long swap_duplicate(unsigned long page_nr);
171 extern void swap_in(unsigned long *table_ptr);
172 extern void si_swapinfo(struct sysinfo * val);
173 extern void rw_swap_page(int rw, unsigned long nr, char * buf);
174
175
176 extern int do_mmap(struct file * file, unsigned long addr, unsigned long len,
177 unsigned long prot, unsigned long flags, unsigned long off);
178 typedef int (*map_mergep_fnp)(const struct vm_area_struct *,
179 const struct vm_area_struct *, void *);
180 extern void merge_segments(struct vm_area_struct *, map_mergep_fnp, void *);
181 extern void insert_vm_struct(struct task_struct *, struct vm_area_struct *);
182 extern int ignoff_mergep(const struct vm_area_struct *,
183 const struct vm_area_struct *, void *);
184 extern int do_munmap(unsigned long, size_t);
185
186 #define read_swap_page(nr,buf) \
187 rw_swap_page(READ,(nr),(buf))
188 #define write_swap_page(nr,buf) \
189 rw_swap_page(WRITE,(nr),(buf))
190
191 #define invalidate() \
192 __asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3": : :"ax")
193
194 extern unsigned long high_memory;
195
196 #define MAP_NR(addr) ((addr) >> PAGE_SHIFT)
197 #define MAP_PAGE_RESERVED (1<<15)
198
199 extern unsigned short * mem_map;
200
201 #define PAGE_PRESENT 0x001
202 #define PAGE_RW 0x002
203 #define PAGE_USER 0x004
204 #define PAGE_PWT 0x008
205 #define PAGE_PCD 0x010
206 #define PAGE_ACCESSED 0x020
207 #define PAGE_DIRTY 0x040
208 #define PAGE_COW 0x200
209
210 #define PAGE_PRIVATE (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
211 #define PAGE_SHARED (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
212 #define PAGE_COPY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
213 #define PAGE_READONLY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED)
214 #define PAGE_TABLE (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
215
216 #define GFP_BUFFER 0x00
217 #define GFP_ATOMIC 0x01
218 #define GFP_USER 0x02
219 #define GFP_KERNEL 0x03
220 #define GFP_NOBUFFER 0x04
221
222
223
224 #define SHM_SWP_TYPE 0x41
225 extern void shm_no_page (ulong *);
226
227 #endif