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