blob: 69ef7cf9dadd0f36cec98dc704661a8976e37cbf [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _X86_64_PAGE_H
2#define _X86_64_PAGE_H
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#ifdef __KERNEL__
5#ifndef __ASSEMBLY__
6
Andi Kleenb9aac102005-09-12 18:49:24 +02007extern unsigned long end_pfn;
Thomas Gleixnera89518b2008-01-30 13:30:17 +01008extern unsigned long end_pfn_map;
Andi Kleenb9aac102005-09-12 18:49:24 +02009
Randy Dunlap6b4b05b2008-01-30 13:31:09 +010010void clear_page(void *page);
11void copy_page(void *to, void *from);
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Randy Dunlap6b4b05b2008-01-30 13:31:09 +010013struct page;
14
15static void inline clear_user_page(void *page, unsigned long vaddr,
16 struct page *pg)
17{
18 clear_page(page);
19}
20
21static void inline copy_user_page(void *to, void *from, unsigned long vaddr,
22 struct page *topage)
23{
24 copy_page(to, from);
25}
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Mel Gorman769848c2007-07-17 04:03:05 -070027#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
28 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
30/*
31 * These are used to make use of C type-checking..
32 */
33typedef struct { unsigned long pte; } pte_t;
34typedef struct { unsigned long pmd; } pmd_t;
35typedef struct { unsigned long pud; } pud_t;
36typedef struct { unsigned long pgd; } pgd_t;
37#define PTE_MASK PHYSICAL_PAGE_MASK
38
39typedef struct { unsigned long pgprot; } pgprot_t;
40
Vivek Goyal1ab60e02007-05-02 19:27:07 +020041extern unsigned long phys_base;
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#define pte_val(x) ((x).pte)
44#define pmd_val(x) ((x).pmd)
45#define pud_val(x) ((x).pud)
46#define pgd_val(x) ((x).pgd)
47#define pgprot_val(x) ((x).pgprot)
48
49#define __pte(x) ((pte_t) { (x) } )
50#define __pmd(x) ((pmd_t) { (x) } )
51#define __pud(x) ((pud_t) { (x) } )
52#define __pgd(x) ((pgd_t) { (x) } )
53#define __pgprot(x) ((pgprot_t) { (x) } )
54
Vivek Goyal9d291e72007-05-02 19:27:06 +020055#endif /* !__ASSEMBLY__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#ifndef __ASSEMBLY__
58
59#include <asm/bug.h>
60
Linus Torvaldse3ebadd2007-05-07 08:44:24 -070061extern unsigned long __phys_addr(unsigned long);
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#endif /* __ASSEMBLY__ */
64
Linus Torvaldse3ebadd2007-05-07 08:44:24 -070065#define __pa(x) __phys_addr((unsigned long)(x))
66#define __pa_symbol(x) __phys_addr((unsigned long)(x))
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
Linus Torvaldse3ebadd2007-05-07 08:44:24 -070069#define __boot_va(x) __va(x)
70#define __boot_pa(x) __pa(x)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
73#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
74#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076#define __HAVE_ARCH_GATE_AREA 1
Christoph Lameter0889eba2007-10-16 01:24:15 -070077#define vmemmap ((struct page *)VMEMMAP_START)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
KAMEZAWA Hiroyukidc8ecb42006-03-27 01:15:34 -080079#include <asm-generic/memory_model.h>
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -070080#include <asm-generic/page.h>
81
David Woodhousecd469e02006-04-27 15:48:08 +010082#endif /* __KERNEL__ */
83
Jeremy Fitzhardinge83a51012008-01-30 13:32:41 +010084#ifdef CONFIG_FLATMEM
85#define pfn_valid(pfn) ((pfn) < end_pfn)
86#endif
87
88
Linus Torvalds1da177e2005-04-16 15:20:36 -070089#endif /* _X86_64_PAGE_H */