blob: 99cf5d3692a920699c5e50a99d32609363b81218 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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 Torvalds1da177e2005-04-16 15:20:36 -070015#ifdef CONFIG_X86_USE_3DNOW
16
17#include <asm/mmx.h>
18
19#define clear_page(page) mmx_clear_page((void *)(page))
20#define copy_page(to,from) mmx_copy_page(to,from)
21
22#else
23
24/*
25 * On older X86 processors it's not a win to use MMX here it seems.
26 * Maybe the K6-III ?
27 */
28
29#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
30#define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE)
31
32#endif
33
34#define clear_user_page(page, vaddr, pg) clear_page(page)
35#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
36
Mel Gorman769848c2007-07-17 04:03:05 -070037#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
38 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
40
41/*
42 * These are used to make use of C type-checking..
43 */
44extern int nx_enabled;
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +020045
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#ifdef CONFIG_X86_PAE
47extern unsigned long long __supported_pte_mask;
48typedef struct { unsigned long pte_low, pte_high; } pte_t;
49typedef struct { unsigned long long pmd; } pmd_t;
50typedef struct { unsigned long long pgd; } pgd_t;
51typedef struct { unsigned long long pgprot; } pgprot_t;
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +020052
53static inline unsigned long long native_pgd_val(pgd_t pgd)
54{
55 return pgd.pgd;
56}
57
58static inline unsigned long long native_pmd_val(pmd_t pmd)
59{
60 return pmd.pmd;
61}
62
63static inline unsigned long long native_pte_val(pte_t pte)
64{
65 return pte.pte_low | ((unsigned long long)pte.pte_high << 32);
66}
67
68static inline pgd_t native_make_pgd(unsigned long long val)
69{
70 return (pgd_t) { val };
71}
72
73static inline pmd_t native_make_pmd(unsigned long long val)
74{
75 return (pmd_t) { val };
76}
77
78static inline pte_t native_make_pte(unsigned long long val)
79{
80 return (pte_t) { .pte_low = val, .pte_high = (val >> 32) } ;
81}
82
83#ifndef CONFIG_PARAVIRT
84#define pmd_val(x) native_pmd_val(x)
85#define __pmd(x) native_make_pmd(x)
86#endif
87
Linus Torvalds1da177e2005-04-16 15:20:36 -070088#define HPAGE_SHIFT 21
Zachary Amsdena2952d82006-12-07 02:14:08 +010089#include <asm-generic/pgtable-nopud.h>
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +020090#else /* !CONFIG_X86_PAE */
Linus Torvalds1da177e2005-04-16 15:20:36 -070091typedef struct { unsigned long pte_low; } pte_t;
92typedef struct { unsigned long pgd; } pgd_t;
93typedef struct { unsigned long pgprot; } pgprot_t;
94#define boot_pte_t pte_t /* or would you rather have a typedef */
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +020095
96static inline unsigned long native_pgd_val(pgd_t pgd)
97{
98 return pgd.pgd;
99}
100
101static inline unsigned long native_pte_val(pte_t pte)
102{
103 return pte.pte_low;
104}
105
106static inline pgd_t native_make_pgd(unsigned long val)
107{
108 return (pgd_t) { val };
109}
110
111static inline pte_t native_make_pte(unsigned long val)
112{
113 return (pte_t) { .pte_low = val };
114}
115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116#define HPAGE_SHIFT 22
Zachary Amsdena2952d82006-12-07 02:14:08 +0100117#include <asm-generic/pgtable-nopmd.h>
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +0200118#endif /* CONFIG_X86_PAE */
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120#define PTE_MASK PAGE_MASK
121
122#ifdef CONFIG_HUGETLB_PAGE
123#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
124#define HPAGE_MASK (~(HPAGE_SIZE - 1))
125#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
126#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127#endif
128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#define pgprot_val(x) ((x).pgprot)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130#define __pgprot(x) ((pgprot_t) { (x) } )
131
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +0200132#ifndef CONFIG_PARAVIRT
133#define pgd_val(x) native_pgd_val(x)
134#define __pgd(x) native_make_pgd(x)
135#define pte_val(x) native_pte_val(x)
136#define __pte(x) native_make_pte(x)
137#endif
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#endif /* !__ASSEMBLY__ */
140
141/* to align the pointer to the (next) page boundary */
142#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
143
144/*
145 * This handles the memory map.. We could make this a config
146 * option, but too many people screw it up, and too few need
147 * it.
148 *
149 * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
150 * a virtual address space of one gigabyte, which limits the
151 * amount of physical memory you can use to about 950MB.
152 *
153 * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
154 * and CONFIG_HIGHMEM64G options in the kernel configuration.
155 */
156
157#ifndef __ASSEMBLY__
158
Ingo Molnare6e54942006-06-27 02:53:50 -0700159struct vm_area_struct;
160
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161/*
162 * This much address space is reserved for vmalloc() and iomap()
163 * as well as fixmap mappings.
164 */
165extern unsigned int __VMALLOC_RESERVE;
166
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167extern int sysctl_legacy_va_layout;
168
Dave Hansen5b505b92005-06-23 00:07:41 -0700169extern int page_is_ram(unsigned long pagenr);
170
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171#endif /* __ASSEMBLY__ */
172
173#ifdef __ASSEMBLY__
Mark Lord975b3d32006-02-01 03:06:11 -0800174#define __PAGE_OFFSET CONFIG_PAGE_OFFSET
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175#else
Mark Lord975b3d32006-02-01 03:06:11 -0800176#define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177#endif
178
179
180#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
181#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
182#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE)
183#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
Eric W. Biederman9f45acc2006-12-07 02:14:03 +0100184/* __pa_symbol should be used for C visible symbols.
185 This seems to be the official gcc blessed way to do such arithmetic. */
186#define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x),0))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
188#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
Andy Whitcroft05b79bd2005-06-23 00:07:57 -0700189#ifdef CONFIG_FLATMEM
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190#define pfn_valid(pfn) ((pfn) < max_mapnr)
Andy Whitcroft05b79bd2005-06-23 00:07:57 -0700191#endif /* CONFIG_FLATMEM */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
193
194#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
195
196#define VM_DATA_DEFAULT_FLAGS \
197 (VM_READ | VM_WRITE | \
198 ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
199 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
200
KAMEZAWA Hiroyukiad658b32006-03-27 01:15:33 -0800201#include <asm-generic/memory_model.h>
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -0700202#include <asm-generic/page.h>
203
Ingo Molnare6e54942006-06-27 02:53:50 -0700204#define __HAVE_ARCH_GATE_AREA 1
David Woodhousecd469e02006-04-27 15:48:08 +0100205#endif /* __KERNEL__ */
206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207#endif /* _I386_PAGE_H */