Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASM_PAGE_H |
| 2 | #define _ASM_PAGE_H |
| 3 | |
| 4 | #ifdef __KERNEL__ |
| 5 | |
| 6 | #include <linux/config.h> |
| 7 | #include <asm/virtconvert.h> |
| 8 | #include <asm/mem-layout.h> |
| 9 | #include <asm/sections.h> |
| 10 | #include <asm/setup.h> |
| 11 | |
| 12 | #ifndef __ASSEMBLY__ |
| 13 | |
| 14 | #define get_user_page(vaddr) __get_free_page(GFP_KERNEL) |
| 15 | #define free_user_page(page, addr) free_page(addr) |
| 16 | |
| 17 | #define clear_page(pgaddr) memset((pgaddr), 0, PAGE_SIZE) |
| 18 | #define copy_page(to,from) memcpy((to), (from), PAGE_SIZE) |
| 19 | |
| 20 | #define clear_user_page(pgaddr, vaddr, page) memset((pgaddr), 0, PAGE_SIZE) |
| 21 | #define copy_user_page(vto, vfrom, vaddr, topg) memcpy((vto), (vfrom), PAGE_SIZE) |
| 22 | |
| 23 | /* |
| 24 | * These are used to make use of C type-checking.. |
| 25 | */ |
| 26 | typedef struct { unsigned long pte; } pte_t; |
| 27 | typedef struct { unsigned long ste[64];} pmd_t; |
| 28 | typedef struct { pmd_t pue[1]; } pud_t; |
| 29 | typedef struct { pud_t pge[1]; } pgd_t; |
| 30 | typedef struct { unsigned long pgprot; } pgprot_t; |
| 31 | |
| 32 | #define pte_val(x) ((x).pte) |
| 33 | #define pmd_val(x) ((x).ste[0]) |
| 34 | #define pud_val(x) ((x).pue[0]) |
| 35 | #define pgd_val(x) ((x).pge[0]) |
| 36 | #define pgprot_val(x) ((x).pgprot) |
| 37 | |
| 38 | #define __pte(x) ((pte_t) { (x) } ) |
| 39 | #define __pmd(x) ((pmd_t) { (x) } ) |
| 40 | #define __pud(x) ((pud_t) { (x) } ) |
| 41 | #define __pgd(x) ((pgd_t) { (x) } ) |
| 42 | #define __pgprot(x) ((pgprot_t) { (x) } ) |
| 43 | #define PTE_MASK PAGE_MASK |
| 44 | |
| 45 | /* to align the pointer to the (next) page boundary */ |
| 46 | #define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK) |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define devmem_is_allowed(pfn) 1 |
| 49 | |
David Howells | 8080f23 | 2005-11-28 13:43:51 -0800 | [diff] [blame] | 50 | #define __pa(vaddr) virt_to_phys((void *) (unsigned long) (vaddr)) |
| 51 | #define __va(paddr) phys_to_virt((unsigned long) (paddr)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) |
| 54 | |
| 55 | extern unsigned long max_low_pfn; |
| 56 | extern unsigned long min_low_pfn; |
| 57 | extern unsigned long max_pfn; |
| 58 | |
| 59 | #ifdef CONFIG_MMU |
| 60 | #define pfn_to_page(pfn) (mem_map + (pfn)) |
| 61 | #define page_to_pfn(page) ((unsigned long) ((page) - mem_map)) |
| 62 | #define pfn_valid(pfn) ((pfn) < max_mapnr) |
| 63 | |
| 64 | #else |
| 65 | #define pfn_to_page(pfn) (&mem_map[(pfn) - (PAGE_OFFSET >> PAGE_SHIFT)]) |
| 66 | #define page_to_pfn(page) ((PAGE_OFFSET >> PAGE_SHIFT) + (unsigned long) ((page) - mem_map)) |
| 67 | #define pfn_valid(pfn) ((pfn) >= min_low_pfn && (pfn) < max_low_pfn) |
| 68 | |
| 69 | #endif |
| 70 | |
| 71 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) |
| 72 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) |
| 73 | |
| 74 | |
| 75 | #ifdef CONFIG_MMU |
| 76 | #define VM_DATA_DEFAULT_FLAGS \ |
| 77 | (VM_READ | VM_WRITE | \ |
| 78 | ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ |
| 79 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) |
| 80 | #endif |
| 81 | |
| 82 | #endif /* __ASSEMBLY__ */ |
| 83 | |
| 84 | #endif /* __KERNEL__ */ |
| 85 | |
| 86 | #ifdef CONFIG_CONTIGUOUS_PAGE_ALLOC |
| 87 | #define WANT_PAGE_VIRTUAL 1 |
| 88 | #endif |
| 89 | |
Stephen Rothwell | fd4fd5a | 2005-09-03 15:54:30 -0700 | [diff] [blame] | 90 | #include <asm-generic/page.h> |
| 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | #endif /* _ASM_PAGE_H */ |