blob: 5e64acfed0a4882b1bf392e0541b03df8d53734f [file] [log] [blame]
Vegard Nossum77ef50a2008-06-18 17:08:48 +02001#ifndef ASM_X86__PAGE_64_H
2#define ASM_X86__PAGE_64_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +01004#define PAGETABLE_LEVELS 4
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +01006#define THREAD_ORDER 1
7#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER)
Joe Perchesb20a4612008-03-23 01:02:58 -07008#define CURRENT_MASK (~(THREAD_SIZE - 1))
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +01009
10#define EXCEPTION_STACK_ORDER 0
11#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
12
13#define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
14#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
15
16#define IRQSTACK_ORDER 2
17#define IRQSTACKSIZE (PAGE_SIZE << IRQSTACK_ORDER)
18
19#define STACKFAULT_STACK 1
20#define DOUBLEFAULT_STACK 2
21#define NMI_STACK 3
22#define DEBUG_STACK 4
23#define MCE_STACK 5
24#define N_EXCEPTION_STACKS 5 /* hw limit: 7 */
25
Andi Kleenfbff3c22008-02-04 16:48:09 +010026#define PUD_PAGE_SIZE (_AC(1, UL) << PUD_SHIFT)
27#define PUD_PAGE_MASK (~(PUD_PAGE_SIZE-1))
28
Eduardo Habkosta6523742008-06-25 00:19:16 -040029/*
30 * Set __PAGE_OFFSET to the most negative possible address +
31 * PGDIR_SIZE*16 (pgd slot 272). The gap is to allow a space for a
32 * hypervisor to fit. Choosing 16 slots here is arbitrary, but it's
33 * what Xen requires.
34 */
35#define __PAGE_OFFSET _AC(0xffff880000000000, UL)
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010036
37#define __PHYSICAL_START CONFIG_PHYSICAL_START
38#define __KERNEL_ALIGN 0x200000
39
40/*
41 * Make sure kernel is aligned to 2MB address. Catching it at compile
42 * time is better. Change your config file and compile the kernel
43 * for a 2MB aligned address (CONFIG_PHYSICAL_START)
44 */
45#if (CONFIG_PHYSICAL_START % __KERNEL_ALIGN) != 0
46#error "CONFIG_PHYSICAL_START must be a multiple of 2MB"
47#endif
48
49#define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START)
50#define __START_KERNEL_map _AC(0xffffffff80000000, UL)
51
52/* See Documentation/x86_64/mm.txt for a description of the memory map. */
53#define __PHYSICAL_MASK_SHIFT 46
54#define __VIRTUAL_MASK_SHIFT 48
55
Ingo Molnar88f3aec2008-02-21 11:04:11 +010056/*
Ingo Molnar85eb69a2008-02-21 12:50:51 +010057 * Kernel image size is limited to 512 MB (see level2_kernel_pgt in
Ingo Molnar88f3aec2008-02-21 11:04:11 +010058 * arch/x86/kernel/head_64.S), and it is mapped here:
59 */
Joe Perchesb20a4612008-03-23 01:02:58 -070060#define KERNEL_IMAGE_SIZE (512 * 1024 * 1024)
Ingo Molnard4afe412008-02-21 13:39:30 +010061#define KERNEL_IMAGE_START _AC(0xffffffff80000000, UL)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#ifndef __ASSEMBLY__
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010064void clear_page(void *page);
65void copy_page(void *to, void *from);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Yinghai Luc987d122008-06-24 22:14:09 -070067/* duplicated to the one in bootmem.h */
68extern unsigned long max_pfn;
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010069extern unsigned long phys_base;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010071extern unsigned long __phys_addr(unsigned long);
72#define __phys_reloc_hide(x) (x)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010074/*
75 * These are used to make use of C type-checking..
76 */
77typedef unsigned long pteval_t;
78typedef unsigned long pmdval_t;
79typedef unsigned long pudval_t;
80typedef unsigned long pgdval_t;
81typedef unsigned long pgprotval_t;
82typedef unsigned long phys_addr_t;
83
Martin Schwidefsky2f569af2008-02-08 04:22:04 -080084typedef struct page *pgtable_t;
85
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010086typedef struct { pteval_t pte; } pte_t;
87
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010088#define vmemmap ((struct page *)VMEMMAP_START)
89
Andi Kleencc615032008-03-12 03:53:28 +010090extern unsigned long init_memory_mapping(unsigned long start,
91 unsigned long end);
92
Yinghai Lu1f75d7e2008-06-22 02:44:49 -070093extern void initmem_init(unsigned long start_pfn, unsigned long end_pfn);
Jaswinder Singha80495e2008-07-23 17:33:57 +053094extern void free_initmem(void);
Jack Steiner3a9e1892008-07-01 14:45:32 -050095
96extern void init_extra_mapping_uc(unsigned long phys, unsigned long size);
97extern void init_extra_mapping_wb(unsigned long phys, unsigned long size);
98
Jeremy Fitzhardinge11b7c7d2008-01-30 13:32:44 +010099#endif /* !__ASSEMBLY__ */
David Woodhousecd469e02006-04-27 15:48:08 +0100100
Jeremy Fitzhardinge83a51012008-01-30 13:32:41 +0100101#ifdef CONFIG_FLATMEM
Yinghai Luc987d122008-06-24 22:14:09 -0700102#define pfn_valid(pfn) ((pfn) < max_pfn)
Jeremy Fitzhardinge83a51012008-01-30 13:32:41 +0100103#endif
104
105
Vegard Nossum77ef50a2008-06-18 17:08:48 +0200106#endif /* ASM_X86__PAGE_64_H */