1 #ifndef _I386_PAGE_H
2 #define _I386_PAGE_H
3
4 #define invalidate() \
5 __asm__ __volatile__("movl %%cr3,%%eax\n\tmovl %%eax,%%cr3": : :"ax")
6
7
8 #define PAGE_SHIFT 12
9 #define PGDIR_SHIFT 22
10 #define PAGE_SIZE (1UL << PAGE_SHIFT)
11 #define PGDIR_SIZE (1UL << PGDIR_SHIFT)
12
13 #ifdef __KERNEL__
14
15
16 #define BITS_PER_PTR (8*sizeof(unsigned long))
17
18 #define PAGE_MASK (~(PAGE_SIZE-1))
19
20 #define PGDIR_MASK (~(PGDIR_SIZE-1))
21
22 #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
23
24 #define PTR_MASK (~(sizeof(void*)-1))
25
26
27
28 #define SIZEOF_PTR_LOG2 2
29
30
31 #define PAGE_DIR_OFFSET(base,address) ((unsigned long*)((base)+\
32 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)*2&PTR_MASK&~PAGE_MASK)))
33
34 #define PAGE_PTR(address) \
35 ((unsigned long)(address)>>(PAGE_SHIFT-SIZEOF_PTR_LOG2)&PTR_MASK&~PAGE_MASK)
36
37 #define PTRS_PER_PAGE (PAGE_SIZE/sizeof(void*))
38
39 #endif
40
41 #endif