debuggers.hg

view xen/include/asm-x86/page.h @ 3765:4dfebfdc7933

bitkeeper revision 1.1159.252.1 (4208e2a42Fwe83QQfJdFQI8V302tYg)

Reorganise mm.h to split out 32-bit and 64-bit definitions. Fix x86_64
definitions to mask out the bits that we don't care about.
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@scramble.cl.cam.ac.uk
date Tue Feb 08 16:02:44 2005 +0000 (2005-02-08)
parents 9f7935ea4606
children 89e86842952a
line source
1 /* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
3 #ifndef __X86_PAGE_H__
4 #define __X86_PAGE_H__
6 #if defined(__i386__)
7 #include <asm/x86_32/page.h>
8 #elif defined(__x86_64__)
9 #include <asm/x86_64/page.h>
10 #endif
12 #ifndef __ASSEMBLY__
13 #define PAGE_SIZE (1UL << PAGE_SHIFT)
14 #else
15 #define PAGE_SIZE (1 << PAGE_SHIFT)
16 #endif
17 #define PAGE_MASK (~(PAGE_SIZE-1))
19 #define clear_page(_p) memset((void *)(_p), 0, PAGE_SIZE)
20 #define copy_page(_t,_f) memcpy((void *)(_t), (void *)(_f), PAGE_SIZE)
22 #define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
23 #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
24 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
25 #define pfn_to_page(_pfn) (frame_table + (_pfn))
26 #define phys_to_page(kaddr) (frame_table + ((kaddr) >> PAGE_SHIFT))
27 #define virt_to_page(kaddr) (frame_table + (__pa(kaddr) >> PAGE_SHIFT))
28 #define VALID_PAGE(page) ((page - frame_table) < max_mapnr)
30 /*
31 * NB. We don't currently track I/O holes in the physical RAM space.
32 * For now we guess that I/O devices will be mapped in the first 1MB
33 * (e.g., VGA buffers) or beyond the end of physical RAM.
34 */
35 #define pfn_is_ram(_pfn) (((_pfn) > 0x100) && ((_pfn) < max_page))
37 /* High table entries are reserved by the hypervisor. */
38 #define DOMAIN_ENTRIES_PER_L2_PAGETABLE \
39 (HYPERVISOR_VIRT_START >> L2_PAGETABLE_SHIFT)
40 #define HYPERVISOR_ENTRIES_PER_L2_PAGETABLE \
41 (ENTRIES_PER_L2_PAGETABLE - DOMAIN_ENTRIES_PER_L2_PAGETABLE)
43 #ifndef __ASSEMBLY__
44 #include <asm/processor.h>
45 #include <asm/fixmap.h>
46 #include <asm/bitops.h>
47 #include <asm/flushtlb.h>
49 #define linear_pg_table ((l1_pgentry_t *)LINEAR_PT_VIRT_START)
50 #define linear_l2_table ((l2_pgentry_t *)(LINEAR_PT_VIRT_START+(LINEAR_PT_VIRT_START>>(L2_PAGETABLE_SHIFT-L1_PAGETABLE_SHIFT))))
52 #define va_to_l1mfn(_va) (l2_pgentry_val(linear_l2_table[_va>>L2_PAGETABLE_SHIFT]) >> PAGE_SHIFT)
54 extern pagetable_t idle_pg_table[ENTRIES_PER_PAGETABLE];
56 extern void paging_init(void);
58 /* Flush global pages as well. */
60 #define __pge_off() \
61 do { \
62 __asm__ __volatile__( \
63 "mov %0, %%cr4; # turn off PGE " \
64 :: "r" (mmu_cr4_features & ~X86_CR4_PGE)); \
65 } while (0)
67 #define __pge_on() \
68 do { \
69 __asm__ __volatile__( \
70 "mov %0, %%cr4; # turn off PGE " \
71 :: "r" (mmu_cr4_features)); \
72 } while (0)
75 #define __flush_tlb_pge() \
76 do { \
77 __pge_off(); \
78 __flush_tlb(); \
79 __pge_on(); \
80 } while (0)
82 #define __flush_tlb_one(__addr) \
83 __asm__ __volatile__("invlpg %0": :"m" (*(char *) (__addr)))
85 #endif /* !__ASSEMBLY__ */
88 #define _PAGE_PRESENT 0x001
89 #define _PAGE_RW 0x002
90 #define _PAGE_USER 0x004
91 #define _PAGE_PWT 0x008
92 #define _PAGE_PCD 0x010
93 #define _PAGE_ACCESSED 0x020
94 #define _PAGE_DIRTY 0x040
95 #define _PAGE_PAT 0x080
96 #define _PAGE_PSE 0x080
97 #define _PAGE_GLOBAL 0x100
99 #define __PAGE_HYPERVISOR \
100 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
101 #define __PAGE_HYPERVISOR_NOCACHE \
102 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_PCD | _PAGE_ACCESSED)
104 #define MAKE_GLOBAL(_x) ((_x) | _PAGE_GLOBAL)
106 #define PAGE_HYPERVISOR MAKE_GLOBAL(__PAGE_HYPERVISOR)
107 #define PAGE_HYPERVISOR_NOCACHE MAKE_GLOBAL(__PAGE_HYPERVISOR_NOCACHE)
109 #ifndef __ASSEMBLY__
111 static __inline__ int get_order(unsigned long size)
112 {
113 int order;
115 size = (size-1) >> (PAGE_SHIFT-1);
116 order = -1;
117 do {
118 size >>= 1;
119 order++;
120 } while (size);
121 return order;
122 }
124 extern void zap_low_mappings(void);
126 /* Map physical byte range (@p, @p+@s) at virt address @v in pagetable @pt. */
127 extern int
128 map_pages(
129 pagetable_t *pt,
130 unsigned long v,
131 unsigned long p,
132 unsigned long s,
133 unsigned long flags);
135 #endif /* !__ASSEMBLY__ */
137 #endif /* __I386_PAGE_H__ */