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
53 #define BAD_PAGETABLE __bad_pagetable()
54 #define BAD_PAGE __bad_page()
55
56 extern volatile short free_page_ptr;
57
58 extern int nr_free_pages;
59 extern unsigned long free_page_list;
60 extern int nr_secondary_pages;
61 extern unsigned long secondary_page_list;
62
63 #define MAX_SECONDARY_PAGES 10
64
65 extern void rw_swap_page(int rw, unsigned int nr, char * buf);
66
67 #define read_swap_page(nr,buf) \
68 rw_swap_page(READ,(nr),(buf))
69 #define write_swap_page(nr,buf) \
70 rw_swap_page(WRITE,(nr),(buf))
71
72
73
74
75
76 extern unsigned long get_free_page(int priority);
77 extern unsigned long put_dirty_page(struct task_struct * tsk,unsigned long page,
78 unsigned long address);
79 extern void free_page(unsigned long addr);
80 extern void free_page_tables(struct task_struct * tsk);
81 extern void clear_page_tables(struct task_struct * tsk);
82 extern int copy_page_tables(struct task_struct * new);
83 extern int unmap_page_range(unsigned long from, unsigned long size);
84 extern int remap_page_range(unsigned long from, unsigned long to, unsigned long size,
85 int permiss);
86 extern void write_verify(unsigned long address);
87
88 extern void do_wp_page(unsigned long error_code, unsigned long address,
89 struct task_struct *tsk, unsigned long user_esp);
90 extern void do_no_page(unsigned long error_code, unsigned long address,
91 struct task_struct *tsk, unsigned long user_esp);
92
93 extern unsigned long paging_init(unsigned long start_mem, unsigned long end_mem);
94 extern void mem_init(unsigned long low_start_mem,
95 unsigned long start_mem, unsigned long end_mem);
96 extern void show_mem(void);
97 extern void do_page_fault(unsigned long *esp, unsigned long error_code);
98 extern void oom(struct task_struct * task);
99 extern void si_meminfo(struct sysinfo * val);
100
101
102
103 extern void swap_free(unsigned int page_nr);
104 extern void swap_duplicate(unsigned int page_nr);
105 extern void swap_in(unsigned long *table_ptr);
106 extern void si_swapinfo(struct sysinfo * val);
107
108 #define invalidate() \
109 __asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3":::"ax")
110
111 extern unsigned long high_memory;
112
113 #define MAP_NR(addr) ((addr) >> PAGE_SHIFT)
114 #define MAP_PAGE_RESERVED (1<<15)
115
116 extern unsigned short * mem_map;
117
118 #define PAGE_DIRTY 0x40
119 #define PAGE_ACCESSED 0x20
120 #define PAGE_USER 0x04
121 #define PAGE_RW 0x02
122 #define PAGE_PRESENT 0x01
123
124 #define GFP_BUFFER 0x00
125 #define GFP_ATOMIC 0x01
126 #define GFP_USER 0x02
127 #define GFP_KERNEL 0x03
128
129 #endif