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