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