This source file includes following definitions.
- get_free_page
1 #ifndef _LINUX_MM_H
2 #define _LINUX_MM_H
3
4 #define PAGE_SIZE 4096
5 #define PAGE_SHIFT 12
6
7 #include <linux/fs.h>
8 #include <linux/kernel.h>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 struct vm_area_struct {
26 struct task_struct * vm_task;
27 unsigned long vm_start;
28 unsigned long vm_end;
29 struct vm_area_struct * vm_next;
30 struct vm_area_struct * vm_share;
31 struct inode * vm_inode;
32 unsigned long vm_offset;
33 struct vm_operations_struct * vm_ops;
34 };
35
36
37
38
39
40
41
42 struct vm_operations_struct {
43 void (*open)(struct vm_area_struct * area);
44 void (*close)(struct vm_area_struct * area);
45 void (*nopage)(struct vm_area_struct * area, unsigned long address);
46 void (*wppage)(struct vm_area_struct * area, unsigned long address);
47 int (*share)(struct vm_area_struct * old, struct vm_area_struct * new, unsigned long address);
48 };
49
50 extern unsigned long __bad_page(void);
51 extern unsigned long __bad_pagetable(void);
52 extern unsigned long __zero_page(void);
53
54 #define BAD_PAGETABLE __bad_pagetable()
55 #define BAD_PAGE __bad_page()
56 #define ZERO_PAGE __zero_page()
57
58 extern volatile short free_page_ptr;
59
60 extern int nr_free_pages;
61 extern unsigned long free_page_list;
62 extern int nr_secondary_pages;
63 extern unsigned long secondary_page_list;
64
65 #define MAX_SECONDARY_PAGES 10
66
67
68
69
70
71
72 extern unsigned long __get_free_page(int priority);
73 extern inline unsigned long get_free_page(int priority)
74 {
75 unsigned long page;
76
77 page = __get_free_page(priority);
78 if (page)
79 __asm__ __volatile__("rep ; stosl"
80 ::"a" (0),"c" (1024),"D" (page)
81 :"di","cx");
82 return page;
83 }
84
85
86
87
88
89 extern void free_page(unsigned long addr);
90 extern unsigned long put_dirty_page(struct task_struct * tsk,unsigned long page,
91 unsigned long address);
92 extern void free_page_tables(struct task_struct * tsk);
93 extern void clear_page_tables(struct task_struct * tsk);
94 extern int copy_page_tables(struct task_struct * new);
95 extern int clone_page_tables(struct task_struct * new);
96 extern int unmap_page_range(unsigned long from, unsigned long size);
97 extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size, int mask);
98 extern int zeromap_page_range(unsigned long from, unsigned long size, int mask);
99
100 extern void do_wp_page(unsigned long error_code, unsigned long address,
101 struct task_struct *tsk, unsigned long user_esp);
102 extern void do_no_page(unsigned long error_code, unsigned long address,
103 struct task_struct *tsk, unsigned long user_esp);
104
105 extern unsigned long paging_init(unsigned long start_mem, unsigned long end_mem);
106 extern void mem_init(unsigned long low_start_mem,
107 unsigned long start_mem, unsigned long end_mem);
108 extern void show_mem(void);
109 extern void do_page_fault(unsigned long *esp, unsigned long error_code);
110 extern void oom(struct task_struct * task);
111 extern void si_meminfo(struct sysinfo * val);
112
113
114
115 extern void swap_free(unsigned long page_nr);
116 extern unsigned long swap_duplicate(unsigned long page_nr);
117 extern void swap_in(unsigned long *table_ptr);
118 extern void si_swapinfo(struct sysinfo * val);
119 extern void rw_swap_page(int rw, unsigned long nr, char * buf);
120
121 #define read_swap_page(nr,buf) \
122 rw_swap_page(READ,(nr),(buf))
123 #define write_swap_page(nr,buf) \
124 rw_swap_page(WRITE,(nr),(buf))
125
126 #define invalidate() \
127 __asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3":::"ax")
128
129 extern unsigned long high_memory;
130
131 #define MAP_NR(addr) ((addr) >> PAGE_SHIFT)
132 #define MAP_PAGE_RESERVED (1<<15)
133
134 extern unsigned short * mem_map;
135
136 #define PAGE_PRESENT 0x001
137 #define PAGE_RW 0x002
138 #define PAGE_USER 0x004
139 #define PAGE_PWT 0x008
140 #define PAGE_PCD 0x010
141 #define PAGE_ACCESSED 0x020
142 #define PAGE_DIRTY 0x040
143 #define PAGE_COW 0x200
144
145 #define PAGE_PRIVATE (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
146 #define PAGE_SHARED (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
147 #define PAGE_COPY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED | PAGE_COW)
148 #define PAGE_READONLY (PAGE_PRESENT | PAGE_USER | PAGE_ACCESSED)
149 #define PAGE_TABLE (PAGE_PRESENT | PAGE_RW | PAGE_USER | PAGE_ACCESSED)
150
151 #define GFP_BUFFER 0x00
152 #define GFP_ATOMIC 0x01
153 #define GFP_USER 0x02
154 #define GFP_KERNEL 0x03
155
156 #endif