blob: 88adf1afb0a28ce66caac316f8d997c99c569a03 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _X86_64_PAGE_H
2#define _X86_64_PAGE_H
3
Randy Dunlap6df95fd2007-05-08 00:31:11 -07004#include <linux/const.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
6/* PAGE_SHIFT determines the page size */
7#define PAGE_SHIFT 12
Vivek Goyal9d291e72007-05-02 19:27:06 +02008#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#define PAGE_MASK (~(PAGE_SIZE-1))
Andi Kleen6b75aee2005-11-05 17:25:53 +010010#define PHYSICAL_PAGE_MASK (~(PAGE_SIZE-1) & __PHYSICAL_MASK)
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
12#define THREAD_ORDER 1
Jan Beulichb556b352006-01-11 22:43:00 +010013#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER)
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#define CURRENT_MASK (~(THREAD_SIZE-1))
15
Jan Beulichb556b352006-01-11 22:43:00 +010016#define EXCEPTION_STACK_ORDER 0
17#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
18
bibo maoa4045df2006-07-28 14:44:48 +020019#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
Jan Beulichb556b352006-01-11 22:43:00 +010020#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
21
22#define IRQSTACK_ORDER 2
23#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER)
24
Andi Kleen5f8efbb2006-01-16 01:56:39 +010025#define STACKFAULT_STACK 1
26#define DOUBLEFAULT_STACK 2
27#define NMI_STACK 3
28#define DEBUG_STACK 4
29#define MCE_STACK 5
30#define N_EXCEPTION_STACKS 5 /* hw limit: 7 */
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
Vivek Goyal9d291e72007-05-02 19:27:06 +020033#define LARGE_PAGE_SIZE (_AC(1,UL) << PMD_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35#define HPAGE_SHIFT PMD_SHIFT
Vivek Goyal9d291e72007-05-02 19:27:06 +020036#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#define HPAGE_MASK (~(HPAGE_SIZE - 1))
38#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40#ifdef __KERNEL__
41#ifndef __ASSEMBLY__
42
Andi Kleenb9aac102005-09-12 18:49:24 +020043extern unsigned long end_pfn;
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045void clear_page(void *);
46void copy_page(void *, void *);
47
48#define clear_user_page(page, vaddr, pg) clear_page(page)
49#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
50
Mel Gorman769848c2007-07-17 04:03:05 -070051#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
52 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
54/*
55 * These are used to make use of C type-checking..
56 */
57typedef struct { unsigned long pte; } pte_t;
58typedef struct { unsigned long pmd; } pmd_t;
59typedef struct { unsigned long pud; } pud_t;
60typedef struct { unsigned long pgd; } pgd_t;
61#define PTE_MASK PHYSICAL_PAGE_MASK
62
63typedef struct { unsigned long pgprot; } pgprot_t;
64
Vivek Goyal1ab60e02007-05-02 19:27:07 +020065extern unsigned long phys_base;
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#define pte_val(x) ((x).pte)
68#define pmd_val(x) ((x).pmd)
69#define pud_val(x) ((x).pud)
70#define pgd_val(x) ((x).pgd)
71#define pgprot_val(x) ((x).pgprot)
72
73#define __pte(x) ((pte_t) { (x) } )
74#define __pmd(x) ((pmd_t) { (x) } )
75#define __pud(x) ((pud_t) { (x) } )
76#define __pgd(x) ((pgd_t) { (x) } )
77#define __pgprot(x) ((pgprot_t) { (x) } )
78
Vivek Goyal9d291e72007-05-02 19:27:06 +020079#endif /* !__ASSEMBLY__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Eric W. Biedermand0537502005-06-25 14:57:52 -070081#define __PHYSICAL_START CONFIG_PHYSICAL_START
Vivek Goyal6a50a662007-05-02 19:27:08 +020082#define __KERNEL_ALIGN 0x200000
Randy Dunlap63f65642007-05-08 00:31:14 -070083
Vivek Goyal069f11f2007-05-10 22:22:15 -070084/*
85 * Make sure kernel is aligned to 2MB address. Catching it at compile
86 * time is better. Change your config file and compile the kernel
87 * for a 2MB aligned address (CONFIG_PHYSICAL_START)
88 */
89#if (CONFIG_PHYSICAL_START % __KERNEL_ALIGN) != 0
90#error "CONFIG_PHYSICAL_START must be a multiple of 2MB"
91#endif
92
Eric W. Biedermand0537502005-06-25 14:57:52 -070093#define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START)
Randy Dunlap63f65642007-05-08 00:31:14 -070094#define __START_KERNEL_map _AC(0xffffffff80000000, UL)
95#define __PAGE_OFFSET _AC(0xffff810000000000, UL)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97/* to align the pointer to the (next) page boundary */
98#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
99
100/* See Documentation/x86_64/mm.txt for a description of the memory map. */
101#define __PHYSICAL_MASK_SHIFT 46
Vivek Goyal9d291e72007-05-02 19:27:06 +0200102#define __PHYSICAL_MASK ((_AC(1,UL) << __PHYSICAL_MASK_SHIFT) - 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103#define __VIRTUAL_MASK_SHIFT 48
Vivek Goyal9d291e72007-05-02 19:27:06 +0200104#define __VIRTUAL_MASK ((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
Vivek Goyal9d291e72007-05-02 19:27:06 +0200106#define KERNEL_TEXT_SIZE (40*1024*1024)
Randy Dunlap63f65642007-05-08 00:31:14 -0700107#define KERNEL_TEXT_START _AC(0xffffffff80000000, UL)
Linus Torvaldse3ebadd2007-05-07 08:44:24 -0700108#define PAGE_OFFSET __PAGE_OFFSET
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
110#ifndef __ASSEMBLY__
111
112#include <asm/bug.h>
113
Linus Torvaldse3ebadd2007-05-07 08:44:24 -0700114extern unsigned long __phys_addr(unsigned long);
115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116#endif /* __ASSEMBLY__ */
117
Linus Torvaldse3ebadd2007-05-07 08:44:24 -0700118#define __pa(x) __phys_addr((unsigned long)(x))
119#define __pa_symbol(x) __phys_addr((unsigned long)(x))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
121#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
Linus Torvaldse3ebadd2007-05-07 08:44:24 -0700122#define __boot_va(x) __va(x)
123#define __boot_pa(x) __pa(x)
Matt Tolentino2b976902005-06-23 00:08:06 -0700124#ifdef CONFIG_FLATMEM
Andi Kleenb9aac102005-09-12 18:49:24 +0200125#define pfn_valid(pfn) ((pfn) < end_pfn)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126#endif
127
128#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
129#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
130#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
131
132#define VM_DATA_DEFAULT_FLAGS \
133 (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
134 VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
135
136#define __HAVE_ARCH_GATE_AREA 1
137
KAMEZAWA Hiroyukidc8ecb42006-03-27 01:15:34 -0800138#include <asm-generic/memory_model.h>
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -0700139#include <asm-generic/page.h>
140
David Woodhousecd469e02006-04-27 15:48:08 +0100141#endif /* __KERNEL__ */
142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143#endif /* _X86_64_PAGE_H */