Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _X86_64_PAGE_H |
| 2 | #define _X86_64_PAGE_H |
| 3 | |
Randy Dunlap | 6df95fd | 2007-05-08 00:31:11 -0700 | [diff] [blame] | 4 | #include <linux/const.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | |
| 6 | /* PAGE_SHIFT determines the page size */ |
| 7 | #define PAGE_SHIFT 12 |
Vivek Goyal | 9d291e7 | 2007-05-02 19:27:06 +0200 | [diff] [blame] | 8 | #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
Andi Kleen | 6b75aee | 2005-11-05 17:25:53 +0100 | [diff] [blame] | 10 | #define PHYSICAL_PAGE_MASK (~(PAGE_SIZE-1) & __PHYSICAL_MASK) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
| 12 | #define THREAD_ORDER 1 |
Jan Beulich | b556b35 | 2006-01-11 22:43:00 +0100 | [diff] [blame] | 13 | #define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #define CURRENT_MASK (~(THREAD_SIZE-1)) |
| 15 | |
Jan Beulich | b556b35 | 2006-01-11 22:43:00 +0100 | [diff] [blame] | 16 | #define EXCEPTION_STACK_ORDER 0 |
| 17 | #define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER) |
| 18 | |
bibo mao | a4045df | 2006-07-28 14:44:48 +0200 | [diff] [blame] | 19 | #define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1) |
Jan Beulich | b556b35 | 2006-01-11 22:43:00 +0100 | [diff] [blame] | 20 | #define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER) |
| 21 | |
| 22 | #define IRQSTACK_ORDER 2 |
| 23 | #define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER) |
| 24 | |
Andi Kleen | 5f8efbb | 2006-01-16 01:56:39 +0100 | [diff] [blame] | 25 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1)) |
Vivek Goyal | 9d291e7 | 2007-05-02 19:27:06 +0200 | [diff] [blame] | 33 | #define LARGE_PAGE_SIZE (_AC(1,UL) << PMD_SHIFT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | #define HPAGE_SHIFT PMD_SHIFT |
Vivek Goyal | 9d291e7 | 2007-05-02 19:27:06 +0200 | [diff] [blame] | 36 | #define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #define HPAGE_MASK (~(HPAGE_SIZE - 1)) |
| 38 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | #ifdef __KERNEL__ |
| 41 | #ifndef __ASSEMBLY__ |
| 42 | |
Andi Kleen | b9aac10 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 43 | extern unsigned long end_pfn; |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | void clear_page(void *); |
| 46 | void 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 Gorman | 769848c | 2007-07-17 04:03:05 -0700 | [diff] [blame] | 51 | #define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \ |
| 52 | alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE |
| 54 | /* |
| 55 | * These are used to make use of C type-checking.. |
| 56 | */ |
| 57 | typedef struct { unsigned long pte; } pte_t; |
| 58 | typedef struct { unsigned long pmd; } pmd_t; |
| 59 | typedef struct { unsigned long pud; } pud_t; |
| 60 | typedef struct { unsigned long pgd; } pgd_t; |
| 61 | #define PTE_MASK PHYSICAL_PAGE_MASK |
| 62 | |
| 63 | typedef struct { unsigned long pgprot; } pgprot_t; |
| 64 | |
Vivek Goyal | 1ab60e0 | 2007-05-02 19:27:07 +0200 | [diff] [blame] | 65 | extern unsigned long phys_base; |
| 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | #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 Goyal | 9d291e7 | 2007-05-02 19:27:06 +0200 | [diff] [blame] | 79 | #endif /* !__ASSEMBLY__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
Eric W. Biederman | d053750 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 81 | #define __PHYSICAL_START CONFIG_PHYSICAL_START |
Vivek Goyal | 6a50a66 | 2007-05-02 19:27:08 +0200 | [diff] [blame] | 82 | #define __KERNEL_ALIGN 0x200000 |
Randy Dunlap | 63f6564 | 2007-05-08 00:31:14 -0700 | [diff] [blame] | 83 | |
Vivek Goyal | 069f11f | 2007-05-10 22:22:15 -0700 | [diff] [blame] | 84 | /* |
| 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. Biederman | d053750 | 2005-06-25 14:57:52 -0700 | [diff] [blame] | 93 | #define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START) |
Randy Dunlap | 63f6564 | 2007-05-08 00:31:14 -0700 | [diff] [blame] | 94 | #define __START_KERNEL_map _AC(0xffffffff80000000, UL) |
| 95 | #define __PAGE_OFFSET _AC(0xffff810000000000, UL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 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 Goyal | 9d291e7 | 2007-05-02 19:27:06 +0200 | [diff] [blame] | 102 | #define __PHYSICAL_MASK ((_AC(1,UL) << __PHYSICAL_MASK_SHIFT) - 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | #define __VIRTUAL_MASK_SHIFT 48 |
Vivek Goyal | 9d291e7 | 2007-05-02 19:27:06 +0200 | [diff] [blame] | 104 | #define __VIRTUAL_MASK ((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
Vivek Goyal | 9d291e7 | 2007-05-02 19:27:06 +0200 | [diff] [blame] | 106 | #define KERNEL_TEXT_SIZE (40*1024*1024) |
Randy Dunlap | 63f6564 | 2007-05-08 00:31:14 -0700 | [diff] [blame] | 107 | #define KERNEL_TEXT_START _AC(0xffffffff80000000, UL) |
Linus Torvalds | e3ebadd | 2007-05-07 08:44:24 -0700 | [diff] [blame] | 108 | #define PAGE_OFFSET __PAGE_OFFSET |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | |
| 110 | #ifndef __ASSEMBLY__ |
| 111 | |
| 112 | #include <asm/bug.h> |
| 113 | |
Linus Torvalds | e3ebadd | 2007-05-07 08:44:24 -0700 | [diff] [blame] | 114 | extern unsigned long __phys_addr(unsigned long); |
| 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | #endif /* __ASSEMBLY__ */ |
| 117 | |
Linus Torvalds | e3ebadd | 2007-05-07 08:44:24 -0700 | [diff] [blame] | 118 | #define __pa(x) __phys_addr((unsigned long)(x)) |
| 119 | #define __pa_symbol(x) __phys_addr((unsigned long)(x)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) |
Linus Torvalds | e3ebadd | 2007-05-07 08:44:24 -0700 | [diff] [blame] | 122 | #define __boot_va(x) __va(x) |
| 123 | #define __boot_pa(x) __pa(x) |
Matt Tolentino | 2b97690 | 2005-06-23 00:08:06 -0700 | [diff] [blame] | 124 | #ifdef CONFIG_FLATMEM |
Andi Kleen | b9aac10 | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 125 | #define pfn_valid(pfn) ((pfn) < end_pfn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | #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 Hiroyuki | dc8ecb4 | 2006-03-27 01:15:34 -0800 | [diff] [blame] | 138 | #include <asm-generic/memory_model.h> |
Stephen Rothwell | fd4fd5a | 2005-09-03 15:54:30 -0700 | [diff] [blame] | 139 | #include <asm-generic/page.h> |
| 140 | |
David Woodhouse | cd469e0 | 2006-04-27 15:48:08 +0100 | [diff] [blame] | 141 | #endif /* __KERNEL__ */ |
| 142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | #endif /* _X86_64_PAGE_H */ |