blob: 7b19f454761de838acb513e2f14f00215581d31a [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
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 */
44extern int nx_enabled;
45#ifdef CONFIG_X86_PAE
46extern unsigned long long __supported_pte_mask;
47typedef struct { unsigned long pte_low, pte_high; } pte_t;
48typedef struct { unsigned long long pmd; } pmd_t;
49typedef struct { unsigned long long pgd; } pgd_t;
50typedef 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
Zachary Amsdena2952d82006-12-07 02:14:08 +010055#include <asm-generic/pgtable-nopud.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#else
57typedef struct { unsigned long pte_low; } pte_t;
58typedef struct { unsigned long pgd; } pgd_t;
59typedef struct { unsigned long pgprot; } pgprot_t;
60#define boot_pte_t pte_t /* or would you rather have a typedef */
61#define pte_val(x) ((x).pte_low)
62#define HPAGE_SHIFT 22
Zachary Amsdena2952d82006-12-07 02:14:08 +010063#include <asm-generic/pgtable-nopmd.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#endif
65#define PTE_MASK PAGE_MASK
66
67#ifdef CONFIG_HUGETLB_PAGE
68#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
69#define HPAGE_MASK (~(HPAGE_SIZE - 1))
70#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
71#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -070072#endif
73
74#define pgd_val(x) ((x).pgd)
75#define pgprot_val(x) ((x).pgprot)
76
77#define __pte(x) ((pte_t) { (x) } )
78#define __pgd(x) ((pgd_t) { (x) } )
79#define __pgprot(x) ((pgprot_t) { (x) } )
80
81#endif /* !__ASSEMBLY__ */
82
83/* to align the pointer to the (next) page boundary */
84#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
85
86/*
87 * This handles the memory map.. We could make this a config
88 * option, but too many people screw it up, and too few need
89 * it.
90 *
91 * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
92 * a virtual address space of one gigabyte, which limits the
93 * amount of physical memory you can use to about 950MB.
94 *
95 * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
96 * and CONFIG_HIGHMEM64G options in the kernel configuration.
97 */
98
99#ifndef __ASSEMBLY__
100
Ingo Molnare6e54942006-06-27 02:53:50 -0700101struct vm_area_struct;
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103/*
104 * This much address space is reserved for vmalloc() and iomap()
105 * as well as fixmap mappings.
106 */
107extern unsigned int __VMALLOC_RESERVE;
108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109extern int sysctl_legacy_va_layout;
110
Dave Hansen5b505b92005-06-23 00:07:41 -0700111extern int page_is_ram(unsigned long pagenr);
112
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113#endif /* __ASSEMBLY__ */
114
115#ifdef __ASSEMBLY__
Mark Lord975b3d32006-02-01 03:06:11 -0800116#define __PAGE_OFFSET CONFIG_PAGE_OFFSET
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117#else
Mark Lord975b3d32006-02-01 03:06:11 -0800118#define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119#endif
120
121
122#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
123#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
124#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE)
125#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
Eric W. Biederman9f45acc2006-12-07 02:14:03 +0100126/* __pa_symbol should be used for C visible symbols.
127 This seems to be the official gcc blessed way to do such arithmetic. */
128#define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x),0))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
130#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
Andy Whitcroft05b79bd2005-06-23 00:07:57 -0700131#ifdef CONFIG_FLATMEM
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132#define pfn_valid(pfn) ((pfn) < max_mapnr)
Andy Whitcroft05b79bd2005-06-23 00:07:57 -0700133#endif /* CONFIG_FLATMEM */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
135
136#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
137
138#define VM_DATA_DEFAULT_FLAGS \
139 (VM_READ | VM_WRITE | \
140 ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
141 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
142
KAMEZAWA Hiroyukiad658b32006-03-27 01:15:33 -0800143#include <asm-generic/memory_model.h>
Stephen Rothwellfd4fd5a2005-09-03 15:54:30 -0700144#include <asm-generic/page.h>
145
Roland McGratha1f3bb92007-01-26 00:56:46 -0800146#ifndef CONFIG_COMPAT_VDSO
Ingo Molnare6e54942006-06-27 02:53:50 -0700147#define __HAVE_ARCH_GATE_AREA 1
Roland McGratha1f3bb92007-01-26 00:56:46 -0800148#endif
David Woodhousecd469e02006-04-27 15:48:08 +0100149#endif /* __KERNEL__ */
150
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151#endif /* _I386_PAGE_H */