debuggers.hg

view xen/include/asm-x86/x86_32/page.h @ 4629:6375127fdf23

bitkeeper revision 1.1311.1.1 (426641eeBv97w6sl983zxeR4Dc3Utg)

Cleanup page table handling. Add macros to access page table
entries, fixup plenty of places in the code to use the page
table types instead of "unsigned long".

Signed-off-by: Gerd Knorr <kraxel@bytesex.org>
Signed-off-by: michael.fetterman@cl.cam.ac.uk
author mafetter@fleming.research
date Wed Apr 20 11:50:06 2005 +0000 (2005-04-20)
parents a01199a95070
children 1803018b3b05
line source
2 #ifndef __X86_32_PAGE_H__
3 #define __X86_32_PAGE_H__
5 #define L1_PAGETABLE_SHIFT 12
6 #define L2_PAGETABLE_SHIFT 22
7 #define PAGE_SHIFT L1_PAGETABLE_SHIFT
8 #define ROOT_PAGETABLE_SHIFT L2_PAGETABLE_SHIFT
10 #define PAGETABLE_ORDER 10
11 #define L1_PAGETABLE_ENTRIES (1<<PAGETABLE_ORDER)
12 #define L2_PAGETABLE_ENTRIES (1<<PAGETABLE_ORDER)
13 #define ROOT_PAGETABLE_ENTRIES L2_PAGETABLE_ENTRIES
15 #define __PAGE_OFFSET (0xFC400000)
17 #define PADDR_BITS 32
18 #define VADDR_BITS 32
19 #define PADDR_MASK (~0UL)
20 #define VADDR_MASK (~0UL)
22 #define _PAGE_NX 0UL
23 #define PAGE_FLAG_MASK 0xfff
25 #ifndef __ASSEMBLY__
26 #include <xen/config.h>
27 #include <asm/types.h>
28 typedef struct { u32 l1_lo; } l1_pgentry_t;
29 typedef struct { u32 l2_lo; } l2_pgentry_t;
30 typedef l2_pgentry_t root_pgentry_t;
32 /* read access (depricated) */
33 #define l1e_get_value(_x) ((_x).l1_lo)
34 #define l2e_get_value(_x) ((_x).l2_lo)
36 /* read access */
37 #define l1e_get_pfn(_x) ((_x).l1_lo >> PAGE_SHIFT)
38 #define l1e_get_phys(_x) ((_x).l1_lo & PAGE_MASK)
39 #define l1e_get_flags(_x) ((_x).l1_lo & PAGE_FLAG_MASK)
41 #define l2e_get_pfn(_x) ((_x).l2_lo >> PAGE_SHIFT)
42 #define l2e_get_phys(_x) ((_x).l2_lo & PAGE_MASK)
43 #define l2e_get_flags(_x) ((_x).l2_lo & PAGE_FLAG_MASK)
45 /* write access */
46 static inline l1_pgentry_t l1e_empty(void)
47 {
48 l1_pgentry_t e = { .l1_lo = 0 };
49 return e;
50 }
51 static inline l1_pgentry_t l1e_create_pfn(u32 pfn, u32 flags)
52 {
53 l1_pgentry_t e = { .l1_lo = (pfn << PAGE_SHIFT) | flags };
54 return e;
55 }
56 static inline l1_pgentry_t l1e_create_phys(u32 addr, u32 flags)
57 {
58 l1_pgentry_t e = { .l1_lo = (addr & PAGE_MASK) | flags };
59 return e;
60 }
61 static inline void l1e_add_flags(l1_pgentry_t *e, u32 flags)
62 {
63 e->l1_lo |= flags;
64 }
65 static inline void l1e_remove_flags(l1_pgentry_t *e, u32 flags)
66 {
67 e->l1_lo &= ~flags;
68 }
70 static inline l2_pgentry_t l2e_empty(void)
71 {
72 l2_pgentry_t e = { .l2_lo = 0 };
73 return e;
74 }
75 static inline l2_pgentry_t l2e_create_pfn(u32 pfn, u32 flags)
76 {
77 l2_pgentry_t e = { .l2_lo = (pfn << PAGE_SHIFT) | flags };
78 return e;
79 }
80 static inline l2_pgentry_t l2e_create_phys(u32 addr, u32 flags)
81 {
82 l2_pgentry_t e = { .l2_lo = (addr & PAGE_MASK) | flags };
83 return e;
84 }
85 static inline void l2e_add_flags(l2_pgentry_t *e, u32 flags)
86 {
87 e->l2_lo |= flags;
88 }
89 static inline void l2e_remove_flags(l2_pgentry_t *e, u32 flags)
90 {
91 e->l2_lo &= ~flags;
92 }
94 /* check entries */
95 static inline int l1e_has_changed(l1_pgentry_t *e1, l1_pgentry_t *e2, u32 flags)
96 {
97 return ((e1->l1_lo ^ e2->l1_lo) & (PAGE_MASK | flags)) != 0;
98 }
99 static inline int l2e_has_changed(l2_pgentry_t *e1, l2_pgentry_t *e2, u32 flags)
100 {
101 return ((e1->l2_lo ^ e2->l2_lo) & (PAGE_MASK | flags)) != 0;
102 }
104 #endif /* !__ASSEMBLY__ */
106 /* Pagetable walking. */
107 #define l2e_to_l1e(_x) \
108 ((l1_pgentry_t *)__va(l2e_get_phys(_x)))
110 /* Given a virtual address, get an entry offset into a page table. */
111 #define l1_table_offset(_a) \
112 (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1))
113 #define l2_table_offset(_a) \
114 ((_a) >> L2_PAGETABLE_SHIFT)
116 /* Given a virtual address, get an entry offset into a linear page table. */
117 #define l1_linear_offset(_a) ((_a) >> PAGE_SHIFT)
119 #define is_guest_l1_slot(_s) (1)
120 #define is_guest_l2_slot(_s) ((_s) < ROOT_PAGETABLE_FIRST_XEN_SLOT)
122 #define root_get_pfn l2e_get_pfn
123 #define root_get_flags l2e_get_flags
124 #define root_get_value l2e_get_value
125 #define root_empty l2e_empty
126 #define root_create_phys l2e_create_phys
127 #define PGT_root_page_table PGT_l2_page_table
129 #define L1_DISALLOW_MASK (3UL << 7)
130 #define L2_DISALLOW_MASK (7UL << 7)
131 #define L3_DISALLOW_MASK (7UL << 7)
132 #define L4_DISALLOW_MASK (7UL << 7)
134 #endif /* __X86_32_PAGE_H__ */
136 /*
137 * Local variables:
138 * mode: C
139 * c-set-style: "BSD"
140 * c-basic-offset: 4
141 * tab-width: 4
142 * indent-tabs-mode: nil
143 * End:
144 */