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 extern volatile short free_page_ptr;
96
97 extern int nr_swap_pages;
98 extern int nr_free_pages;
99 extern unsigned long free_page_list;
100 extern int nr_secondary_pages;
101 extern unsigned long secondary_page_list;
102
103 #define MAX_SECONDARY_PAGES 20
104
105
106
107
108
109
110 extern unsigned long __get_free_page(int priority);
111 extern inline unsigned long get_free_page(int priority)
112 {
113 unsigned long page;
114
115 page = __get_free_page(priority);
116 if (page)
117 __asm__ __volatile__("rep ; stosl"
118 : \
119 :"a" (0),"c" (1024),"D" (page)
120 :"di","cx");
121 return page;
122 }
123
124
125
126 extern void free_page(unsigned long addr);
127 extern unsigned long put_dirty_page(struct task_struct * tsk,unsigned long page,
128 unsigned long address);
129 extern void free_page_tables(struct task_struct * tsk);
130 extern void clear_page_tables(struct task_struct * tsk);
131 extern int copy_page_tables(struct task_struct * to);
132 extern int clone_page_tables(struct task_struct * to);
133 extern int unmap_page_range(unsigned long from, unsigned long size);
134 extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size, int mask);
135 extern int zeromap_page_range(unsigned long from, unsigned long size, int mask);
136
137 extern void do_wp_page(unsigned long error_code, unsigned long address,
138 struct task_struct *tsk, unsigned long user_esp);
139 extern void do_no_page(unsigned long error_code, unsigned long address,
140 struct task_struct *tsk, unsigned long user_esp);
141
142 extern unsigned long paging_init(unsigned long start_mem, unsigned long end_mem);
143 extern void mem_init(unsigned long low_start_mem,
144 unsigned long start_mem, unsigned long end_mem);
145 extern void show_mem(void);
146 extern void oom(struct task_struct * task);
147 extern void si_meminfo(struct sysinfo * val);
148
149
150
151 extern void * vmalloc(unsigned long size);
152 extern void vfree(void * addr);
153 extern int vread(char *buf, char *addr, int count);
154
155
156
157 extern void swap_free(unsigned long page_nr);
158 extern unsigned long swap_duplicate(unsigned long page_nr);
159 extern void swap_in(unsigned long *table_ptr);
160 extern void si_swapinfo(struct sysinfo * val);
161 extern void rw_swap_page(int rw, unsigned long nr, char * buf);
162
163
164 extern int do_mmap(struct file * file, unsigned long addr, unsigned long len,
165 unsigned long prot, unsigned long flags, unsigned long off);
166 typedef int (*map_mergep_fnp)(const struct vm_area_struct *,
167 const struct vm_area_struct *, void *);
168 extern void merge_segments(struct vm_area_struct *, map_mergep_fnp, void *);
169 extern void insert_vm_struct(struct task_struct *, struct vm_area_struct *);
170 extern int ignoff_mergep(const struct vm_area_struct *,
171 const struct vm_area_struct *, void *);
172 extern int do_munmap(unsigned long, size_t);
173
174 #define read_swap_page(nr,buf) \
175 rw_swap_page(READ,(nr),(buf))
176 #define write_swap_page(nr,buf) \
177 rw_swap_page(WRITE,(nr),(buf))
178
179 #define invalidate() \
180 __asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3": : :"ax")
181
182 extern unsigned long high_memory;
183
184 #define MAP_NR(addr) ((addr) >> PAGE_SHIFT)
185 #define MAP_PAGE_RESERVED (1<<15)
186
187 extern unsigned short * mem_map;
188
189 #define PAGE_PRESENT 0x001
190 #define PAGE_RW 0x002
191 #define PAGE_USER 0x004
192 #define PAGE_PWT 0x008
193 #define PAGE_PCD 0x010
194 #define PAGE_ACCESSED 0x020
195 #define PAGE_DIRTY 0x040
196 #define PAGE_COW 0x200
197
198 #define PAGE_PRIVATE (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
199 #define PAGE_SHARED (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
200 #define PAGE_COPY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
201 #define PAGE_READONLY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED)
202 #define PAGE_TABLE (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
203
204 #define GFP_BUFFER 0x00
205 #define GFP_ATOMIC 0x01
206 #define GFP_USER 0x02
207 #define GFP_KERNEL 0x03
208
209
210
211 #define SHM_SWP_TYPE 0x41
212 extern void shm_no_page (ulong *);
213
214 #endif