Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _I386_PAGE_H |
| 2 | #define _I386_PAGE_H |
| 3 | |
| 4 | /* PAGE_SHIFT determines the page size */ |
| 5 | #define PAGE_SHIFT 12 |
| 6 | #define PAGE_SIZE (1UL << PAGE_SHIFT) |
| 7 | #define PAGE_MASK (~(PAGE_SIZE-1)) |
| 8 | |
| 9 | #define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1)) |
| 10 | #define LARGE_PAGE_SIZE (1UL << PMD_SHIFT) |
| 11 | |
| 12 | #ifdef __KERNEL__ |
| 13 | #ifndef __ASSEMBLY__ |
| 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | #ifdef CONFIG_X86_USE_3DNOW |
| 17 | |
| 18 | #include <asm/mmx.h> |
| 19 | |
| 20 | #define clear_page(page) mmx_clear_page((void *)(page)) |
| 21 | #define copy_page(to,from) mmx_copy_page(to,from) |
| 22 | |
| 23 | #else |
| 24 | |
| 25 | /* |
| 26 | * On older X86 processors it's not a win to use MMX here it seems. |
| 27 | * Maybe the K6-III ? |
| 28 | */ |
| 29 | |
| 30 | #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) |
| 31 | #define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE) |
| 32 | |
| 33 | #endif |
| 34 | |
| 35 | #define clear_user_page(page, vaddr, pg) clear_page(page) |
| 36 | #define copy_user_page(to, from, vaddr, pg) copy_page(to, from) |
| 37 | |
| 38 | #define alloc_zeroed_user_highpage(vma, vaddr) alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO, vma, vaddr) |
| 39 | #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE |
| 40 | |
| 41 | /* |
| 42 | * These are used to make use of C type-checking.. |
| 43 | */ |
| 44 | extern int nx_enabled; |
| 45 | #ifdef CONFIG_X86_PAE |
| 46 | extern unsigned long long __supported_pte_mask; |
| 47 | typedef struct { unsigned long pte_low, pte_high; } pte_t; |
| 48 | typedef struct { unsigned long long pmd; } pmd_t; |
| 49 | typedef struct { unsigned long long pgd; } pgd_t; |
| 50 | typedef struct { unsigned long long pgprot; } pgprot_t; |
| 51 | #define pmd_val(x) ((x).pmd) |
| 52 | #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32)) |
| 53 | #define __pmd(x) ((pmd_t) { (x) } ) |
| 54 | #define HPAGE_SHIFT 21 |
| 55 | #else |
| 56 | typedef struct { unsigned long pte_low; } pte_t; |
| 57 | typedef struct { unsigned long pgd; } pgd_t; |
| 58 | typedef struct { unsigned long pgprot; } pgprot_t; |
| 59 | #define boot_pte_t pte_t /* or would you rather have a typedef */ |
| 60 | #define pte_val(x) ((x).pte_low) |
| 61 | #define HPAGE_SHIFT 22 |
| 62 | #endif |
| 63 | #define PTE_MASK PAGE_MASK |
| 64 | |
| 65 | #ifdef CONFIG_HUGETLB_PAGE |
| 66 | #define HPAGE_SIZE ((1UL) << HPAGE_SHIFT) |
| 67 | #define HPAGE_MASK (~(HPAGE_SIZE - 1)) |
| 68 | #define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) |
| 69 | #define HAVE_ARCH_HUGETLB_UNMAPPED_AREA |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #endif |
| 71 | |
| 72 | #define pgd_val(x) ((x).pgd) |
| 73 | #define pgprot_val(x) ((x).pgprot) |
| 74 | |
| 75 | #define __pte(x) ((pte_t) { (x) } ) |
| 76 | #define __pgd(x) ((pgd_t) { (x) } ) |
| 77 | #define __pgprot(x) ((pgprot_t) { (x) } ) |
| 78 | |
| 79 | #endif /* !__ASSEMBLY__ */ |
| 80 | |
| 81 | /* to align the pointer to the (next) page boundary */ |
| 82 | #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) |
| 83 | |
| 84 | /* |
| 85 | * This handles the memory map.. We could make this a config |
| 86 | * option, but too many people screw it up, and too few need |
| 87 | * it. |
| 88 | * |
| 89 | * A __PAGE_OFFSET of 0xC0000000 means that the kernel has |
| 90 | * a virtual address space of one gigabyte, which limits the |
| 91 | * amount of physical memory you can use to about 950MB. |
| 92 | * |
| 93 | * If you want more physical memory than this then see the CONFIG_HIGHMEM4G |
| 94 | * and CONFIG_HIGHMEM64G options in the kernel configuration. |
| 95 | */ |
| 96 | |
| 97 | #ifndef __ASSEMBLY__ |
| 98 | |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 99 | struct vm_area_struct; |
| 100 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | /* |
| 102 | * This much address space is reserved for vmalloc() and iomap() |
| 103 | * as well as fixmap mappings. |
| 104 | */ |
| 105 | extern unsigned int __VMALLOC_RESERVE; |
| 106 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | extern int sysctl_legacy_va_layout; |
| 108 | |
Dave Hansen | 5b505b9 | 2005-06-23 00:07:41 -0700 | [diff] [blame] | 109 | extern int page_is_ram(unsigned long pagenr); |
| 110 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | #endif /* __ASSEMBLY__ */ |
| 112 | |
| 113 | #ifdef __ASSEMBLY__ |
Mark Lord | 975b3d3 | 2006-02-01 03:06:11 -0800 | [diff] [blame] | 114 | #define __PAGE_OFFSET CONFIG_PAGE_OFFSET |
Eric W. Biederman | 3d345e3 | 2005-06-25 14:57:49 -0700 | [diff] [blame] | 115 | #define __PHYSICAL_START CONFIG_PHYSICAL_START |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | #else |
Mark Lord | 975b3d3 | 2006-02-01 03:06:11 -0800 | [diff] [blame] | 117 | #define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET) |
Eric W. Biederman | 3d345e3 | 2005-06-25 14:57:49 -0700 | [diff] [blame] | 118 | #define __PHYSICAL_START ((unsigned long)CONFIG_PHYSICAL_START) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | #endif |
Eric W. Biederman | 3d345e3 | 2005-06-25 14:57:49 -0700 | [diff] [blame] | 120 | #define __KERNEL_START (__PAGE_OFFSET + __PHYSICAL_START) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
| 122 | |
| 123 | #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) |
| 124 | #define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE) |
| 125 | #define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE) |
| 126 | #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) |
| 127 | #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) |
| 128 | #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) |
Andy Whitcroft | 05b79bd | 2005-06-23 00:07:57 -0700 | [diff] [blame] | 129 | #ifdef CONFIG_FLATMEM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | #define pfn_valid(pfn) ((pfn) < max_mapnr) |
Andy Whitcroft | 05b79bd | 2005-06-23 00:07:57 -0700 | [diff] [blame] | 131 | #endif /* CONFIG_FLATMEM */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) |
| 133 | |
| 134 | #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) |
| 135 | |
| 136 | #define VM_DATA_DEFAULT_FLAGS \ |
| 137 | (VM_READ | VM_WRITE | \ |
| 138 | ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ |
| 139 | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) |
| 140 | |
KAMEZAWA Hiroyuki | ad658b3 | 2006-03-27 01:15:33 -0800 | [diff] [blame] | 141 | #include <asm-generic/memory_model.h> |
Stephen Rothwell | fd4fd5a | 2005-09-03 15:54:30 -0700 | [diff] [blame] | 142 | #include <asm-generic/page.h> |
| 143 | |
Ingo Molnar | e6e5494 | 2006-06-27 02:53:50 -0700 | [diff] [blame] | 144 | #define __HAVE_ARCH_GATE_AREA 1 |
David Woodhouse | cd469e0 | 2006-04-27 15:48:08 +0100 | [diff] [blame] | 145 | #endif /* __KERNEL__ */ |
| 146 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | #endif /* _I386_PAGE_H */ |