blob: e424bef4395a8b1fa009eed0e5e9f06dbeebfab5 [file] [log] [blame]
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +01001#ifndef _ASM_X86_PAGE_32_H
2#define _ASM_X86_PAGE_32_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
Linus Torvalds1da177e2005-04-16 15:20:36 -07004/*
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +01005 * This handles the memory map.
6 *
7 * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
8 * a virtual address space of one gigabyte, which limits the
9 * amount of physical memory you can use to about 950MB.
10 *
11 * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
12 * and CONFIG_HIGHMEM64G options in the kernel configuration.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 */
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010014#define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)
Jeremy Fitzhardinge3dc494e2007-05-02 19:27:13 +020015
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010016#ifdef CONFIG_X86_PAE
17#define __PHYSICAL_MASK_SHIFT 36
18#define __VIRTUAL_MASK_SHIFT 32
19#define PAGETABLE_LEVELS 3
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#ifndef __ASSEMBLY__
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010022typedef u64 pteval_t;
23typedef u64 pmdval_t;
24typedef u64 pudval_t;
25typedef u64 pgdval_t;
26typedef u64 pgprotval_t;
27typedef u64 phys_addr_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010029typedef struct { unsigned long pte_low, pte_high; } pte_t;
Ingo Molnare6e54942006-06-27 02:53:50 -070030
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010031static inline unsigned long long native_pte_val(pte_t pte)
32{
33 return pte.pte_low | ((unsigned long long)pte.pte_high << 32);
34}
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010036static inline pte_t native_make_pte(unsigned long long val)
37{
38 return (pte_t) { .pte_low = val, .pte_high = (val >> 32) } ;
39}
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010041#endif /* __ASSEMBLY__
42 */
43#else /* !CONFIG_X86_PAE */
44#define __PHYSICAL_MASK_SHIFT 32
45#define __VIRTUAL_MASK_SHIFT 32
46#define PAGETABLE_LEVELS 2
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010048#ifndef __ASSEMBLY__
49typedef unsigned long pteval_t;
50typedef unsigned long pmdval_t;
51typedef unsigned long pudval_t;
52typedef unsigned long pgdval_t;
53typedef unsigned long pgprotval_t;
54typedef unsigned long phys_addr_t;
David Woodhousecd469e02006-04-27 15:48:08 +010055
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010056typedef struct { pteval_t pte_low; } pte_t;
57typedef pte_t boot_pte_t;
58
59static inline unsigned long native_pte_val(pte_t pte)
60{
61 return pte.pte_low;
62}
63
64static inline pte_t native_make_pte(unsigned long val)
65{
66 return (pte_t) { .pte_low = val };
67}
68
69#endif /* __ASSEMBLY__ */
70#endif /* CONFIG_X86_PAE */
71
72#ifdef CONFIG_HUGETLB_PAGE
73#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
74#endif
75
76#ifndef __ASSEMBLY__
77#define __phys_addr(x) ((x)-PAGE_OFFSET)
78#define __phys_reloc_hide(x) RELOC_HIDE((x), 0)
79
80#ifdef CONFIG_FLATMEM
81#define pfn_valid(pfn) ((pfn) < max_mapnr)
82#endif /* CONFIG_FLATMEM */
83
84extern int nx_enabled;
85
86/*
87 * This much address space is reserved for vmalloc() and iomap()
88 * as well as fixmap mappings.
89 */
90extern unsigned int __VMALLOC_RESERVE;
91extern int sysctl_legacy_va_layout;
92extern int page_is_ram(unsigned long pagenr);
93
94#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
95#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE)
96
97#ifdef CONFIG_X86_USE_3DNOW
98#include <asm/mmx.h>
99
100static inline void clear_page(void *page)
101{
102 mmx_clear_page(page);
103}
104
105static inline void copy_page(void *to, void *from)
106{
107 mmx_copy_page(to, from);
108}
109#else /* !CONFIG_X86_USE_3DNOW */
110#include <linux/string.h>
111
112static inline void clear_page(void *page)
113{
114 memset(page, 0, PAGE_SIZE);
115}
116
117static inline void copy_page(void *to, void *from)
118{
119 memcpy(to, from, PAGE_SIZE);
120}
121#endif /* CONFIG_X86_3DNOW */
122#endif /* !__ASSEMBLY__ */
123
124#endif /* _ASM_X86_PAGE_32_H */