blob: 213d92fd652aa24175ddd673c52cabb932d876be [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ASM_PAGE_H
2#define _ASM_PAGE_H
3
4#ifdef __KERNEL__
5
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include <asm/virtconvert.h>
7#include <asm/mem-layout.h>
8#include <asm/sections.h>
9#include <asm/setup.h>
10
11#ifndef __ASSEMBLY__
12
13#define get_user_page(vaddr) __get_free_page(GFP_KERNEL)
14#define free_user_page(page, addr) free_page(addr)
15
16#define clear_page(pgaddr) memset((pgaddr), 0, PAGE_SIZE)
17#define copy_page(to,from) memcpy((to), (from), PAGE_SIZE)
18
19#define clear_user_page(pgaddr, vaddr, page) memset((pgaddr), 0, PAGE_SIZE)
20#define copy_user_page(vto, vfrom, vaddr, topg) memcpy((vto), (vfrom), PAGE_SIZE)
21
22/*
23 * These are used to make use of C type-checking..
24 */
25typedef struct { unsigned long pte; } pte_t;
26typedef struct { unsigned long ste[64];} pmd_t;
27typedef struct { pmd_t pue[1]; } pud_t;
28typedef struct { pud_t pge[1]; } pgd_t;
29typedef struct { unsigned long pgprot; } pgprot_t;
30
31#define pte_val(x) ((x).pte)
32#define pmd_val(x) ((x).ste[0])
33#define pud_val(x) ((x).pue[0])
34#define pgd_val(x) ((x).pge[0])
35#define pgprot_val(x) ((x).pgprot)
36
37#define __pte(x) ((pte_t) { (x) } )
38#define __pmd(x) ((pmd_t) { (x) } )
39#define __pud(x) ((pud_t) { (x) } )
40#define __pgd(x) ((pgd_t) { (x) } )
41#define __pgprot(x) ((pgprot_t) { (x) } )
42#define PTE_MASK PAGE_MASK
43
44/* to align the pointer to the (next) page boundary */
45#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define devmem_is_allowed(pfn) 1
48
David Howells8080f232005-11-28 13:43:51 -080049#define __pa(vaddr) virt_to_phys((void *) (unsigned long) (vaddr))
50#define __va(paddr) phys_to_virt((unsigned long) (paddr))
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
53
54extern unsigned long max_low_pfn;
55extern unsigned long min_low_pfn;
56extern unsigned long max_pfn;
57
58#ifdef CONFIG_MMU
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#define pfn_valid(pfn) ((pfn) < max_mapnr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#else
KAMEZAWA Hiroyuki5cdac7c2006-03-27 01:15:40 -080061#define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#define pfn_valid(pfn) ((pfn) >= min_low_pfn && (pfn) < max_low_pfn)
63
64#endif
65
66#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
67#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
68
69
70#ifdef CONFIG_MMU
71#define VM_DATA_DEFAULT_FLAGS \
72 (VM_READ | VM_WRITE | \
73 ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
74 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
75#endif
76
77#endif /* __ASSEMBLY__ */
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#ifdef CONFIG_CONTIGUOUS_PAGE_ALLOC
80#define WANT_PAGE_VIRTUAL 1
81#endif
82
KAMEZAWA Hiroyuki5cdac7c2006-03-27 01:15:40 -080083#include <asm-generic/memory_model.h>
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -070084#include <asm-generic/page.h>
85
Al Viroe7bc5372007-02-01 13:08:45 +000086#endif /* __KERNEL__ */
87
Linus Torvalds1da177e2005-04-16 15:20:36 -070088#endif /* _ASM_PAGE_H */